Skip to Content
author's profile photo Former Member
Former Member

Store Procedure for Sales Employee mandatory

Hi Experts,

I want Stored Procedure in which if the user doesn't mention Sales Employee name it should not add Sales Quotation and Sales Order.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2011 at 07:37 AM

    Hi Shailesh......

    Please check this......

    For Order:

    If @object_type='17' and @transaction_type IN ('A','U')
    BEGIN 
    If Exists (Select T0.DocNum from ORDR T0 INNER JOIN RDR1 T1 
    ON T0.DocEntry=T1.DocEntry 
    Where (T0.SlpCode is null or T0.SlpCode = -1)
    And T0.DocEntry = @list_of_cols_val_tab_del)
    BEGIN
    Select @error = -1,
    @error_message = 'Please choose proper Sales Employee'
    End
    End

    And For Sales Quotation:

    If @object_type='23' and @transaction_type IN ('A','U')
    BEGIN 
    If Exists (Select T0.DocNum from OQUT T0 INNER JOIN QUT1 T1 
    ON T0.DocEntry=T1.DocEntry 
    Where (T0.SlpCode is null or T0.SlpCode = -1)
    And T0.DocEntry = @list_of_cols_val_tab_del)
    BEGIN
    Select @error = -1,
    @error_message = 'Please choose proper Sales Employee'
    End
    End

    Regards,

    Rahul

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2011 at 06:31 AM

    hi

    For sales quotation,

    IF(@object_type='23') and (@transaction_type IN ('A','U'))
    begin
    SELECT T2.[DocEntry] FROM OQUT T0 INNER JOIN  OINV T1 on t0.CardCode = t1.CardCode INNER JOIN QUT1 T2 ON T0.DocEntry = T2.DocEntry WHERE T1.[OwnerCode] IS NULL AND T0.DocEntry = @list_of_cols_val_tab_del)
    Begin
    SET @error = 30
    SET @error_message =N'You cannot add the sales quotation without Sales Employee'
    end

    For SO,

    IF(@object_type='17') and (@transaction_type IN ('A','U'))
    begin
    SELECT T2.[DocEntry] FROM ORDR T0 INNER JOIN  OINV T1 on t0.CardCode = t1.CardCode INNER JOIN RDR1 T2 ON T0.DocEntry = T2.DocEntry WHERE T1.[OwnerCode] IS NULL AND T0.DocEntry = @list_of_cols_val_tab_del)
    Begin
    SET @error = 50
    SET @error_message =N'You cannot add the sales order without Sales Employee'
    end

    Edited by: kambadasan on Sep 23, 2011 12:02 PM

    Edited by: kambadasan on Sep 23, 2011 12:02 PM

    Edited by: kambadasan on Sep 23, 2011 12:03 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2011 at 06:37 AM

    Hi,

    For SO:

    IF @object_type='17' AND @transaction_type IN(N'A', N'U')
    BEGIN
    	DECLARE @sales AS INT
    	SELECT @sales=ISNULL(SlpCode,-1) FROM ORDR WHERE DocEntry=@list_of_cols_val_tab_del
    	IF @sales=-1
    	  BEGIN
    		SET @error=-123
    		SET @error_message='Sales person is mandatory for this document'
    	  END
    END
    

    For SQ:

    IF @object_type='23' AND @transaction_type IN(N'A', N'U')
    BEGIN
    	DECLARE @sales AS INT
    	SELECT @sales=ISNULL(SlpCode,-1) FROM OQUT WHERE DocEntry=@list_of_cols_val_tab_del
    	IF @sales=-1
    	  BEGIN
    		SET @error=-123
    		SET @error_message='Sales person is mandatory for this document'
    	  END
    END
    

    Best Regards,

    Hendry Wijaya

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.