Hi
I have below Stored Procedure & i want that it should not ask for Base document if Currecny <> INR & doctotal = 0
else in all condition it should ask for Base Document.
SQL
if exists(Select ItemCode from [dbo].[PDN1] T0
Where T0.BaseEntry IS NULL
AND T0.DocEntry=@list_of_cols_val_tab_del)
begin
SELECT @error = 33, @error_message = 'GRPO without Base Document !'
endThanks

Brahma Prakash ShuklaRank #633 · 3.8K reputationPosted Nov 30, 2023, 3:11 AM EST
IF EXISTS ( SELECT ItemCode FROM [dbo].[PDN1] T0 WHERE T0.BaseEntry IS NULL AND T0.DocEntry = @list_of_cols_val_tab_del ) BEGIN IF NOT EXISTS ( SELECT 1 FROM YourTable -- Replace YourTable with the actual table where you can get the currency and doctotal values WHERE DocEntry = @list_of_cols_val_tab_del AND Currency <> 'INR' AND doctotal = 0 ) BEGIN -- Currency is not INR and doctotal is 0, no need to ask for Base Document -- You can add any additional logic or set variables as needed END ELSE BEGIN -- Currency is INR or doctotal is not 0, ask for Base Document SELECT @error = 33, @error_message = 'GRPO without Base Document !' END END