cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Simple Transformation - ABAP to XML - Dynamic attribute name

EgbertVenema
Explorer
0 Kudos
615

Let's start with the question: Is it possible to have dynamic attribute names with simple transformations?

And for a bit of context: From our S/4HANA Public Cloud Edition we need to export data in XML format. The easiest way to convert an internal table to XML is by using a simple transformation. To keep this as flexible as possible, I have added property attributes as a name/value table.

ARTICLE-VALUE = 'BL22070'
ARTICLE-PROPERTIES = ( ( name = 'group'   value = 'BK' )
                       ( name = 'chgdate' value = '20240807' ) ).

 In the simple transformation, this is processed in a loop:

<tt:loop ref = "article.properties">
  <tt:attribute name="$ref.name" value-ref="$ref.value"/>
</tt:loop>

Everything else (of course there is more data) works as expected, the XML looks great... except for the attribute name here. The "$ref.name" is copied literally.

<article $ref.name="BK" $ref.name="20240807">

Fair enough, the documentation of the tt:attribute tag does not mention any dynamic way of defining the name... as I found out after this did not work.

Is there a different method to get this to work? Should I start over and switch to XSLT? Or just accept that I will have to define all attribute names statically in the simple transformation and check whether to include them based on the corresponding ref-value?

Thanks in advance for your help and insights!

Accepted Solutions (0)

Answers (0)