Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Need help for SP

Dear Team,

Below i mentioned my stored procedure for Block production order if there is no stock.

Actually t0.U_stockcbe  is a FMS alphanumeric field contains stock in warehouse.But this sp is not working correctly.

please help

IF @transaction_type IN (N'A', N'U') AND (@Object_type = N'202')

if  Exists( SELECT   T0.[LineNum]  FROM WOR1 T0  INNER JOIN OWOR T1 ON T0.DocEntry = T1.DocEntry

WHERE T0.[PlannedQty]>t0.U_stockcbe 

and T1.DocEntry= @list_of_cols_val_tab_del )

  Begin

  Set @error =9

  Set @error_message = 'prd Orderd Quantity is greater than Stock!! '

  End

End

Regards

Sanu

Former Member
replied

Hi Sanu,

below SP checks the Stock in selected warehouse no need of UDF

-- Prd. Order Avaiable Qty

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

BEGIN

If exists ( SELECT     T0.DocNum, T1.BaseQty, T1.PlannedQty, T2.OnHand, T1.ItemCode, T2.OnHand - T1.PlannedQty AS Avail

FROM         OWOR AS T0 INNER JOIN WOR1 AS T1 ON T0.DocEntry = T1.DocEntry INNER JOIN

OITW AS T2 ON T1.ItemCode = T2.ItemCode AND T1.wareHouse = T2.WhsCode

--INNER JOIN OITM AS T3 ON T1.ItemCode = T3.ItemCode

WHERE     (T2.OnHand - T1.PlannedQty < 0) AND T0.[DocEntry] = @list_of_cols_val_tab_del

and (select itemtype from OITM where ItemCode = T1.ItemCode) <> 'L' )

BEGIN

SELECT @Error = 15, @error_message = 'Qty. not Available in the selected WHS'

End

end

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question