cancel
Showing results for 
Search instead for 
Did you mean: 

Looping in message mapping

Former Member
0 Kudos

Hello XI Gurus,

I need your help in doing following mapping.

The source ORDERS02 Idoc contains is fields like

E1EDP01(segment) under this

E1EDP19(segment)-QUALF(field) = Z18

E1EDP19(segment)-QUALF(field) = Z39

E1EDP19(segment)-QUALF(field) = Z39

E1EDP19(segment)-QUALF(field) = Z39

E1EDP19(segment)-QUALF(field) = Z39

and the Target structure is like this

E1NTITM(segment) under this-

BAUTL(field)

we need to populate the E1NTITM segment in target system only when

E1EDP19-QUALF = Z39 , so here i got the idea how to get the E1NTITM segement. But BAUTL field will be populate in each E1NTITM segment only when E1EDP19-QUALF = Z18. It means, in the source structure contains one

E1EDP19-QUALF = Z18 and n number of E1EDP19-QUALF = Z39 fields. So E1NTITM segment will appear in the target n number of times and BAUTL field will be appear in each and every E1NTITM segment. if the source doesn't have

E1EDP19-QUALF = Z18 field then BAUTL field could't be there in target E1NTITM segment. For this i just have an idea like, we need to loop the E1EDP01 segment to check if there is any E1EDP19-QUALF = Z18 field is there but i don't no how to do the looping. Please help me how to solve this problem.

Accepted Solutions (1)

Accepted Solutions (1)

nisarkhan_n
Active Contributor
0 Kudos

inorder to loop at the E1EDP01 segment, right click on the field E1EDP19 change the context to E1EDP01, this will loop from E1EDP01...

Former Member
0 Kudos

Hi Nisar,

Thx for you are reply. But here E1EDP19 has already the context E1EDP01 only. So no need to change the context for E1EDP19, even in the mapping there is no need to use E1EDP19 we need to use only QUALF (to check its value is Z18) . I changed the QUALF field context to E1EDP01 but i am getting BAUTL field only at first time (means E1NTITM fields are there n times in target but only first E1NTITM segment has the BAUTL field). Please help me how to solve my mapping

justin_santhanam
Active Contributor
0 Kudos

Rao,

Your source is fine, can u give how the output looks like for the sample data u've given above.

raj.

Former Member
0 Kudos

Hi Raj,

My souce is look like this

E1EDP01(segment) under this

E1EDP19(segment)-QUALF(field) = Z18

E1EDP19(segment)-QUALF(field) = Z39

E1EDP19(segment)-QUALF(field) = Z39

E1EDP19(segment)-QUALF(field) = Z39

E1EDP19(segment)-QUALF(field) = Z39

E1EDP19(segment)-QUALF(field) = Z11

and the Target structure is like this

E1NTITM(segment) under this- This segement will appear for all QUALF = Z39

XXXX (some other field)

BAUTL(field) -- This field will be appear for all E1NTITM segments when QUALF= Z18

Finally my target structure is like

E1NTITM

XXXXX

BAUTL

E1NTITM

XXXXX

BAUTL

E1NTITM

XXXXX

BAUTL

E1NTITM

XXXXX

BAUTL

Here 4 E1NTITM segements are there bcz in my source i have 4 QUALF = Z39 are there and each and every E1NTITM segment have BAUTL bcz in my source i have one QUALF = Z18.

For ex: if my source is like

E1EDP01(segment) under this

E1EDP19(segment)-QUALF(field) = Z39

E1EDP19(segment)-QUALF(field) = Z39

E1EDP19(segment)-QUALF(field) = Z39

E1EDP19(segment)-QUALF(field) = Z39

E1EDP19(segment)-QUALF(field) = Z11

Then my target is like

E1NTITM

XXXXX

E1NTITM

XXXXX

E1NTITM

XXXXX

E1NTITM

XXXXX

Here 4 E1NTITM segements are there bcz in my source i have 4 QUALF = Z39 are there and there is no BAUTL bcz in my source there is no QUALF = Z18.

In source there will be only one QUALF = Z18 or there is no QUALF = Z18. if QUALF = Z18 is there then each and every E1NTITM segment will have BUATL field.

justin_santhanam
Active Contributor
0 Kudos

Rao,

Based on your structure I created the logic, please find them below in the URL. If you think it's not correct, then reply back.

<b>Mapping</b>

http://www.flickr.com/photo_zoom.gne?id=1954590723&size=o

http://www.flickr.com/photo_zoom.gne?id=1954590729&size=o

<b>UDF</b>

http://www.flickr.com/photo_zoom.gne?id=1954590957&size=o

Just see the logic[ The UDF window belongs to SP14, so don't care] I believe u know how to create advanced UDF.

I used two UDF, find the code below.

<b>UDF - Generate</b>


int z39cnt =0;
int z18cnt =0;
for(int i=0;i<a.length;i++)
{
if(a<i>.equals("Z18"))
z18cnt+=1;
else if(a<i>.equals("Z39"))
z39cnt+=1;
}

if(z18cnt == 0)
{
result.addSuppress();
}
else
{
for( int j=0;j<z39cnt;j++)
{
result.addValue("BAUTL");
result.addContextChange();
}
}

<b>UDF - Generateroot</b>


int z39cnt=0;

for(int i=0;i<a.length;i++)
{
if(a<i>.equals("Z39"))
result.addValue("");
}

<b>Results</b>

http://www.flickr.com/photo_zoom.gne?id=1954590735&size=o

http://www.flickr.com/photo_zoom.gne?id=1954590737&size=o

If you find any difficulties in achieving the same then let me know.

raj.

Former Member
0 Kudos

Hi Raj,

Thanks a lot. My problem is solved with your solution. I just used your solution with some minor modification according to my requirments. So finally my problem is solved.

justin_santhanam
Active Contributor
0 Kudos

No Problem, as far as solution is achieved .:-)

raj.

Answers (0)