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

Object current = param(1);
treenode activity = param(2);
Token token = param(3);
treenode processFlow = ownerobject(activity);
{ //************* PickOption Start *************\\
/***popup:AddRowToGlobalTableNew:config=ProcessFlow*/
/**Add Row and Data to GlobalTable*/
/** \nAs each flowitem enters, add a new row to a GlobalTable and write data to that row.*/
Variant tableID = /** \nTable: *//***tag:table*//**/"DailyInvLevel"/**/;
int columns = /** \nNumber of Columns: *//***tag:col_ct*//**/1/**/;

Table table;
switch (tableID.type) {
    case VAR_TYPE_NODE: table = tableID; break;
    case VAR_TYPE_STRING: table = Table(tableID.as(string)); break;
    default:
        table = reftable(tableID.as(int));
    break;
}

double rows = table.numRows + 1;

table.setSize(rows, maxof(columns, table.numCols));
table.setColHeader(1,"OnHand");
/** \nCommands to set the data in the new row:*/
int i = 1;
/***tagex:data_values*//** \n */table[rows][i] = /** */getstat(getactivity(current, "List: DC"), "Content", STAT_CURRENT, current);/**//**/; i++;
/***/
} //******* 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.

Jeff Nordgren avatar image Jeff Nordgren commented ·

@Anggoro P,

Rather than just the code to look at, is it possible to send your model or a sample model so that we can see the code in context?

Thanks.

0 Likes 0 ·
Anggoro P avatar image Anggoro P Jeff Nordgren commented ·
0 Likes 0 ·
Jeff Nordgren avatar image Jeff Nordgren Anggoro P commented ·
@Anggoro P

Thanks for sending the model. I'm still not clear what your goal here is. Can you explain to me in more detail what exactly is supposed to happen?

Thanks.

0 Likes 0 ·
Show more comments

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.

Anggoro P avatar image Anggoro P commented ·

@Raja Sekaran

Thanks a lot! :)

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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