Thursday, December 20, 2007

Create XSLT program

There are two options to create a XSLT program:

  1. Tcode: SE80 -> create/choose packet -> right click on it | Create -> Others -> XSL Transformation
  2. Tcode: XSLT_TOOL

For a quick overview you can watch at the SXSLTDEMO* programs.

In this example we already use the three XSLT options explained later.
As you can see we define a XSL and ASX (ABAP) tags to handle the ABAP and XML variables/tags. After "" we create the XML_OUTPUT tag, but in this case we also could speak about a container. In fact the XML_OUTPUT tag comprise the structure of the internal table "it_airplus" which where moved by the CALL TRANSFORMATION in the report.

See the whole XSLT program here: Snippets:XSLT sample to encode, decode XML file

"http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
"INVOICES_BTM">
"http://www.sap.com/abapxml" version="1.0">


for-each select="INVOICE_BTM">


"head" select="INVOICE_HEAD" />
"$head/@LANGUAGE" />
"$head/@DIRECT_DEBIT_QUALIFIER" />
"$head/INVOICE_DATE"/>

"number" select="$head/INVOICE_NUMBER" />
"$number/NUMBER"/>
"$number/EXTENSION"/>
"$number/SEQUENCE"/>

"$head/CREDIT_DEBIT_QUALIFIER"/>
"$head/CREDIT_DEBIT_LABEL"/>
"$head/BILLING_CURRENCY"/>
"$head/BASE_CURRENCY"/>
"$head/DUE_DATE"/>


"inv_parties" select="$head/INVOICE_PARTIES" />

"payee" select="$inv_parties/PAYEE" />
"$payee/PARTYCODE"/>

"address" select="$payee" />

for-each select="$address/ADDRESSLINE">
"."/>
for-each>
"INVOICE_HEAD/INVOICE_PARTIES/PAYEE/ADDRESS/POST_CODE"/>
"INVOICE_HEAD/INVOICE_PARTIES/PAYEE/ADDRESS/CITY"/>
"INVOICE_HEAD/INVOICE_PARTIES/PAYEE/ADDRESS/STATE_CODE"/>
"INVOICE_HEAD/INVOICE_PARTIES/PAYEE/ADDRESS/COUNTRY_CODE"/>
"INVOICE_HEAD/INVOICE_PARTIES/PAYEE/ADDRESS/COUNTRY"/>


...
...

"summary" select="INVOICE_SUMMARY" />
"$summary/@NUMBER_OF_INVOICE_DETAIL" />

for-each select="$summary/TOTAL_SALE_VALUES">

"total_sale_values" select="$summary" />
"$total_sale_values/@CURRENCY"/>
"$total_sale_values/NET_TOTAL"/>
"$total_sale_values/VAT_TOTAL"/>

for-each select="INVOICE_SUMMARY/TOTAL_SALE_VALUES/VAT_SUMMARY">

"vat_sum" select="$total_sale_values/VAT_SUMMARY" />
"$vat_sum/@RATE" />
"."/>
"."/>
for-each>


for-each>



"INVOICE_SUMMARY/TOTAL_BILLING_VALUES/NET_TOTAL"/>
"INVOICE_SUMMARY/TOTAL_BILLING_VALUES/VAT_TOTAL"/>


"INVOICE_SUMMARY/TOTAL_BILLING_VALUES/VAT_SUMMARY/@RATE" />

for-each select="INVOICE_SUMMARY/TOTAL_BILLING_VALUES/VAT_SUMMARY/NET_VALUE">
"."/>
for-each>
for-each select="INVOICE_SUMMARY/TOTAL_BILLING_VALUES/VAT_SUMMARY/VAT_VALUE">
"."/>
for-each>



"INVOICE_SUMMARY/TOTAL_BILLING_VALUES/ADDITIONAL_INSURANCE_TOTAL"/>


"INVOICE_SUMMARY/TOTAL_BILLING_VALUES/TOTAL_BILLING_AMOUNT"/>







for-each>




No comments:

Blog Archive