‎2009 Apr 23 9:41 AM
Goal: I want my XSLT mapping to be dynamic, because I expect a certain number of fields with values in my XML, but these field names may change over time, so I have to make it dynamic.
Step 1: I made my output dynamic by using dynamic internal tables (field-symbols). So that I can change my internal tables easily with a custom-table. Done!
Step 2: My XSLT transformation should be handled dynamically. Not done!
Is this step 2 even possible?
I was thinking of passing PARAMETERS to my CALL TRANSFORMATION statement so that I can let know what fieldnames my XSLT can expect, but then the question remains if the ZTEST transformation can read this out for my purpose.
CALL TRANSFORMATION ztest
PARAMETERS (gt_param)
SOURCE XML gt_itab
RESULT (gt_result_xml).
...knowing that gt_param can only by of type
ABAP_TRANS_PARMBIND_TAB (for specifying strings) or
ABAP_TRANS_OBJBIND_TAB (for specifying object references) or
ABAP_TRANS_PARM_OBJ_BIND_TAB (for specifying data references).
Thus, is it possible to make my TRANSFORMATION handling dynamic (by using PARAMETERS or something else)? If yes, does anybody know how. Examples are appreciated.
Mehmet Metin
‎2009 May 01 10:42 AM
‎2009 Dec 21 2:28 PM
hi..
how did you handled this dynamic filed names of internal table..i have the same requirement..
PLease reply..
‎2010 May 12 12:37 PM
Hi Mehmet,
How did u solved this problem? I have a customizing table to how the system read xml document. But i havent known how to write a xslt document yet..
Thanks
‎2012 Aug 15 7:59 PM
Hi Mehmet,
I am stuck with a similar requirement. Could you kindly let me know how you were able to resolve the issue at your end? Please respond back.
Regards,
Balaji
‎2012 Aug 15 8:10 PM
This can be done with basic XSLT. Use the XPath expression '*' to apply a template to each child of a given node (for example, if a node represents an ABAP structure, its children represent its components). In the template, use the XPath-function 'local-name()' to retrieve the name of the current element without namespace. Now you should have everything you need for creating the result tree.
For a working example in our XI system, see the following template:
<xsl:template match="ZMEDI_MELDUNG_DET">
<xsl:element name="{SEGID_N}">
<xsl:element name='SEGID_N'>
<xsl:value-of select="*[position()=1]"/>
</xsl:element>
<xsl:for-each select="*[position()>1 and text() != '']">
<xsl:element name="{local-name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
Here, I copy the components of the ABAP source structure ZMEDI_MELDUNG_DET (the structure name was fixed in my case, but it's easy to identify it without specifying its name, if it should be given at runtime only) into a result tree fragment with parent node name = the content of the ABAP component SEGID_N, the first child having the fixed name SEGID_N with (redundant) its value again, and after that all the components of the source structure, whatever they may be, if their content is non-empty (this was a format required by another non-SAP-development team).
Regards,
Rüdiger