cancel
Showing results for 
Search instead for 
Did you mean: 

mapping - repeat segment

Former Member
0 Kudos

IDOC

+segment1 (0....unbound)

++field1

++field2

+node2 (0...unbound)

++keyfield1

++keyfield2

segment 1 can appear more than one time.

Based on the node2, the target structure gets repeated. For every repeatetion the segment1 occurrences should repeat. Both Segment1, node2 are at the same level under one single segment in IDOC.

Eg: If segment1 repeats 4 times, and node2 repeats, each repetitions of node2 should have 4 repetitions of the segments1 occurrences in node 2 repetition.

Tried with multiple options. help

Venkat.

Accepted Solutions (1)

Accepted Solutions (1)

former_member181962
Active Contributor
0 Kudos

Yes, I agree with VJ.

in the UDF you have to do something like

for(int i =0; i>first.length();i++)

for(int j= 0;j<second.length();j++)

result.addValue("");

Former Member
0 Kudos

Dear VJ, Ravi Kanth,

Thanks for your replies. I wrote the UDF and resulted in following error mesg when I mapped it to the target node.

for(int i =0; i>node2.length();i++)

for(int j= 0;j<segment1.length();j++)

result.addValue("");

     /usr/sap/X5D/DVEBMGS13/j2ee/cluster/server0/./temp/classpath_resolver/Map21bff7f3cd3711e1bf3a00000806f16e/source/com/sap/xi/tf/_.java:1005: cannot resolve symbol
symbol : method length ()
location: class java.lang.String[]
for(int i =0; i>node2.length();i++)
^
/usr/sap/X5D/DVEBMGS13/j2ee/cluster/server0/./temp/classpath_resolver/Map21bff7f3cd3711e1bf3a00000806f16e/source/com/sap/xi/tf/_.java:1006: cannot resolve symbol
symbol : method length ()
location: class java.lang.String[]
for(int j= 0;j<segment1.length();j++)

Former Member
0 Kudos

Hi.

Please correct the UDF. Remove () for method length.

for(int i =0; i>node2.length;i++)

for(int j= 0;j<segment1.length;j++)

result.addValue("");

Regards

Lucho.

Former Member
0 Kudos

Hi Lucho.

Thanks for your reply. You suggestion did helped to execute the UDF succesfully but it did not fix the issue. The following is the Display queue values.

int cnt =0;

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

for(int j=0;j<b.length;j++)

{

cnt++;

result.addValue("");

if(cnt>=i)

{

cnt=0;

result.addValue(ResultList.CC);

}

}

No errors but the way data is populated, there seems to be some issue!

example : There are 3 occurrences of a node and 3 occurrences of node b. The above function returns each value with a context chance and hence there are some fields which are not being populated in the target.

The problem currently is when there are 2 repetitions of a segment, hence there is a need to insert context change for every 2 objects.

Similarly, if there are 3 repetitions of one segment and 2 repetetions of second, there should be context created accordingly

I also tried to shuffle. Nothing works perfectly.

This is tried with target node.

help

Former Member
0 Kudos

Hi.

Did you select UDF by context or by Queue?

Regards

Lucho.

Former Member
0 Kudos

I did

infact I changed it to...

int cnt =b.length;

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

for(int j=0;j<b.length;j++)

{

cnt--;

result.addValue(b[j]);

if(cnt==0)

{

cnt=b.length;

result.addValue(ResultList.CC);

}

}

It works now. Thanks a lot guys

Answers (1)

Answers (1)

VijayKonam
Active Contributor
0 Kudos

A simple UDF at the context level should do the work here. Pass both Node2 and segment 1 to it. For each node2, add the length for segment one number of elements on the target. 

VJ