Skip to Content
0
May 16, 2023 at 03:48 AM

Store Procedure for Delivery Order

282 Views Last edit Aug 14, 2023 at 03:07 AM 2 rev

Hi. I have a one issues where my warehouse admin when they do the DO and copy from SO, certain line did not capture the baseref value which the baseref column in DO refer to SO number. please refer example below:

image.png

when this issues happened, the SO that should be auto closed but due to this issues and sales PIC need to manually closed the SO.

So here i want to make a control, whenever DO that copy from SO and if any DO line that not capture the baseref number then they won't allow to add the DO. Below is my stored procedure code but it is not working:

IF @object_type='15' AND @transaction_type IN ('A','U')
BEGIN
    IF EXISTS (
        SELECT t0.DocEntry, t1.LineNum
        FROM ODLN t0
        INNER JOIN DLN1 t1 ON t0.DocEntry =t1.DocEntry
		
        WHERE t1.BaseType = '-1'
        --AND t1.BaseEntry IS NOT NULL
        AND t1.BaseRef IS NULL and t1.DocEntry=@list_of_cols_val_tab_del
    )
    BEGIN   
        Set @error = -1
        SET @error_message = 'Baseref Empty'
    END
END 
Can someone help me? Thanks a lot.

Attachments

image.png (36.3 kB)