Skip to Content
0
Former Member
Jul 20, 2016 at 10:25 AM

Stored proc to block doc if base doc series is different

36 Views

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 😊