cancel
Showing results for 
Search instead for 
Did you mean: 

Stored proc to block doc if base doc series is different

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

MukeshSingh
Participant
0 Kudos

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

Former Member
0 Kudos

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