question

hermione12 avatar image
0 Likes"
hermione12 asked Jeanette F commented

Global Table Creation

Hi,

In my model, when an item exits from source1 to combiner1.In the process flow, I am creating an Entry trigger source (On source1 exit) and then deciding the Item_type label which is assigned on items from Source1 using the Decide element.

1672933624288.png

  • If entering Item_type == "Light". I am writing a custom code which checks the labels Item_type and Station in the "Process_flow" table.

It should match Item_type == "Light" and Station == "Station1"

If both the label matches, I want to extract the partnames of the items with both labels Item_type and Station. I want to extract those partnames and write them on the one more global table "Station_partrequest_light" in the same sequence as read from the Process flow.

  • If entering item is Item_type == "Heavy". Then it should match Item_type == "Heavy" and Station == "Station1" from the Process_flow table. and then I want to extract only those items which satisfy these conditions and store only the partnames into the one more global table "Station_partrequest_heavy"

I have tried writing a code in the Custom code , but it is not working properly. Can you please help.

table_creation.fsm

FlexSim 22.2.3
globaltable
1672933624288.png (11.9 KiB)
table-creation.fsm (35.1 KiB)
· 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.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @hermione12, was Jason Lightfoot's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot commented

You need to add rows to your table. If this table is to be created dynamically, the easiest way is to format it manually with dummy row(s) and then set the size to be the number of columns with zero rows on reset. Then you can just call the table's method to add a row without specifying any additional parameters.

Then you need to sort out your code regarding the row and column index to match the dimensions of your target table, and decide in which column you want to store the data.

In order to debug and understand your own code, place a breakpoint in the code and step through it, noting the values of your local variables. More information in the online section on debugging .

· 4
5 |100000

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

hermione12 avatar image hermione12 commented ·

@Jason Lightfoot

While I was adding rows to my table. I used Table.addRow(). But, it used to add so many rows each time I looped and all the initial partnames would go down the table as new one adds up.

Also in the code I have given if statement to check if the labels match from the process flow. This is not working for both the labels, when I use && it is not working.

what to do? Please check my code in the custom code and let me know what is wrong.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ hermione12 commented ·
Please provide an example of how you want your table formatted.
0 Likes 0 ·
hermione12 avatar image hermione12 Jason Lightfoot ♦ commented ·

@Jason Lightfoot

This is how my table should be formatted:

For Item_type == "Light" and Station == "Station1"

1672936406152.png

For Item_type == "Heavy" and Station == "Station1"

1672936441202.png

0 Likes 0 ·
1672936406152.png (14.5 KiB)
1672936441202.png (14.3 KiB)
Show more comments

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.