question

Anggoro P avatar image
0 Likes"
Anggoro P asked Anggoro P commented

Calculating inventory on hand

Hi, in order to calculate daily inventory on hand, I use a schedule source activity and a custom code. The schedule source used for making sure that there is a token per day to request the calculation via the custom code.

However, after running the simulation until 100 time unit (days), there were around 116 data, meanwhile I was expecting only 100 data (because the simulation run for only 100 days)

Attached is my code. Any idea what is wrong with the code?

Thanks

  1. Object current = param(1);
  2. treenode activity = param(2);
  3. Token token = param(3);
  4. treenode processFlow = ownerobject(activity);
  5. { //************* PickOption Start *************\\
  6. /***popup:AddRowToGlobalTableNew:config=ProcessFlow*/
  7. /**Add Row and Data to GlobalTable*/
  8. /** \nAs each flowitem enters, add a new row to a GlobalTable and write data to that row.*/
  9. Variant tableID = /** \nTable: *//***tag:table*//**/"DailyInvLevel"/**/;
  10. int columns = /** \nNumber of Columns: *//***tag:col_ct*//**/1/**/;
  11.  
  12. Table table;
  13. switch (tableID.type) {
  14. case VAR_TYPE_NODE: table = tableID; break;
  15. case VAR_TYPE_STRING: table = Table(tableID.as(string)); break;
  16. default:
  17. table = reftable(tableID.as(int));
  18. break;
  19. }
  20.  
  21. double rows = table.numRows + 1;
  22.  
  23. table.setSize(rows, maxof(columns, table.numCols));
  24. table.setColHeader(1,"OnHand");
  25. /** \nCommands to set the data in the new row:*/
  26. int i = 1;
  27. /***tagex:data_values*//** \n */table[rows][i] = /** */getstat(getactivity(current, "List: DC"), "Content", STAT_CURRENT, current);/**//**/; i++;
  28. /***/
  29. } //******* PickOption End *******\\
Choose One
inventory
· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Raja Sekaran avatar image
0 Likes"
Raja Sekaran answered Anggoro P commented

Hi @Anggoro P

Based on your arrival time, the first token will be created at the time of 0 and the next token will be created at the time of 1 and the last token will be created at the time 6 then the schedule will repeat itself and one more token created at the time of 6. Because of creating token at the time of 0, you will get two tokens at the time of 6. To avoid this, I have added one more arrival at time 7 with the quantity set to 0. This will cause no tokens to be created at the time.

Thanks.

inventoryonhand-support.fsm


· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.