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 processing - parameters?

Former Member
0 Likes
1,830

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

5 REPLIES 5
Read only

Former Member
0 Likes
1,037

Solved (differently).

Read only

0 Likes
1,037

hi..

how did you handled this dynamic filed names of internal table..i have the same requirement..

PLease reply..

Read only

0 Likes
1,037

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

Read only

0 Likes
1,037

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

Read only

0 Likes
1,037

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