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

Stored proc to block doc if base doc series is different

Hi All

A customer has a number of numbering series. When they do a sales order for example for a specific series and copy to a delivery it defaults to the primary series (standard sap business one behaviour).

To prevent users from making mistakes we want to add a stored proc to block them if the base doc numbering series is different from the doc being added.

this is my stored proc: but it blocks the delivery if the sales order has the same numbering series.

IF (@transaction_type = 'A' or @transaction_type = 'U') AND @Object_type = '15'

BEGIN

IF EXISTS (Select T1.BaseEntry

From ODLN T0 inner join DLN1 T1 on T0.DocEntry = T1.DocEntry

inner join RDR1 T2 on T1.BaseEntry = T2.DocEntry

inner join ORDR T3 on T3.DocEntry = T2.DocEntry

where (T0.DocEntry = @LIST_OF_COLS_VAL_TAB_DEL) and (T0.Series <> T3.Series))

BEGIN

SET @ERROR = -1

SET @ERROR_MESSAGE = 'Series does not match'

END

END

What am i missing? 😕

Thank you.

Jerusha 😊

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 20, 2016 at 10:35 AM

    Hi Jerusha,

    Try below:

    IF (@transaction_type = 'A' or @transaction_type = 'U') AND @Object_type = '15'

    BEGIN

    IF EXISTS (Select T0.DocEntry

    From ODLN T0

    inner join DLN1 T1 on T0.DocEntry = T1.DocEntry

    inner join RDR1 T2 on T1.BaseEntry = T2.DocEntry AND T1.BaseLine = T2.LineNum

    inner join ORDR T3 on T3.DocEntry = T2.DocEntry

    where T0.Series <> T3.Series and T0.DocEntry = @LIST_OF_COLS_VAL_TAB_DEL)

    BEGIN

    SET @ERROR = -1

    SET @ERROR_MESSAGE = 'Series does not match'

    END

    END

    Hope this helps 😊

    Thanks'

    --

    --

    Regards::::

    Atul Chakraborty

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 20, 2016 at 12:08 PM

    Hi Jerusha,

    Try this

    IF @transaction_type = ('A', 'U') AND @Object_type = '15'

    BEGIN

    IF EXISTS (Select T0.DocEntry From ODLN T0

    inner join DLN1 T1 on T0.DocEntry = T1.DocEntry

    inner join NNM1 T4 on t0.Series=t4.Series

    inner join RDR1 T2 on T1.BaseEntry = T2.DocEntry AND T1.BaseLine = T2.LineNum

    inner join ORDR T3 on T3.DocEntry = T2.DocEntry

    inner join NNM1 T5 on t3.Series=T5.Series

    where T4.SeriesName <> T5.SeriesName and T0.DocEntry=@LIST_OF_COLS_VAL_TAB_DEL)

    BEGIN SET @ERROR = -1

    SET @ERROR_MESSAGE = 'Series does not match'

    END

    END

    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.