xmlabap-st

Assign field value to attribute in ABAP ST transformation?


I'm using SAP Simple Transformation and I want to set value of unitCode attribute from ABAP field which is defined inside my structure. Let's say it's UNITCODE field.

 <cbc:InvoicedQuantity tt:value-ref="INVOICEDQUANTITY" unitCode="C62" unitCodeListID="UNECRec20"/>

Right now unitCode is hardcoded as value C62 but I want that this attribute takes value from ABAP UNITCODE field (in same structure as INVOICEDQUANTITY). How can I make this happen?

Thanks in advance!


Solution

  • You may initialize an attribute from an ABAP variable using tt:attribute:

      <cbc:InvoicedQuantity tt:value-ref="INVOICEDQUANTITY" unitCodeListID="UNECRec20">
        <tt:attribute name="unitCode" value-ref="UNITCODE"/>
      </cbc:InvoicedQuantity>
    

    Below is a Minimal Reproducible Example: