Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Inspection of multiple columns in table

Hi, 

 

I am fairly new to PlantSim and I encountered several problems while trying to build up a logic. 

 

Logic should be like following: For the "W" stream orders from the SalesOrder table, I wanted to compare Quantity value {SalesOrder table} and Amount Value {StockLevel table} for the corresponding SKU. 

 

And if Quantity < Amount then create MU.Order on the 'Shipment' on a predetermined date, smth like Duedate {SalesOrder} - 7 days.

 

I tried to code this all in a Method, but it didn't work out. I would like to hear your suggestions. 

 

Thanks in advance. 

 

Kind regards, 

 

Orkhan

 

 

2 REPLIES
Solution
Solution
Accepted by topic author Orxan
‎10-19-2016 08:04 AM

Re: Inspection of multiple columns in table

Something like this could work:

 

SalesOrder table:

column 1 = SKU ID

column 2 = Order quantity

column 3 = # days until shipped

each row is a separate order

 

StockLevel table:

column 1 = SKU ID

column 2 = Current stock level

coulmn 3 = Pending shipments

each row is a separate SKU

 

Orders are processed in a method as follows:

 

is

     i : integer

     stockNum : integer

do

     for i := 1 to SalesOrder.YDim loop

 

          -- find SKU in stock level table

 

          StockLevel.setCursor(1,1);

          if StockLevel.find({1,*},SalesOrder[1,i]) then

 

              -- check if there is sufficient inventory

 

              stockNum := StockLevel.cursorY;

              if StockLevel[2,stockNum] - StockLevel[3,stockNum] >= SalesOrder[2,i] then

        

                  -- increment pending shipments

        

                  StockLevel[3,stockNum] := StockLevel[3,stockNum] + SalesOrder[2,i];

 

                  -- schedule shipment of order quantity to occur at the appropriate time

                  -- (number of seconds in the future)

 

                  ref(ShipOrder).methCall((SalesOrder[3,i] * 24 * 3600),SalesOrder[2,i]);

              end;

          end;

     next;

end;

 

In the method ShipOrder, pending shipments and stock level are updated

 

(orderQuantity : integer)

 

is

do

     StockLevel[2,stockNum] := StockLevel[2,stockNum] - orderQuantity;

     StockLevel[3,stockNum] := StockLevel[3,stockNum] - orderQuantity;

end;

 

 

Re: Inspection of multiple columns in table

Thanks a lot Robert!