cancel
Showing results for 
Search instead for 
Did you mean: 

Content analysis on graphical mapping

Former Member
0 Kudos

Hi there.

A segment of the source file im working with looks like this:

- <E1KNVKM SEGMENT="1">

<PARNR>0001376509</PARNR>

<PAFKT>TR</PAFKT>

</E1KNVKM>

- <E1KNVKM SEGMENT="1">

<PARNR>0001376510</PARNR>

<PAFKT>TR</PAFKT>

</E1KNVKM>

- <E1KNVKM SEGMENT="1">

<PARNR>0001019107</PARNR>

<PAFKT>TS</PAFKT>

</E1KNVKM>

on the structure i just see the E1KNVKM node as 0..9999 ocurrences, i need to move the PARNR code just once! when the PAFKT field is equal to TS, in most cases the segment with the TS is not the first one, is there any way i could loop through and ask if the PAFKT is equal to TS and the move the PARNR field in graphical mapping??.

Thanks for the quick response on this matter.

Regards,

Roberto.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Use below mapping.

1. use if then else

if PAFKT = TS then pass PARNR else pass constant with space.

2. Pass output of if then else to remove context > sort (descending order)> collapse context --> target field.

I tried with below data and it is working fine for me.

Source xml:


<?xml version="1.0" encoding="UTF-8"?>
<ns0:SDN xmlns:ns0="http://PurchaseRequest_Info">
   <IDOCSegment>
      <E1KNVKM>
         <PARNR>Fail</PARNR>
         <PAFKT>AB</PAFKT>
      </E1KNVKM>
      <E1KNVKM>
         <PARNR>Pass</PARNR>
         <PAFKT>TS</PAFKT>
      </E1KNVKM>
      <E1KNVKM>
         <PARNR>Fail</PARNR>
         <PAFKT>DF</PAFKT>
      </E1KNVKM>
   </IDOCSegment>
</ns0:SDN>

Output:


<?xml version="1.0" encoding="UTF-8"?> <ns0:SDN_Target xmlns:ns0="http://PurchaseRequest_Info">
 <IDOC>
        <PARNR>Pass</PARNR>
 </IDOC>
</ns0:SDN_Target>

Former Member
0 Kudos

Hi,

Use graphical mapping:

PAFKT(sets context to its parent node)

-


equals-----IfWitoutElse( PARNR(sets context to its parent node)->then) -


Target

Constant( KT)

Thanks

Amit

Former Member
0 Kudos

A simple udf would do the trick,

if you have 2 queues for PARNR and PAFKT , and a resultlist,

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

{if (PAFKT<i> = "TS' )

result.addvalue(PARNR<i>);

exit;

}

Alternatively you can do this in graphical mapping too.

Former Member
0 Kudos

Use "if without else" for graphical mapping

Former Member
0 Kudos

Hi there.

I tried with "if without else" and it does not work... :S.

To the first answer: can you elaborate a little more on this udf thing? never done it before.

Regards.

Roberto.

Former Member
0 Kudos

Firstly, If without else should work provided you handle the context.

Create an user defined function with 2 input queues (PARNR and PAFKP) and a resultlist.

paste the code.

use this udf in the mapping , with the same fields as inputs to the udf and map the output of the udf to your target field.

it will work like a breeze.

Former Member
0 Kudos

Hi there amith.

what do you mean with "provided i handed the context"...

Thanks.

Roberto.

Former Member
0 Kudos

This should give you an idea

http://www.riyaz.net/blog/xipi-introduction-to-context-handling-in-message-mapping/technology/sap/5/

Also read through this

/people/sravya.talanki2/blog/2005/08/16/message-mapping-simplified--part-i

Edited by: AMITH GOPALAKRISHNAN on Mar 22, 2011 5:25 PM