on 05-27-2015 3:33 PM
Hello
Having PI message mapping not as a daily task, it is often quite cumbersome for me to find a working solution in this context mapping environment as it is with the following apparently simple request.
Requirement: Map the partner number for role "WE" (element PARVW) to mandatory ShipToNumber field.
Input:
<INVOIC02>
<E1EDKA1>
<PARVW>RS</PARVW>
<NAME1>abcd</NAME1>
</E1EDKA1>
<E1EDKA1>
<PARVW>RE</PARVW>
<PARTN>123</PARTN>
<NAME1>Bill to</NAME1>
</E1EDKA1>
<E1EDKA1>
<PARVW>WE</PARVW>
<PARTN>456</PARTN>
<NAME1>Ship to</NAME1>
</E1EDKA1>
<E1EDKA1>
<PARVW>ZE</PARVW>
<PARTN>789</PARTN>
<NAME1>xyz</NAME1>
</E1EDKA1>
Mapping:
PARVW [context change INVOIC02] -> equalsS Constant = "WE"
(ifWithoutElse)
then PARTN [context change INVOIC02] -> mapWithDefault -> ShipToNumber
Problem: ShipToNumber now contains the value 789 instead of 456 because to first E1EDKA1 segment is missing the PARTN element, i.e. the context is missing an entry.
I've tried various combinations of node functions and context changes, but some way or another it results in a solution not working properly either mapping the wrong value, not creating the target element at all when the node with WE doesn't exist, or giving the cannot create target element error.
Do I need to create an UDF for this which appears to me to be a common issue as IDocs are often missing elements in segments.
Thanks in advance for any feedback or solution.
Regards,
Daniel
Hi Daniel,
Don't change the context of source field and after if without else (before output field) add remove context and split by value.
regards,
Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Harish
Thanks for your answer. I've tried this and playing around with what happens if value, element, or node for "WE" are not provided. What I've came up is this:
PARVW [context E1EDKA1] -> equalsS Constant = "WE"
(ifWithoutElse)
then PARTN [context E1EDKA1] -> mapWithDefault -> (ifWithoutElse) -> removeContext -> SplitByValue -> mapWithDefault -> ShipToNumber
Nevertheless, what I forgot to mention is that I can have multiple occurrences of INVOIC02 in the source file (it is actually a custom INVOIC02 and not the SAP standard). If that happens and the "WE" node from the first INVOIC02 is missing then it would just apply the value from the next occurring "WE" node from the following invoice which would be incorrect.
Any suggestions on how to handle this?
Regards,
Daniel
Hi Daniel
You can resolve this with an additional formatByExample after the mapWithDefault as shown below. For PARVW, change the context to be the same as parent of E1EDKA1. In my case below I'm using standard IDoc INVOIC02, so the parent is IDOC, change it accordingly based on your custom structure.
Based on the test data below, you can see the output is aligned properly even though there is missing PARTN in the RS segment.
Rgds
Eng Swee
Hi Daniel,
In the below mapping, can't you just use remove context for both PARVW & PARTN before giving as input and proceed with the same mapping.
Can you test with this and let us know if issue has resolved or not.
Regards
Vishnu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
26 | |
9 | |
9 | |
7 | |
6 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.