1 – Create file xsl:

Captura de Tela 2016-02-03 às 13.53.28.png

<?xml version=”1.0″ encoding=”UTF-8″?>

<xsl:stylesheet xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:doc=”urn:sap-com:document:sap:rfc:functions” version=”2.0″>

  <xsl:output indent=”yes”></xsl:output>

  <xsl:variable name=”Fields” select=”RFC_READ_TABLE/TABLES/FIELDS/item”></xsl:variable>

  <xsl:template match=”RFC_READ_TABLE”>

    <xsl:element name=”rows”>

      <xsl:for-each select=”TABLES/DATA/item”>

        <xsl:apply-templates select=”WA”></xsl:apply-templates>

      </xsl:for-each>

    </xsl:element>

  </xsl:template>

  <xsl:template match=”WA”>

    <xsl:variable name=”Data” select=”.”></xsl:variable>

    <xsl:element name=”row”>

      <xsl:for-each select=”$Fields”>

        <xsl:element name=”{FIELDNAME}”>

          <xsl:value-of select=”substring($Data, OFFSET+1, LENGTH)”></xsl:value-of>

        </xsl:element>

      </xsl:for-each>

    </xsl:element>

  </xsl:template>

</xsl:stylesheet>

2 – Add action block XSL Transformation:

Captura de Tela 2016-02-03 às 13.52.18.png

Captura de Tela 2016-02-03 às 13.57.30.png

3 – Configure XSL Transformation

3.1 Configure file XSL

   

Captura de Tela 2016-02-03 às 14.04.37.png

3.2 Configure XML input

Captura de Tela 2016-02-03 às 14.08.02.png

Example RFC_READ_TABLE IN TABLE MAPL


<?xml version=”1.0″ encoding=”UTF-8″?>

<RFC_READ_TABLE>

<INPUT>

<DELIMITER>¬</DELIMITER>

<NO_DATA/>

<QUERY_TABLE>MAPL</QUERY_TABLE>

<ROWCOUNT>0</ROWCOUNT>

<ROWSKIPS>0</ROWSKIPS>

</INPUT>

<TABLES>

<DATA>

<item>

<WA>20150626¬3203¬2¬52001190¬01¬0000002¬00000002¬000000000000100265¬</WA>

</item>

<item>

<WA>20150820¬3203¬2¬52001322¬01¬0000001¬00000001¬000000000000100265¬</WA>

</item>

<item>

<WA>20140618¬3203¬Q¬00002061¬01¬0000001¬00000001¬000000000000100265¬X</WA>

</item>

<item>

<WA>20141222¬3203¬Q¬00002204¬01¬0000001¬00000001¬000000000000100265¬</WA>

</item>

</DATA>

<FIELDS>

<item>

<FIELDNAME>DATUV</FIELDNAME>

<OFFSET>000000</OFFSET>

<LENGTH>000008</LENGTH>

<TYPE>D</TYPE>

<FIELDTEXT>Data início validade</FIELDTEXT>

</item>

<item>

<FIELDNAME>WERKS</FIELDNAME>

<OFFSET>000009</OFFSET>

<LENGTH>000004</LENGTH>

<TYPE>C</TYPE>

<FIELDTEXT>Centro</FIELDTEXT>

</item>

<item>

<FIELDNAME>PLNTY</FIELDNAME>

<OFFSET>000014</OFFSET>

<LENGTH>000001</LENGTH>

<TYPE>C</TYPE>

<FIELDTEXT>Tipo de roteiro</FIELDTEXT>

</item>

<item>

<FIELDNAME>PLNNR</FIELDNAME>

<OFFSET>000016</OFFSET>

<LENGTH>000008</LENGTH>

<TYPE>C</TYPE>

<FIELDTEXT>Chave do grupo de listas de tarefas</FIELDTEXT>

</item>

<item>

<FIELDNAME>PLNAL</FIELDNAME>

<OFFSET>000025</OFFSET>

<LENGTH>000002</LENGTH>

<TYPE>C</TYPE>

<FIELDTEXT>Numerador de grupos</FIELDTEXT>

</item>

<item>

<FIELDNAME>ZKRIZ</FIELDNAME>

<OFFSET>000028</OFFSET>

<LENGTH>000007</LENGTH>

<TYPE>N</TYPE>

<FIELDTEXT>Numerador de critérios adicionais</FIELDTEXT>

</item>

<item>

<FIELDNAME>ZAEHL</FIELDNAME>

<OFFSET>000036</OFFSET>

<LENGTH>000008</LENGTH>

<TYPE>N</TYPE>

<FIELDTEXT>Numerador interno</FIELDTEXT>

</item>

<item>

<FIELDNAME>MATNR</FIELDNAME>

<OFFSET>000045</OFFSET>

<LENGTH>000018</LENGTH>

<TYPE>C</TYPE>

<FIELDTEXT>Nº do material</FIELDTEXT>

</item>

<item>

<FIELDNAME>LOEKZ</FIELDNAME>

<OFFSET>000064</OFFSET>

<LENGTH>000001</LENGTH>

<TYPE>C</TYPE>

<FIELDTEXT>Código de eliminação</FIELDTEXT>

</item>

</FIELDS>

<OPTIONS>

<item>

<TEXT>MATNR = ‘000000000000100265’ AND WERKS = ‘3203’</TEXT>

</item>

</OPTIONS>

</TABLES>

</RFC_READ_TABLE>

3.3 Configure XML output

Variable Transaction.OUT (Type XML).

Captura de Tela 2016-02-03 às 14.24.19.png

XML output transformed by XSL and captured the Tracer_0.

<?xml version=”1.0″ encoding=”UTF-8″?>

<RFC_READ_TABLE>

<rows>

<row>

<DATUV>20150626</DATUV>

<WERKS>3203</WERKS>

<PLNTY>2</PLNTY>

<PLNNR>52001190</PLNNR>

<PLNAL>01</PLNAL>

<ZKRIZ>0000002</ZKRIZ>

<ZAEHL>00000002</ZAEHL>

<MATNR>000000000000100265</MATNR>

<LOEKZ/>

</row>

<row>

<DATUV>20150820</DATUV>

<WERKS>3203</WERKS>

<PLNTY>2</PLNTY>

<PLNNR>52001322</PLNNR>

<PLNAL>01</PLNAL>

<ZKRIZ>0000001</ZKRIZ>

<ZAEHL>00000001</ZAEHL>

<MATNR>000000000000100265</MATNR>

<LOEKZ/>

</row>

<row>

<DATUV>20140618</DATUV>

<WERKS>3203</WERKS>

<PLNTY>Q</PLNTY>

<PLNNR>00002061</PLNNR>

<PLNAL>01</PLNAL>

<ZKRIZ>0000001</ZKRIZ>

<ZAEHL>00000001</ZAEHL>

<MATNR>000000000000100265</MATNR>

<LOEKZ>X</LOEKZ>

</row>

<row>

<DATUV>20141222</DATUV>

<WERKS>3203</WERKS>

<PLNTY>Q</PLNTY>

<PLNNR>00002204</PLNNR>

<PLNAL>01</PLNAL>

<ZKRIZ>0000001</ZKRIZ>

<ZAEHL>00000001</ZAEHL>

<MATNR>000000000000100265</MATNR>

<LOEKZ/>

</row>

</rows>

</RFC_READ_TABLE>

4 – Copy and Paste XML out for Transaction.OUT

Much better to work than concatenated strings.

<WA>20150626¬3203¬2¬52001190¬01¬0000002¬00000002¬000000000000100265¬</WA>

Captura de Tela 2016-02-03 às 14.28.55.png

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply