cancel
Showing results for 
Search instead for 
Did you mean: 

How to map values from "n" source segments to 14 occurrences of a single target segment or pass blank value for the rest of the segments if 14 source segment is not present

0 Kudos

Source

-ProdOrder.................1-n
---CapacityRecord..........1-n
-----OperationNo...........0-1
-----SequenceNo............0-1
-----ControlKey............0-1
:
:
etc


Target

-Prod_Order...............1-n
---Dept_Data..............14-14
-----StandardTime.........1.1
-----RTINS................1.1
-----RTINST...............1.1
:
:
etc

For each ProdOrder everytime the target is created Dept_Data needs to occure 14 times with data from each CapacityRecord.
For example, if 1 ProdOrder contains 6 Capacity records in it, then the first 6 Dept_Data needs to be populated based upon the data of those 6 CapacityRecord and the next 8 Dept_Data will have blank values in it.
Please let me know how to achieve this.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

Try this:

1) Duplicate Dept_Data

2) Map Capacity_Record with Target Dept_Data node and map rest of the elements as per ur business logic

3) For the duplicated node use below UDF

int count = Integer.parseInt(var1[0]);

if(count<14)

{

for(int i =0;i<14-count;i++)

{

result.addValue("");

}

}

else

result.addSuppress();

Mapping:

a) Capacity_Record --Count --UDF---Dept_Data

b) Eventually, map constant to all the elements inside the duplicated Dept_Data

Thanks

Amit Srivastava

\

0 Kudos

Thanks a ton Amit. It worked.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Subhra

Please do the mapping as below

Create one udf for populating the root strcuture

map the root node as below

write one more udf for populating fields

code:

int cnt = Integer.parseInt(count[0]);


for ( int i = 0; i< cnt; i++)
{
result.addValue(fieldval[i]);
}
for ( int k = 0; k<14-cnt; k++)
{
result.addValue("");
}

map the field as

Output: