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

Variable currency element in Simple Transformation

johnm16
Participant
0 Likes
478

Hi Folks,

I'm working on a Simple Transformation in XSLT_TOOL to  convert data from ABAP to XML.  It works fine,  but there is one improvement I need to make. 

The data comes from an SD invoice,  and each value element needs to be accompanied by a currency element.  And the currency has to appear on the same line in the XML as the value.

So I need an XML output line that looks something like this:

<Amount currencyID="EUR">100.00</Amount>

Thus far,  the relevant line in my ST looks like this:

<Amount currencyID="EUR" tt:value-ref=".INVOICE.AMOUNT"/>

Clearly, the currency here is a literal;  but I need to insert it as a variable instead.  It's in my ABAP structure as INVOICE.CURRENCY.

So how do I include the currency variable, without it appearing on a separate line?

Don't think I haven't searched for this;  everything I've found so far either outputs 2 lines instead of 1,  or doesn't compile (thank you AI).  I'm sure the answer is trivial...

Thanks for reading,

John

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
413

In your question "currencyID" is named officially an "XML Attribute".

In Simple Transformation, use tt:attribute:

<Amount tt:value-ref=".INVOICE.AMOUNT">
  <tt:attribute name="currencyID" value-ref=".INVOICE.CURRENCY"/>
</Amount>

 

View solution in original post

Hi Folks,

I'm working on a Simple Transformation in XSLT_TOOL to  convert data from ABAP to XML.  It works fine,  but there is one improvement I need to make. 

The data comes from an SD invoice,  and each value element needs to be accompanied by a currency element.  And the currency has to appear on the same line in the XML as the value.

So I need an XML output line that looks something like this:

<Amount currencyID="EUR">100.00</Amount>

Thus far,  the relevant line in my ST looks like this:

<Amount currencyID="EUR" tt:value-ref=".INVOICE.AMOUNT"/>

Clearly, the currency here is a literal;  but I need to insert it as a variable instead.  It's in my ABAP structure as INVOICE.CURRENCY.

So how do I include the currency variable, without it appearing on a separate line?

Don't think I haven't searched for this;  everything I've found so far either outputs 2 lines instead of 1,  or doesn't compile (thank you AI).  I'm sure the answer is trivial...

Thanks for reading,

John

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
414

In your question "currencyID" is named officially an "XML Attribute".

In Simple Transformation, use tt:attribute:

<Amount tt:value-ref=".INVOICE.AMOUNT">
  <tt:attribute name="currencyID" value-ref=".INVOICE.CURRENCY"/>
</Amount>

 

Read only

0 Likes
410

Thank you Sandra;  I knew it would be simple...