1. Junior Member
Join Date
Dec 2016
Posts
1

## Dynamic fill

Hi guys

Having this input table.

 item month quantiy 54000001 1 100 54000005 1 175 54000009 1 195 54000013 1 215 54000002 2 300 54000006 2 180 54000010 2 200 54000014 2 220 54000003 3 50 54000007 3 185 54000011 3 205 54000015 3 225 54000004 4 200 54000008 4 190 54000012 4 210

I want to assign the correct Facility depending of his capacity to produce.

knowing that:
Facility 1 has priority to produce over Facility 2, and Facility 2 over Facility 3

Facility 1 can produce 300 in a month
Facility 2 can produce 1000 in a month
Facility 3 can produce infinite

The pseudo-code should be something like:

If (Select sum(quantity) where facility=’facility 1’) < 300 then ’facility 1’
Else If (Select sum(quantity) where facility=’facility 2’) < 1000 then ’facility 2’
Else ’facility 2’

The execution of this should works on this way(thinking that is perfectly defined)

Start process…

 item month quantiy facility 54000001 1 100 ?

Result 1: sum(quantity)=0 where facility=’facility 1’
 item month quantiy facility 54000001 1 100 facility 1

 item month quantiy facility 54000001 1 100 facility 1 54000005 1 175 ?

Result 2: sum(quantity)=100 where facility=’facility 1’
 item month quantiy facility 54000001 1 100 facility 1 54000005 1 175 facility 1

 item month quantiy facility 54000001 1 100 facility 1 54000005 1 175 facility 1 54000009 1 195 ?

Result 3: sum(quantity)=275 where facility=’facility 1’
 item month quantiy facility 54000001 1 100 facility 1 54000005 1 175 facility 1 54000009 1 195 facility 1
 item month quantiy facility 54000001 1 100 facility 1 54000005 1 175 facility 1 54000009 1 195 facility 1 54000013 1 215 ?
Read 4: sum(quantity)=370 where facility=’facility 1’
Then… sum(quantity)=0 where facility=’facility 2’
 item month quantiy facility 54000001 1 100 facility 1 54000005 1 175 facility 1 54000009 1 195 facility 1 54000013 1 215 facility 2
.
.
.
.
.

Finally my result table is:

 item month quantiy facility 54000001 1 100 facility 1 54000005 1 175 facility 1 54000009 1 195 facility 1 54000013 1 215 facility 2 54000002 2 300 facility 1 54000006 2 180 facility 2 54000010 2 1000 facility 2 54000014 2 220 facility 3 54000003 3 50 facility 1 54000007 3 185 facility 1 54000011 3 205 facility 1 54000015 3 225 facility 2 54000004 4 200 facility 1 54000008 4 190 facility 1 54000012 4 210 facility 2

I hope you understand

How can I solve this in kettle?????

Carlos.

2. Senior Member
Join Date
Jun 2012
Posts
5,534
I you calculate the cumulative sum per month you can use step Number-Range to assign facilities.
This kind of production planning isn't very realistic, though.

Also, your numbers and pseudo code could be more consistent ...