Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

XI IDoc complex mapping problem - help needed!

Hi all,

I am mapping WPUBON IDoc (sent as IDoc XML file) to WPUBON IDoc in R/3. However, I have a complex mapping requirement that I am trying to use the graphical tool for.

Source segment structure is such that we have:

E1WPB01 (header) has one or many E1WPB02 (items) and E1WPB05 (coupons).

E1WPB02 (items) have one or many E1WPB03 (item conditions).

So for each IDoc, we can have many items (E1WPB02), each item can have many conditions (E1WPB03) and each IDoc can have many coupons (E1WPB05).

For each E1WPB05 received, we need to take the value and divide it proportionately in order to add an extra E1WPB03 discount condition segment to each E1WPB02 item (we are a retailer and this will allow us to break down customer coupon discounts across each item in the basket). For example, if we have 2 E1WPB02 items with values $2 and $3 and the coupon is worth $1, item 1 needs a new E1WPB03 segment with a value of $0.40 and item 2 needs one with a value of $0.60.

This process needs to occur for each E1WPB05 segment (customers could have more than one coupon). No E1WPB05 segments are required in the target IDoc.

I have tried a few things but really am a bit stuck on where to start.... any ideas anyone?

Thankyou.

Stuart Richards

Former Member
Former Member replied

Hi Stuart,

for your problem you would need to change the mapping for node E1WPB03. In your case I suggest to add another user defined function copyContent (using Context as Cache and with 2 input parameters a and b):

 for (int i = 0; i < b.length; i++){
    for (int j = 0; j < a.length; j++) result.addValue(b[i ]);
    result.addContextChange();
 }

Just remove the blank in b[i ] (I cannot print this since the system thinks I want to start writing in italics).

Then change the mapping for node E1WPB03 as follows (the mapping becomes quite large, therefore I need to break it into separate pieces).

a) The end portion of the mapping looks as follows:

                                           E1WPB03 -->
              E1WPB05 -->                              addContent --> E1WPB03
                          copyContent --> createIf -->
and --> removeContext --> 

b) The first input for the function <b>and</b> looks as follows (checking for the negative sign in E1WPB02):

 VORZEICHEN -->
                equalS --> 
Constant[-] -->

c) The second input for the function <b>and</b> looks as follows (checking for the existence of a segment E1WPB03 with KONDITION = PN10):

     KONDITION -->
                   equalS         -->
Constant[PN10] -->                    ifWithoutElse -->
                   Constant[true] -->

Regards,

Claus

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question