Skip to Content

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

How to prevent Sales Orders to be added if the BP...

does not have enough funds (considering other open orders).

I have a problem where operaters can add as many sales order for a BP as they would like as long as the total amount on the order is below his available credit (OCRD_CreditLine minus OCRD_Balance)

I would like to add a stored procedure that will also take OCRD_OrdersBal into consideration.

If a BP has a credit limit of 50,000 and account balance of 31,000 and no other open orders, any order with a document total of 19,000 or less should be allowed to be captured.

If however the BP has a credit limit of 50,000 and account balance of 31,000 with a open order of 10,000, no orders above 9,000 should be able to get added.

Hope how I explained make sense?

All help will be greatly appreciated.

Former Member
Former Member replied

Hello,

Try this in SP_transaction Notification it will work

-


Order Amount Value----


IF (@transaction_type = 'A' Or @transaction_type = 'U') AND @object_type = '17'

BEGIN

Declare @OpenOrderAmount as decimal(10,2)

Declare @CreditLimitAmount as decimal(10,2)

Declare @CurrentOrderAmount as decimal(10,2)

Declare @Balance as decimal(10,2)

Declare @AvailOrder as Decimal(10,2)

Set @CreditLimitAmount = (Select CreditLine from OCRD where CardCode = (Select CardCode from ORDR where DocEntry =@list_of_cols_val_tab_del))

Set @Balance = (Select Balance from OCRD where CardCode = (Select CardCode from ORDR where DocEntry =@list_of_cols_val_tab_del))

Set @OpenOrderAmount = (Select OrdersBal from OCRD where CardCode = (Select CardCode from ORDR where DocEntry =@list_of_cols_val_tab_del))

Set @CurrentOrderAmount = (select Convert(decimal(10,2),DocTotal) from ORDR where DocEntry =@list_of_cols_val_tab_del)

Set @AvailOrder = (@CreditLimitAmount-(@Balance +@OpenOrderAmount))

If @AvailOrder < @CurrentOrderAmount

begin

SET @error = 10

SET @error_message = N'Total Order Amount Should be ' + cONVERT(NVARCHAR(20),@AvailOrder)

end

END

-


End----


Thanks

Manvendra Singh Niranjan

0 View this answer in context

Helpful Answer

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