question

Craig DIckson avatar image
0 Likes"
Craig DIckson asked Matt Long commented

Number of tokens found by a Pull from List activity?

I have a token representing a tote of inventory of a SKU. (This is all in process flow.) Once the tote has been picked, it pulls tokens from a list (representing order lines for that SKU). I need to know how many it successfully pulled, so I can update the original tote's inventory. It gives me the label "pulled" that is a list of pulled tokens, but not the count.

FlexSim 16.1.0
process flowlistpull from listarrayarraysize
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

David Besson avatar image
2 Likes"
David Besson answered Matt Long commented

You could use an "Assign Labels" activity to add a label with the number of entries in the label array "pulled".

Then you can use this new label to update the inventory.


capture.png (68.3 KiB)
· 8
5 |100000

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

Matthew Gillespie avatar image Matthew Gillespie ♦♦ commented ·

That pickoption is using the arraysize command() which tells you how many things are in an array. But, the nicest thing about that pickoption is that it handles both the situation where the pulled label has an array of things and when the pulled label isn't an array and points at the one thing it pulled. If you only pulled one thing then the label won't be an array and the arraysize() command will return a 0.

0 Likes 0 ·
Craig DIckson avatar image Craig DIckson Matthew Gillespie ♦♦ commented ·

Yep, I discovered that it returns 0 if it picked 1 item, which doesn't work for what I am trying to do. I do still need to know that it did pull one item, vs. none (I have Required = 0; if is nothing matching to pull, then I'll go away for a delay and then come look for a different match).

The code below is for a Decision activity, immediately following the Pull activity.

As a corollary, how can I clear the array so that next time through the Pull activity it has the new results (especially if the first time pulled more items, creating a larger array)?

/**Custom Code*/
treenode current = param(1);
treenode activity = param(2);
treenode token = param(3);
treenode processFlow = ownerobject(activity);






//How many lines did we just fulfill? Update the inventory
setlabel(token,"labelPieces",(getlabel(token,"labelPieces") - arraysize(getlabel(token,"pulled"))));




if(getlabel(token,"labelPieces") == 0) // is it empty now?
{
	return(1); // send to sink
}
else
{
	//setlabel(token,"pulled", NULL);
	return(2); // back to inventory
}
0 Likes 0 ·
Craig DIckson avatar image Craig DIckson Matthew Gillespie ♦♦ commented ·

OK, I see what you meant now. Using the option in the setLabel activity is smarter than just using arraysize(...) in code.

I added an attribute and an activity and it seems to be working now.

Thanks

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Craig DIckson commented ·

Exactly, I was just giving some background on the 2 different things it checks.

You mentioned that if nothing is pulled you go to a delay and then try pulling again. If you set the require number to 1, then the pull will create a backorder on the list if it can't pull anything and will wait until there's at least 1 thing on the list. That way you don't have to keep polling the list to see if anything's changed.

You shouldn't need to clear the array. The Pull From List just sets the label to a new value the next time through.

0 Likes 0 ·
Show more comments
Craig DIckson avatar image Craig DIckson commented ·

Matthew,

I made a change that demonstrates what isn't working for me. When the token hits the bottom, I'd like it to read 0, per the most recent pull. But it still reads 1.

Craig

1087-arraysizepickoption-2.fsm

0 Likes 0 ·
Matt Long avatar image Matt Long Craig DIckson commented ·

Looks like this is a small bug. It was supposed to ignore times when nothing was pulled when you select Insert at Front, but currently it's ignoring both the Assign to (overwrite) and the Insert at Front. We'll get this fixed for the next bug fix release.

For now, you can use an Assign Labels before you pull and choose the option Remove Label.

0 Likes 0 ·