cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping - unbounded to different targets

oscar_mller
Explorer
0 Kudos

People,

I have this scenario :

Note that, in source, I have an unbounded structure.

At the target, I have two 1..1 structures.

If the id field in the source structure, is with the value "1", I must map to the structure "emit". If the value is "2", I map to the "dest" structure.

I tried several ways, but the target structures are 1..1 and therefore it only maps the first occurrence of origin.

Is how to do this?

Thank you

Accepted Solutions (1)

Accepted Solutions (1)

oscar_mller
Explorer
0 Kudos

People,

See the result of the mapping. The structure "dest" is not being created.

Thank´s

Former Member
0 Kudos

you need to map both emit and dest field in the target instead of mapping infe root node.

id equals +constant 1 > createif> emit

id equals +constant 1 > createif> dest

oscar_mller
Explorer
0 Kudos

People,

I got through the following udfs:

for(int i=0;i<id.length;i++){

   if(id[i].equals("1")){

           emitnode_out.addValue("");

           nitem_out.addValue(nitem_in[i]);

           nome_out.addValue(nome_in[i]);

          

           nitem_out.addValue(ResultList.CC);

           nome_out.addValue(ResultList.CC);

          

           emitnode_out.addValue(ResultList.CC);

    }

}

for(int i=0;i<id.length;i++){

   if(id[i].equals("2")){

           destnode_out.addValue("");

           nitem_out.addValue(nitem_in[i]);

           nome_out.addValue(nome_in[i]);

          

           nitem_out.addValue(ResultList.CC);

           nome_out.addValue(ResultList.CC);

           destnode_out.addValue(ResultList.CC);

    }

}

Thank´s

Former Member
0 Kudos

Hi Oscar,

Udf is not required for this requirment. We can achieve this using standard functions.

Please see the below screenshots.

Regards,

Raju.

oscar_mller
Explorer
0 Kudos

Raju,

I had done it and had not worked because I had not changed the id field context. Now I did it, it worked perfectly. It is better than use the UDF.

Thank´s,

Answers (0)