I have a transformation i am trying to acheive but can't figure out the logic to do it, can somebody please help me
CLASS is an input, and from it i am removing the last three digs using this code that works well.
" if (right ($in.0. CLASS ,3) == "101") ($out. 0. IDT_ TYPE = "001"; } else ($out. 0.IDT_TYPE= right ($in. 0.CLASS , 3);}"
in the same transformation, i want to use the 3 digits derived to
"if IDT-Type == '001' then VALUE = 1 AND add 2 more records where all fields except {IDT-TYPE, VALUE} remained unchanged:
If AMOUNT_TO == ""
Create another record and set IDT-TYPE as {"022", "+" & REPT ("0", 9 - LEN(FACTOR)) & FACTOR} and VALUE as {"023", "+999999999000"}
Else
Create another record and set IDT-TYPE as {"022", "+" & REPT ("0", 9 - LEN(FACTOR)) & FACTOR} and VALUE as{"023", "+" & REPT ("0", 9 - LEN(FACTOR)) & FACTOR & "000"} "
IDT-Type,VALUE,AMOUNT_TO and FACTOR are OUTPUT columns
CLASS is an input column
The most challenging thing for me is how to create a new record (row)
-
Hi Mahmood.
If, basically, you need to create 1 or more records out of 1 input, then the component which can help with this is Normalizer.
It requires two CTL functions to be defined:
- count() - supposed to return a number which denotes how many (X) times will the second function be called for the current input record
- transform(integer idx) - function called X times for each input record (idx starts with 0, then up to X-1)
Example:
function integer count(){
if ($in.0.IDT-TYPE == '001') {
return 2; // transform called 2x
}else{
return 1; // transform called 1x
}
}
function integer transform(integer idx){
switch(idx){
case 1:
$out.0.value="A";
break;
case 2:
$out.0.value="B";
break;
default:
$out.0.value="AB";
}
return OK;
}Your logic in count() can be quite complex. If you need to, aside calculating how many output records should be created, some other logic, then you can use global variable which you populate in the count() function or just calculate it inside tranform(integer idx) function.
Please sign in to leave a comment.
Comments 1