Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamic XSLT source code generation based upon internal table

Former Member
0 Likes
1,019

Hi,

Is there anyway to generate dynamic XSLT source code based upon final structure of output internal table and call dynamic generated XSLT in program?

CALL TRANSFORMATION z_transformation

            PARAMETERS

             p_shared_string = lo_shared_str_nodeset

            SOURCE XML g_sheet_data

            RESULT lt_data = i_data[].

Source code example of XSLT transformation -

<xsl:template match="/">

     <asx:abap version="1.0">

       <asx:values>

         <LT_DATA>   "Internal table

           <xsl:for-each select="ss:worksheet/ss:sheetData/ss:row">

             <xsl:if test="position() &gt; 1">

               <item>

                 <FIELD1>

                   <xsl:variable name="cell_id" select="concat('A', position())"/>

                   <xsl:variable name="v_index" select="ss:c[@r=$cell_id][@t='s']/ss:v"/>

                   <xsl:if test="$v_index">

                     <xsl:value-of select="$V_SHARED_STRING/sst/si[$v_index + 1]/t"/>

                   </xsl:if>

                   <xsl:if test="not($v_index)">

                     <xsl:value-of select="ss:c[@r=$cell_id]/ss:v"/>

                   </xsl:if>

                 </FIELD1>

             </item>

             </xsl:if>

           </xsl:for-each>

         </LT_DATA> "internal table

       </asx:values>

     </asx:abap>

   </xsl:template>

</xsl:transform>

2 REPLIES 2
Read only

Former Member
0 Likes
533

In addition,

We are converting binary data of excel from application server into internal table but currently we created two XSLT transformation to achieve this one for deleting name space and other for converting data into internal table format.


We want to make our source code for future use also,Is there anyway to generate XSLT source code dynamically?Above mentioned code is snippet of data extracting which we are doing but this transformation is hard coded.


Any help is appreciated.


BR,

Praveen

Read only

0 Likes
533

You could probably check out this answer