Skip to Content
0

How to map SOAP IDOC for specific Text TDID with multiple TDLINES into one Target XML field

Apr 20 at 02:07 PM

134

avatar image

I have a requirement where for a specific E1EDKT1 TDID value, I need to concatenate the multiple E1EDKT2 TDLINEs into one Target field defined as a String. The target field is defined as:

<xsd:element minOccurs="0" maxOccurs="1" name="Comments" type="xsd:string" />

I need to select the correct set of TDLINES and either Loop thru them to concatenate them together, or concatenate them to the target field. I've looked as using a variable, but I'm not sure if this will work.

Sender data looks like:

    <E1EDKT1 SEGMENT="1">
      <TDID>0102</TDID>
      <TSSPRAS>E</TSSPRAS>
      <TSSPRAS_ISO>EN</TSSPRAS_ISO>
      <E1EDKT2 SEGMENT="1">
        <TDLINE>Testing Transport Info Text</TDLINE>
        <TDFORMAT>*</TDFORMAT>
      </E1EDKT2>
      <E1EDKT2 SEGMENT="1">
        <TDLINE>Multiple line text test</TDLINE>
        <TDFORMAT>*</TDFORMAT>
      </E1EDKT2>
    </E1EDKT1>
    <E1EDKT1 SEGMENT="1">
      <TDID>ZFGP</TDID>
      <TSSPRAS>E</TSSPRAS>
      <TSSPRAS_ISO>EN</TSSPRAS_ISO>
      <TDOBNAME>MATERIAL FREIGHT GROUP</TDOBNAME>
      <E1EDKT2 SEGMENT="1">
        <TDLINE>REF</TDLINE>
      </E1EDKT2>
    </E1EDKT1>

Only when TDID = 0102 the result should be:

<Comments>Testing Transport Info Text Multiple line text test</Comments>

I don't have experience with PI mapping so all of this is very new to me. Would someone be able to provide a solution or lead me to a blog that would help me determine how to accomplish this requirement?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Morten Wittrock
Apr 20 at 03:10 PM
1

Hi there

Granted, I'm biased since I love XSLT, but XSLT really is incredibly useful in situations like the one you describe :-)

Assuming the following simplified input:

<?xml version="1.0" encoding="UTF-8"?>
<IDOC>
    <E1EDKT1 SEGMENT="1">
        <TDID>0102</TDID>
        <TSSPRAS>E</TSSPRAS>
        <TSSPRAS_ISO>EN</TSSPRAS_ISO>
        <E1EDKT2 SEGMENT="1">
            <TDLINE>Testing Transport Info Text</TDLINE>
            <TDFORMAT>*</TDFORMAT>
        </E1EDKT2>
        <E1EDKT2 SEGMENT="1">
            <TDLINE>Multiple line text test</TDLINE>
            <TDFORMAT>*</TDFORMAT>
        </E1EDKT2>
    </E1EDKT1>
    <E1EDKT1 SEGMENT="1">
        <TDID>ZFGP</TDID>
        <TSSPRAS>E</TSSPRAS>
        <TSSPRAS_ISO>EN</TSSPRAS_ISO>
        <TDOBNAME>MATERIAL FREIGHT GROUP</TDOBNAME>
        <E1EDKT2 SEGMENT="1">
            <TDLINE>REF</TDLINE>
        </E1EDKT2>
    </E1EDKT1>
</IDOC>

You can achieve the following output:

<?xml version="1.0" encoding="UTF-8"?>
<Comments>Testing Transport Info Text Multiple line text test</Comments>

With this super simple XSLT stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:template match="/">
        <Comments>
            <xsl:value-of select="string-join(//E1EDKT1[TDID = '0102']/E1EDKT2/TDLINE, ' ')"/>
        </Comments>
    </xsl:template>
</xsl:stylesheet>

Pretty neat, isn't it?

Regards,

Morten

Show 5 Share
10 |10000 characters needed characters left characters exceeded

I've never used XSLT mapping. Is it difficult to figure out?

0

There is a bit of a learning curve, for sure, but once you get the hang of it, complicated mapping problems become easy to solve. There is an XSLT tutorial at the W3Schools site, you might want to take a look at.

Each of the three mapping options in Cloud Integration has pros and cons. Message Mapping (i.e. the graphical mapping tool) is easier to pick up, and straightforward mappings are quick and easy to build. More complicated mappings, however, can be a real pain to build.

0

And how do I get started?

0

So, how did it go?

Regards,

Morten

0

I was able to accomplish this by creating a two step mapping process. By modifying target xsd to change the "comment" tag into a complex structure, I was able to successfully perform the concatenation for the specific E1EDK01-TDID value. I then pass the result of this map into the next map with the original target xsd to complete the process.

0