Skip to Content
0
May 11 at 11:05 PM

How to display E1EDPT1/E1EDPT2/TDLINE in XSLT for SAP PI

286 Views Last edit May 11 at 11:11 PM 2 rev

Hi There,

I have a requirement to create an xml document from an input IDoc that involves line item texts (E1EDPT1/E1EDPT2/TDLINE) with XSLT. The input IDoc has multiple line items (E1EDP01) and each line item has multiple E1EDPT1/E1EDPT2/TDLINE. I want to be able to retrieve the E1EDPT1/E1EDPT2/TDLINEs for each IDoc line item (E1EDP01) without going outside of the line item E1EDP01.

The current behavior of the XSLT script is that it doesn't limit itself to each line item E1EDP01. Instead, it pulls the E1EDPT1/E1EDPT2/TDLINEs from all IDoc line items E1EDP01s into the current line item E1EDP01. Is there a way of restricting the script to retrieve only the E1EDPT1/E1EDPT2/TDLINEs for each IDoc line item E1EDP01?

I have attached the input IDoc xml and the XSLT stylesheet.

Thanks in advance.

Chuo

inputidoc.xml

newstylesheet.txt

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>  
<xsl:template match="/ORDERS01/IDOC">
<ORDERS01>
<IDOC>

    
<!-- Line Items -->   
<xsl:for-each select="E1EDP01">
<E1EDP01 SEGMENT="1">
            <POSEX><xsl:value-of select="//E1EDP01/POSEX"/></POSEX>
            <ACTION><xsl:value-of select="//E1EDP01/ACTION"/></ACTION>
            <PSTYP><xsl:value-of select="//E1EDP01/PSTYP"/></PSTYP>
            <KZABS><xsl:value-of select="//E1EDP01/KZABS"/></KZABS>
            <MENGE><xsl:value-of select="//E1EDP01/MENGE"/></MENGE>
            <MENEE><xsl:value-of select="//E1EDP01/MENEE"/></MENEE>
            <BMNG2><xsl:value-of select="//E1EDP01/BMNG2"/></BMNG2>
            <PMENE><xsl:value-of select="//E1EDP01/PMENE"/></PMENE>
            <PEINH><xsl:value-of select="//E1EDP01/PEINH"/></PEINH>
            <GEWEI><xsl:value-of select="//E1EDP01/GEWEI"/></GEWEI>
            <MATKL><xsl:value-of select="//E1EDP01/MATKL"/></MATKL>
            <EVERS><xsl:value-of select="//E1EDP01/EVERS"/></EVERS>
            <BPUMN><xsl:value-of select="//E1EDP01/BPUMN"/></BPUMN>
            <BPUMZ><xsl:value-of select="//E1EDP01/BPUMZ"/></BPUMZ>
            
<!-- Line Item Text -->            
    <xsl:if test="//E1EDPT1[TDID='F01' or TDID='F03']/E1EDPT2/TDLINE">
    
            <E1EDPT1 SEGMENT="1">
            <TDID>F01</TDID>
            
     <xsl:for-each select="//E1EDPT1[TDID='F01' or TDID='F03']/E1EDPT2/TDLINE">
            <E1EDPT2 SEGMENT="1">
                <TDLINE>
                    <xsl:value-of select="."/>
                </TDLINE>
                <TDFORMAT>*</TDFORMAT>
            </E1EDPT2>
     </xsl:for-each>
            </E1EDPT1>
    </xsl:if>
            

</E1EDP01>
</xsl:for-each> 
     
</IDOC>            
</ORDERS01>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<ORDERS01>
    <IDOC BEGIN="1">
        <EDI_DC40 SEGMENT="1">
            <TABNAM>EDI_DC40</TABNAM>
            <MANDT>012</MANDT>
            <DOCNUM>0000000001137381</DOCNUM>
            <DOCREL>750</DOCREL>
            <STATUS>30</STATUS>
            <DIRECT>1</DIRECT>
            <OUTMOD>2</OUTMOD>
            <IDOCTYP>ORDERS01</IDOCTYP>
            <CIMTYP>ZORDERX1</CIMTYP>
            <MESTYP>ZORDERS_EDI</MESTYP>
            <STD>X</STD>
            <STDVRS>004010</STDVRS>
            <STDMES>850</STDMES>
            <SNDPOR>SAPDVE</SNDPOR>
            <SNDPRT>LS</SNDPRT>
            <SNDPRN>DVD002</SNDPRN>
            <RCVPOR>A000000004</RCVPOR>
            <RCVPRT>LI</RCVPRT>
            <RCVPFC>LF</RCVPFC>
            <RCVPRN>0000000000</RCVPRN>
            <CREDAT>20211123</CREDAT>
            <CRETIM>140225</CRETIM>
            <SERIAL>20211111152118</SERIAL>
        </EDI_DC40>
        <E1EDK01 SEGMENT="1">
            <CURCY>CAD</CURCY>
            <HWAER>CAD</HWAER>
            <WKURS>1.00000</WKURS>
            <ZTERM>Z011</ZTERM>
            <BSART>LP</BSART>
            <BELNR>5500001113</BELNR>
            <RECIPNT_NO>000000</RECIPNT_NO>
        </E1EDK01>
        <E1EDK14 SEGMENT="1">
            <QUALF>014</QUALF>
            <ORGID>1002</ORGID>
        </E1EDK14>
        <E1EDK03 SEGMENT="1">
            <IDDAT>012</IDDAT>
            <DATUM>20110608</DATUM>
        </E1EDK03>
        <E1EDK02 SEGMENT="1">
            <QUALF>001</QUALF>
            <BELNR>5500001113</BELNR>
            <DATUM>20110608</DATUM>
            <UZEIT>152118</UZEIT>
        </E1EDK02>                    
        <E1EDP01 SEGMENT="1">
            <POSEX>00010</POSEX>
            <ACTION>001</ACTION>
            <PSTYP>2</PSTYP>
            <KZABS>X</KZABS>
            <MENGE>10000.000</MENGE>
            <MENEE>EA</MENEE>
            <BMNG2>10000.000</BMNG2>
            <PMENE>EA</PMENE>
            <PEINH>1</PEINH>
            <GEWEI>KG</GEWEI>
            <MATKL>DISC</MATKL>
            <EVERS>A1</EVERS>
            <BPUMN>1</BPUMN>
            <BPUMZ>1</BPUMZ>
            <E1EDP20 SEGMENT="1">
                <WMENG>10.000</WMENG>
                <AMENG>0.000</AMENG>
                <EDATU>20141212</EDATU>
            </E1EDP20>
            <E1EDP19 SEGMENT="1">
                <QUALF>001</QUALF>
                <IDTNR>6M3036412</IDTNR>
            </E1EDP19>
            <E1EDPT1 SEGMENT="1">
                <TDID>F01</TDID>
                <TSSPRAS>F</TSSPRAS>
                <TSSPRAS_ISO>FR</TSSPRAS_ISO>
                <E1EDPT2 SEGMENT="1">
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test 15 aug</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test1 12 aug</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test2</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test1</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>12 july test2</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>12 july test</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>Item Text 2.</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>item text.</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
            </E1EDPT1>
            <E1EDPT1 SEGMENT="1">
                <TDID>F03</TDID>
                <TSSPRAS>F</TSSPRAS>
                <TSSPRAS_ISO>FR</TSSPRAS_ISO>
                <E1EDPT2 SEGMENT="1">
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test 15 aug</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test1 12 aug</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test2</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test1</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>12 july test2</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>12 july test</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>Item Text 2.</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>item text.</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
            </E1EDPT1>            
        </E1EDP01>
        <E1EDP01 SEGMENT="1">
            <POSEX>00010</POSEX>
            <ACTION>001</ACTION>
            <PSTYP>2</PSTYP>
            <KZABS>X</KZABS>
            <MENGE>10000.000</MENGE>
            <MENEE>EA</MENEE>
            <BMNG2>10000.000</BMNG2>
            <PMENE>EA</PMENE>
            <PEINH>1</PEINH>
            <GEWEI>KG</GEWEI>
            <MATKL>DISC</MATKL>
            <EVERS>A1</EVERS>
            <BPUMN>1</BPUMN>
            <BPUMZ>1</BPUMZ>
            <E1EDP20 SEGMENT="1">
                <WMENG>10.000</WMENG>
                <AMENG>0.000</AMENG>
                <EDATU>20141212</EDATU>
            </E1EDP20>
            <E1EDP19 SEGMENT="1">
                <QUALF>001</QUALF>
                <IDTNR>6M3036412</IDTNR>
            </E1EDP19>
            <E1EDPT1 SEGMENT="1">
                <TDID>F01</TDID>
                <TSSPRAS>F</TSSPRAS>
                <TSSPRAS_ISO>FR</TSSPRAS_ISO>
                <E1EDPT2 SEGMENT="1">
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test 15 aug</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test1 12 aug</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test2</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test1</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>12 july test2</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>12 july test</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>Item Text 2.</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>item text.</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
            </E1EDPT1>
            <E1EDPT1 SEGMENT="1">
                <TDID>F03</TDID>
                <TSSPRAS>F</TSSPRAS>
                <TSSPRAS_ISO>FR</TSSPRAS_ISO>
                <E1EDPT2 SEGMENT="1">
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test 15 aug</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test1 12 aug</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test2</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>test1</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>12 july test2</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>12 july test</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>Item Text 2.</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
                <E1EDPT2 SEGMENT="1">
                    <TDLINE>item text.</TDLINE>
                    <TDFORMAT>*</TDFORMAT>
                </E1EDPT2>
            </E1EDPT1>            
        </E1EDP01>        
        <E1EDS01 SEGMENT="1">
            <SUMID>009</SUMID>
            <SUMME>200000</SUMME>
            <SUNIT>CAD</SUNIT>
        </E1EDS01>
    </IDOC>
</ORDERS01>

Attachments

inputidoc.xml (9.8 kB)