Skip to Content

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

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Apr 20 at 03:10 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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.