question

Fernanda Becker avatar image
0 Likes"
Fernanda Becker asked Fernanda Becker commented

How to set and use a daily global table?

Hi everybody,

I'm modelling a retail supply chain, which background I explained some of the background in this previous question.

I would like some help with the following problem: In the initial settings, I set the time unit in days. More than that, while running the model, I need the definition/count of "1 day", in order to take some decisions when the day is over. I have a table called "Pedidos" and its 6th column represents the total amount of sales I have of each SKU. But I need to have the sales per day (of each SKU), what means that this quantity needs to be reset at the end of the day. Moreover, before being reset, this table needs to be able to fill the second column of the table called "Chamada" with the quantity that was sold in that day. This table "Chamada" is used to set the Source of new products and, in this way, in the day "D" there must be created only the products that were sold in the day "D-1".

How can I do that?

If it wasn't clear, just let me know and I can explain.

Thank you very much! Best regards,

Choose One
global tablesupply chaindailysales
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
1 Like"
Jeff Nordgren answered Fernanda Becker commented

@Fernanda Becker

Fernanda,

I'm not sure I totally understand what needs to happen at the end of each day in your model but I think the answer would be to use a User Event. In the Toolbox under Modeling Logic>User Event.

By putting a 1 in the First Event Time area (end of 1 day) you can go into the code area and do any and all things you need to "finish" that day. Then by checking the Repeat event check box, your code will run at the end of each day (1 time unit).

Would this work for you? Or is there something that I'm not understanding correctly?


userevent.png (18.0 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.

Fernanda Becker avatar image Fernanda Becker commented ·

@Jeff Nordgren, I didn't know this "User Event" possibility before. I'm so so grateful! Thank you very much! It's working perfectly!

Best regards,

1 Like 1 ·
Sam Stubbs avatar image
1 Like"
Sam Stubbs answered Fernanda Becker commented

So somewhere in the logic of your model, at the end of a day. (You could use a scheduled source in Process Flow, if you don't already have something to keep track of the end of the day.) You'll want to write a custom code that parses through all of the column in your Pedidas and Chamada tables, updating those values. Something like a for loop could work here:

for (int i=1; i<=gettablerows("Pedidos"); i++)  {
	int vendas_num = gettablenum("Pedidos",i,6);
	settablenum("Chamada",i,2,vendas_num);
	settablenum("Pedidos",i,6,0);
}

This loop goes through each row in your tables (using a variable 'i' as the index), assigns the value at row "i" column 2 in your Chamada table to the value located in row "i" column 6 of your "Pedidos" table, and then clears the value on the Pedidos table. Am I correct that this is along the lines you were looking for?

· 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.

Fernanda Becker avatar image Fernanda Becker commented ·

Thank you very much, @Sam Stubbs!! I implemented this logic in the User Event that @Jeff Nordgren suggested and it helped a lot!! Thank you one more time!

1 Like 1 ·

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.