cancel
Showing results for 
Search instead for 
Did you mean: 

Message mapping with missing source elements

0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Harish
Active Contributor
0 Kudos

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

0 Kudos

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

engswee
Active Contributor
0 Kudos

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

0 Kudos

Thank you Eng Swee, this works for all of the cases I've tested.

Answers (1)

Answers (1)

pvishnuvardan_reddy
Active Contributor
0 Kudos

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

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Daniel,

Reward points if solution has found useful.

Regards

Vishnu