cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping - Target Node as many times as per Source node value

vinotha_m
Participant
0 Kudos

Hi everyone,

We have a requirement where suppose if the quantity in the source structure is 2, then a node or line in the target structure has to repeat 2 times.

It it is 3 the target node shoud repeat 3 times.

so

Qty = 3.

056056

056056

056056

Please let me know if you know any suitable solution for this one.

Vinotha M

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

use an advanced UDF.

input to the UDF will be the source field that will have the value

say a is the input to the UDF then the code will be something like;

int length = Integer.parseInt(a);

for(i=0; i<length;i++)
{
result.addValue("");
}

that will do the trick

vinotha_m
Participant
0 Kudos

Will it create multiple target nodes? means multiple records in the file downloaded as much as the source node value.

former_member181962
Active Contributor
0 Kudos

Small modification to Shabz's code:

int length = Integer.parseInt(a[0]);
 
for(i=0; i<length;i++)
{
result.addValue("");
}

Regards,

Ravi Kanth Talagana

vinotha_m
Participant
0 Kudos

Is there anything taht has to be done on the configuration Side as well..

Because without this UDF everything seems to be working fine.

When we put this UDF to create mutiple target nodes, we get thsi error in Communciation channel.

Could not process due to error: java.lang.Exception: Exception in XML Parser (format problem?):'java.lang.Exception: Message processing failed in XML parser: 'java.lang.Exception: Column value '0000000000' too long (>2 for 5. column) - must stop', probably configuration error in file adapter (XML parser error)'

Without the UDF in mapping it there is no issue.

Vinotha M

Shabarish_Nair
Active Contributor
0 Kudos

it has nothing to with the error in CC.

Check the CC parameters ...

post the target XML structure and the FCC you have given here so that easy for us to troubleshoot.

vinotha_m
Participant
0 Kudos

The FCC and the Data structure is very huge to be pasted here.

But I htink i spotted the problem, It is that the value that has to be repeated has to be used in the UseOneAsMany functionality..

But it does not hvr any context since it is based on just one of the source fields.

Please help me with this

Thanks,

Vinotha M

Answers (0)