on 03-22-2011 2:36 PM
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.
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.