cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping with Alternative and Missing elements

Former Member
0 Kudos

Hi All.

This is my first question on SCN so pardon if I overstep on any rules.

I'm mapping a ORDERS05 IDOC to another XML document.

On the ORDERS05 <E1EDP01 SEGMENT="1"> contains some of the material information and it CHILD node <E1EDP19 SEGMENT="1"> contains material numbers. I have removed some of the ELEMENTS to simplyfy my example.

I want to map the <IDTNR> where <QUALF>Z02</QUALF> to my target XML structure with is a single NODE structure for material.

This works fine in the QUALIFIER exists and I have the context on the E1EDP19 level. If the <QUALF>Z02</QUALF> segment is missing I want to use the IDTNR from <QUALF>001</QUALF> and I can't get it right. I have tried changing the context to E1EDP01  but then the queues are missalinged as the E1EDP19 with <QUALF>010</QUALF> has no IDTNR.

So my questions is can this be solved with Graphic mapping or may a UDF?

I could always do it by writing a XSLT but that feels like a cop out instead of using the ESB mapping.

      <E1EDP01 SEGMENT="1">

         <POSEX>00010</POSEX>

         <E1EDP19 SEGMENT="1">

            <QUALF>010</QUALF>

         </E1EDP19>

         <E1EDP19 SEGMENT="1">

            <QUALF>Z02</QUALF>

            <IDTNR>100000999</IDTNR>

         </E1EDP19>

         <E1EDP19 SEGMENT="1">

            <QUALF>001</QUALF>

            <IDTNR>000000000010000615</IDTNR>

            <KTEXT>Hungry Lion Chips 6X2.5Kg</KTEXT>

         </E1EDP19>

         <E1EDP19 SEGMENT="1">

            <QUALF>003</QUALF>

            <IDTNR>16009650906107</IDTNR>

         </E1EDP19>

Various Mapping that I have done so far

Thank you all for your assistance in this regard.

Accepted Solutions (1)

Accepted Solutions (1)

former_member190293
Active Contributor
0 Kudos

Hi Derick!

You could use MapWithDefault to add value for missing IDTNR element.

I'm not at work now so I can't try it myself, but:

IDTNR-MapWithDefault-RemoveContexts-FormatByExample(QUALF in context of E1EDP01).

Thus you should get the correct items count for IDTNR queue in context of E1EDP01 and use it for substitution.

Regards, Evgeniy.

Former Member
0 Kudos

Hi Evgeniy.

The mapping you suggested worked for what we needed.

Below is an example of the mapping that worked should someone else wish to do the same.

Herewith issues that needs to be noted.

If the 001  QUALF NODE is found before the Z02 then it will use the IDTNR for 001.

If both QUALF elements are missing it will move the IDTNR value one context up.

Answers (1)

Answers (1)

former_member186851
Active Contributor
0 Kudos

Hello Derick,

I guess the requirment is similar to logic in the below discussion ,can you try it

Former Member
0 Kudos

Hi Raghuraman

Herewith the UDF that I wrote.

int ItemCount=0;

     for( int i=0; i< QUALF.length; i++) {

         if (QUALF[i].equals("Z02")) {

             result.addValue(IDTNR[i]);

            ItemCount++;

            break;

         }

     }

if (ItemCount ==0){

   result.addValue("ZZZZZZZZZ");

    }

The function and some additional mapping does work if the Z02 qualifier is there however if it is not the entries move up on the context and you are left with the wrong entries in your end destination.

If the function could be modified to check for both entries in the results and if a result for a context is blank it could default a entry for E1EDP01 should no entries be found in this context it would be the best solution but my java skills is zero to none and I suspect I will have to go for a Java course should I wish to further work with UDF's.

I also tried

int ItemCount=0;

     for( int i=0; i< QUALF.length; i++) {

         if (QUALF[i].equals("Z02")) {

             result.addValue(IDTNR[i]);

            ItemCount++;

            break;

         }

     }

but that leaves you with the BLUE SUPPRESS values and I could not find a UDF example that was successfull in removing them.

former_member186851
Active Contributor
0 Kudos

Hello Derick,

Removecontexts after that UDF should remove the Suppress values if am not wrong.

Anyways I will work out more and help you.

Guess Eve Solution helped you for the time being..thats glad to hear.