Do things until a parameter goes down to zero

I have a table called SALES-RECORD

This table has all the sales of our website and records whether the sold item is in stock and how many are out of stock.

I also have another table called BAG-NAME that records the number of bags in stock in the warehouse.

Now we get bags from the factory let’s say 100 blue bags so I want to create a workflow that first looks inside the table sales-record and clears the outstanding orders and then if there are any bags left it adds them on the stock on table BAG-NAME.

If I have a variable called Bagsin that takes the value of the bags that came ( in this instance 100)
I can create a workflow:

Constraint ItemName=Blue Bag
Constraint QtyOutOfStock>0

Then I want to allocate the 100 bags that came to the ones that have QtyOutOf Stock>0 but until QtyOutOfStock=0 so the QtyOutOfStock should not get negative values.

Also If I have less bags than QtyOutOfStock required then that has to carry on until variable BAgsIn is zero.

Finally whatever left to be added to stock in BAG-NAME table…

What’s the best way of doing that please?

This topic was automatically closed after 70 days. New replies are no longer allowed.