Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi team,
I want to distribute the attribute "number" by 1 on the attributes "Supp" which have the biggest "rest" and which are grouped by code,
I use:
tOracleInput-> tSortRow-> Tjavaflex-> tLogRow
I use tSortRow to sort the "rest" attributes,
tJavaFlex:
for (int i = 0; i <= row7.code; i ++)
{for (j = 0; j <= row7.number; j--)
{row10.Supp = row7.Supp + 1;}
input
code|number|rest|supp
1 |2 |150 |4
1 |2 |125 |1
1 |2 |110 |1
2 |3 |145 |0
2 |3 |130 |3
2 |3 |50 |1
2 |3 |10 |4
Iwant an output like this:
code|number|rest|supp
1 |2 |150 |5
1 |2 |125 |2
1 |2 |110 |1
2 |3 |145 |1
2 |3 |130 |4
2 |3 |50 |2
2 |3 |10 |4
Could anyone please give me a hint of how to do this?
Your help is very much appreciated.
thanks,
nadakh
Find attached the job
Here is the tJavaRow
String code = input_row.code; int num = input_row.number; output_row.code = input_row.code; output_row.number = input_row.number; output_row.rest = input_row.rest; output_row.supp = input_row.supp; if( code.contains(context.current_code) ){ context.to_distribute -= 1 ; output_row.supp += ( 0 > context.to_distribute ? 0 : 1 ); } else { context.current_code = input_row.code; context.to_distribute = input_row.number - 1; output_row.supp += ( 0 > context.to_distribute ? 0 : 1 ); }
hope this will help
l have this error when I set the context.to_distribute
Thank you, It works well .
I have another problem.
for the same procedure , I have the calculation expression : "rest"= A/(B+1)
but each time I recalculate the rest that got a number as follows: "rest"= (A/(B+1 +1)) (adding 1 )
and I start again until the "number" is distributed all.
reste=Voix/(supp+1)
for exemple, for code1: "number" to distribute =2
1) for "rest" = 584 / (2+1)=194.66
for "rest" = 840 / (3+1) =210
for "rest" = 863 / (3+1) =215.75 we assign a "Number"=1 -> Supp = Supp+1 ( because 215,75 is the max)
2) for "rest" = 584 / (2+1)=194.66
for "rest" = 840 / (3+1) =210 we assign a "Number"=1 -> Supp = Supp+1 ( because 210 is the max)
for "rest" = 863 / (3+1+1) =172.6
result:
code|Supp
1 | 2
1 | 4 (3+1)
1 | 4 (3+1)
and we repete for each group of code the same procedure precedent
I try this code in tjavaRow but it doesn't works:
//Code généré selon les schémas d'entrée et de sortie
output_row.code = input_row.code;
output_row.number = input_row.number;
output_row.VOIX = input_row.VOIX;
output_row.supp = input_row.supp;
output_row.rest = input_row.rest;
String code = input_row.code;
int num = input_row.number;
double reste =Double.valueOf(input_row.VOIX/(input_row.supp+1+1));
if( code.contains(context.current_code) ) and (context.reste<input_row.rest) {
context.to_distribute -= 1 ;
output_row.supp += ( 0 > context.to_distribute ? 0 : 1 );
} else {
context.current_code = input_row.code;
context.to_distribute = input_row.number - 1;
context.reste= Double.valueOf(input_row.VOIX/(input_row.supp+1+1));
output_row.supp += ( 0 > context.to_distribute ? 0 : 1 );
}
please I need your help to resolve this