Problem in blocking that amount in the sales order through routein
We are facing a problem in Routine,
We have developed a Z rebate module in that we are saving the accrual value for a perticular customer in "Z" Table.
We are having a senerio of adjusting that perticular accrued amount in the next month sales order as a discount at the item level. In table itself we fix this much amount as to flow to sales order for a Perticular material (EX- for 100001 material 5 rs per TON).
We have devaloped 901 routine that will go to "z" table and check any accrued amount is there then depending on the quantity ordered it will take accrual amount (simultanusly it will block the respective amount in the "z" table) and it will come and update in sales order pricing. Once we save sales order then it will reduse the perticular amount in from "z" table.
Now we are facing a problem, when we create a sales order first time depending on quantity routine will pull the value from "z" table and it will block respective amount in the "z" table. but before saving the sales order if you change the quantity again (EX- from 100 qty to 200 qty) then the routine is not pulling any value because the amount is already blocked.
Can any one tell me how check in run time this was the earlier quantity and this is changes quantity Or is there any logic to block that perticular amount.