XML XSLT With Abap
XML XSLT With Abap
XML XSLT With Abap
1
inv_number TYPE t_inv_number,
credit_debit_qualifier(1),
credit_debit_label(10),
billing_currency(3),
base_currency(3),
due_date(8),
inv_parties TYPE t_inv_parties,
inv_qualifier(4),
END OF t_ap_head.
*---------------------------------------->
2
TYPES: BEGIN OF t_desc_sal_prov,
agency(30),
branch(15),
END OF t_desc_sal_prov.
TYPES: BEGIN OF t_desc_db_travel,
start_stat(50),
dest_stat(50),
db_class(15),
adults(2),
children(2),
END OF t_desc_db_travel.
TYPES: BEGIN OF t_desc_ht_book,
start_date(8),
end_date(8),
amount(2),
END OF t_desc_ht_book.
TYPES: BEGIN OF t_desc_serv_desc,
date(8),
doc_number(30),
voucher_number(30),
cc_code(15),
class(10),
txn_type_detail(3),
etix_qual(1),
flight_tax(15),
a_add_info_line(5),
add_info(50),
db_travel_data TYPE t_desc_db_travel,
ht_book_data TYPE t_desc_ht_book,
END OF t_desc_serv_desc.
3
bill_values TYPE t_det_values,
det_descrip TYPE t_det_det_desc,
END OF t_ap_detail.
*-------------------------------------------------->
4
DATA: l_xml_x1 TYPE xstring.
*airplus tables
DATA: it_airplus TYPE STANDARD TABLE OF t_ap,
wa_airplus TYPE t_ap
.
*Errorvariables
DATA: xslt_err TYPE REF TO cx_xslt_exception,
err_string TYPE string
.
START-OF-SELECTION.
* Creating a document
l_document = l_ixml->create_document( ).
* Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
* Validate a document
IF pa_val EQ 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
ENDIF.
5
err_string = xslt_err->get_text( ).
WRITE: / 'Transformation error: ', err_string.
EXIT.
ENDTRY.* setting a breakpoint to watch the workarea
* by the internal table "it_airplus"
break-point.
1. Tcode: SE80 -> create/choose packet -> right click on it | Create -> Others -> XSL Transformation
2. Tcode: XSLT_TOOL
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
"<asx:values>" 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.
This coding shows you a complete XSLT program with loops and variables.
XSLT programs can be used to read out and generate XML files.
As you can see in the first part of this program I used variables and later at description tag I used the
explicit command to refer the right tag in the XML file.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:template match="INVOICES_BTM">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<XML_OUTPUT>
<xsl:for-each select="INVOICE_BTM">
<INVOICE_BTM>
<HEAD>
<xsl:variable name="head" select="INVOICE_HEAD" />
<A_LANGUAGE> <xsl:value-of select="$head/@LANGUAGE" />
</A_LANGUAGE>
<A_DIRECT_DEBIT_QUAL> <xsl:value-of select="$head/@DIRECT_DEBIT_QUALIFIER" />
</A_DIRECT_DEBIT_QUAL>
<INV_DATE> <xsl:value-of select="$head/INVOICE_DATE"/></INV_DATE>
<INV_NUMBER>
<xsl:variable name="number" select="$head/INVOICE_NUMBER" />
<NUMBER> <xsl:value-of select="$number/NUMBER"/> </NUMBER>
<EXTENSION><xsl:value-of select="$number/EXTENSION"/></EXTENSION>
<SEQUENCE> <xsl:value-of select="$number/SEQUENCE"/> </SEQUENCE>
</INV_NUMBER>
<CREDIT_DEBIT_QUALIFIER> <xsl:value-of
select="$head/CREDIT_DEBIT_QUALIFIER"/></CREDIT_DEBIT_QUALIFIER>
6
<CREDIT_DEBIT_LABEL> <xsl:value-of select="$head/CREDIT_DEBIT_LABEL"/>
</CREDIT_DEBIT_LABEL>
<BILLING_CURRENCY> <xsl:value-of select="$head/BILLING_CURRENCY"/>
</BILLING_CURRENCY>
<BASE_CURRENCY> <xsl:value-of select="$head/BASE_CURRENCY"/>
</BASE_CURRENCY>
<DUE_DATE> <xsl:value-of select="$head/DUE_DATE"/>
</DUE_DATE>
<INV_PARTIES>
<xsl:variable name="inv_parties" select="$head/INVOICE_PARTIES" />
<PAYEE>
<xsl:variable name="payee" select="$inv_parties/PAYEE" />
<PARTYCODE><xsl:value-of select="$payee/PARTYCODE"/></PARTYCODE>
<ADDRESS>
<xsl:variable name="address" select="$payee" />
<xsl:for-each select="$address/ADDRESSLINE">
<ADDRESSLINE> <xsl:value-of select="."/> </ADDRESSLINE>
</xsl:for-each>
<POST_CODE> <xsl:value-of
select="INVOICE_HEAD/INVOICE_PARTIES/PAYEE/ADDRESS/POST_CODE"/></POST_CODE>
<CITY> <xsl:value-of
select="INVOICE_HEAD/INVOICE_PARTIES/PAYEE/ADDRESS/CITY"/></CITY>
<STATE_CODE> <xsl:value-of
select="INVOICE_HEAD/INVOICE_PARTIES/PAYEE/ADDRESS/STATE_CODE"/></STATE_CODE>
<COUNTRY_CODE> <xsl:value-of
select="INVOICE_HEAD/INVOICE_PARTIES/PAYEE/ADDRESS/COUNTRY_CODE"/></COUNTRY_CODE>
<COUNTRY> <xsl:value-of
select="INVOICE_HEAD/INVOICE_PARTIES/PAYEE/ADDRESS/COUNTRY"/></COUNTRY>
</ADDRESS>
</PAYEE>
<INVOICEE>
<xsl:variable name="invoicee" select="$inv_parties/INVOICEE" />
<BILLING_LEVEL><xsl:value-of select="$invoicee/BILLING_LEVEL"/></BILLING_LEVEL>
<PARTYCODE> <xsl:value-of select="$invoicee/PARTYCODE"/></PARTYCODE>
<ADDRESS>
<xsl:variable name="address" select="$invoicee/ADDRESS" />
<xsl:for-each select="$address/ADDRESSLINE">
<ADDRESSLINE> <xsl:value-of select="."/></ADDRESSLINE>
</xsl:for-each>
<POST_CODE> <xsl:value-of select="$address/POST_CODE"/></POST_CODE>
<CITY> <xsl:value-of select="$address/CITY"/></CITY>
<STATE_CODE> <xsl:value-of select="$address/STATE_CODE"/></STATE_CODE>
<COUNTRY_CODE> <xsl:value-of select="$address/COUNTRY_CODE"/></COUNTRY_CODE>
<COUNTRY> <xsl:value-of select="$address/COUNTRY"/></COUNTRY>
</ADDRESS>
</INVOICEE>
</INV_PARTIES>
<INV_QUALIFIER><xsl:value-of select="$head/INVOICE_QUALIFIER"/></INV_QUALIFIER>
</HEAD>
<DETAILS>
7
<xsl:for-each select="INVOICE_DETAILS/INVOICE_DETAIL">
<xsl:variable name="inv_detail" select="." />
<INV_DETAIL>
<A_LINE><xsl:value-of select="$inv_detail/@LINE"/></A_LINE>
<A_TYP> <xsl:value-of select="$inv_detail/@TYP" /></A_TYP>
<CUSTOMER>
<xsl:variable name="customer" select="$inv_detail/CUSTOMER" />
<CARDNUMBER> <xsl:value-of select="$customer/CARDNUMBER"/></CARDNUMBER>
<NAME> <xsl:value-of select="$customer/NAME"/></NAME>
</CUSTOMER>
<SERVICE_PROV>
<xsl:variable name="service_prov" select="$inv_detail/SERVICE_PROVIDER" />
<CODE> <xsl:value-of select="$service_prov/CODE"/></CODE>
<COMPANYNAME> <xsl:value-of select="$service_prov/COMPANYCODE"/></COMPANYNAME>
<STREET> <xsl:value-of select="$service_prov/STREET"/></STREET>
<PLACE> <xsl:value-of select="$service_prov/PLACE"/></PLACE>
<TAX_CODE> <xsl:value-of select="$service_prov/TAX_CODE"/></TAX_CODE>
</SERVICE_PROV>
<CUSTOMER_DAT>
<xsl:variable name="customer_dat" select="$inv_detail/CUSTOMER_DATA" />
<PERSONAL_ID> <xsl:value-of select="$customer_dat/PERSONAL_ID"/></PERSONAL_ID>
<DEP_CODE> <xsl:value-of select="$customer_dat/DEPARTMENT_CODE"/></DEP_CODE>
<COST_CENTER> <xsl:value-of select="$customer_dat/COST_CENTER"/></COST_CENTER>
<ACC_UNIT> <xsl:value-of select="$customer_dat/ACCOUNTING_UNIT"/></ACC_UNIT>
<ACC_NUMBER> <xsl:value-of select="$customer_dat/ACCOUNT_NUMBER"/></ACC_NUMBER>
<FILE_DATE> <xsl:value-of select="$customer_dat/FILE_DATE"/></FILE_DATE>
<PROJ_NUMBER> <xsl:value-of select="$customer_dat/PROJECT_NUMBER"/></PROJ_NUMBER>
<ORDER_NUMBER> <xsl:value-of select="$customer_dat/ORDER_NUMBER"/></ORDER_NUMBER>
<ACTION_CODE> <xsl:value-of select="$customer_dat/ACTION_CODE"/></ACTION_CODE>
<DESTINATION> <xsl:value-of select="$customer_dat/DESTINATION"/></DESTINATION>
<TXN_REF> <xsl:value-of select="$customer_dat/TXN_REF"/></TXN_REF>
<CUST_REF> <xsl:value-of select="$customer_dat/CUSTOMER_REF"/></CUST_REF>
<DOM_TAG> <xsl:value-of select="$customer_dat/DOM_TAG"/></DOM_TAG>
</CUSTOMER_DAT>
<SALE_VALUES>
<xsl:variable name="sale_values" select="$inv_detail/SALE_VALUES" />
<A_SALE_TO_BASE_RATE><xsl:value-of select="$sale_values/@SALE_TO_BASE_RATE"
/></A_SALE_TO_BASE_RATE>
<CURRENCY> <xsl:value-of select="$sale_values/CURRENCY"/></CURRENCY>
<NET_VALUE> <xsl:value-of select="$sale_values/NET_VALUE"/></NET_VALUE>
<VAT_VALUE> <xsl:value-of select="$sale_values/VAT_VALUE"/></VAT_VALUE>
<GROSS_VALUE> <xsl:value-of select="$sale_values/GROSS_VALUE"/></GROSS_VALUE>
<ADD_INS_VAL> <xsl:value-of
select="$sale_values/ADDITIONAL_INSURANCE_VALUE"/></ADD_INS_VAL>
<LINE_GROSS_VAL><xsl:value-of
select="$sale_values/LINE_GROSS_VALUE"/></LINE_GROSS_VAL>
<xsl:variable name="vat_sum" select="$sale_values/VAT_SUMMARY" />
<xsl:for-each select="$sale_values/VAT_SUMMARY">
8
<VAT_SUM>
</VAT_SUM></xsl:for-each>
</SALE_VALUES>
<BILL_VALUES>
<xsl:variable name="bill_values" select="$inv_detail/BILLING_VALUES" />
<CURRENCY> <xsl:value-of select="$bill_values/CURRENCY"/></CURRENCY>
<NET_VALUE> <xsl:value-of select="$bill_values/NET_VALUE"/></NET_VALUE>
<VAT_VALUE> <xsl:value-of select="$bill_values/VAT_VALUE"/></VAT_VALUE>
<GROSS_VALUE> <xsl:value-of select="$bill_values/GROSS_VALUE"/></GROSS_VALUE>
<ADD_INS_VAL> <xsl:value-of
select="$bill_values/ADDITIONAL_INSURANCE_VALUE"/></ADD_INS_VAL>
<LINE_GROSS_VAL><xsl:value-of
select="$bill_values/LINE_GROSS_VALUE"/></LINE_GROSS_VAL>
<xsl:for-each select="$bill_values/VAT_SUMMARY">
<xsl:variable name="vat_sum" select="$bill_values/VAT_SUMMARY" />
<VAT_SUM>
</VAT_SUM></xsl:for-each>
</BILL_VALUES>
<DET_DESCRIP>
<xsl:for-each
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION">
<DETAIL_DESC>
<A_LINE><xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/@LINE" /></A_LINE>
<SALES_PROV>
<AGENCY> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SALES_PROVIDER/AGENCY"
/></AGENCY>
<BRANCH> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SALES_PROVIDER/BRANCH"
/></BRANCH>
</SALES_PROV>
<SALE_VAL>
<A_SALE_TO_BASE_RATE><xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SALE_VALUES/@SALE_TO_B
ASE_RATE" /></A_SALE_TO_BASE_RATE>
9
<CURRENCY> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SALE_VALUES/CURRENCY"/
></CURRENCY>
<NET_VALUE> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SALE_VALUES/NET_VALUE"
/></NET_VALUE>
<VAT_VALUE> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SALE_VALUES/VAT_VALUE"
/></VAT_VALUE>
<GROSS_VALUE> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SALE_VALUES/GROSS_VALU
E"/></GROSS_VALUE>
<ADD_INS_VAL> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SALE_VALUES/ADDITIONAL
_INSURANCE_VALUE"/></ADD_INS_VAL>
<LINE_GROSS_VAL><xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SALE_VALUES/LINE_GROSS
_VALUE"/></LINE_GROSS_VAL>
<VAT_SUM>
<xsl:for-each select="">
<VAT_VALUE><xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SALE_VALUES/VAT_SUMMAR
Y/VAT_VALUE"/></VAT_VALUE>
</xsl:for-each>
<xsl:for-each select="">
<NET_VALUE><xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SALE_VALUES/VAT_SUMMAR
Y/NET_VALUE"/></NET_VALUE>
</xsl:for-each>
</VAT_SUM>
</SALE_VAL>
<BILL_VAL>
<CURRENCY> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/BILLING_VALUES/CURRENC
Y"/></CURRENCY>
<NET_VALUE> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/BILLING_VALUES/NET_VAL
UE"/></NET_VALUE>
<VAT_VALUE> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/BILLING_VALUES/VAT_VAL
UE"/></VAT_VALUE>
<GROSS_VALUE> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/BILLING_VALUES/GROSS_V
ALUE"/></GROSS_VALUE>
<ADD_INS_VAL> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/BILLING_VALUES/ADDITIO
NAL_INSURANCE_VALUE"/></ADD_INS_VAL>
<LINE_GROSS_VAL><xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/BILLING_VALUES/LINE_GR
OSS_VALUE"/></LINE_GROSS_VAL>
<VAT_SUM>
<A_RATE><xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/BILLING_VALUES/VAT_SUM
MARY/@RATE" /></A_RATE>
10
<xsl:for-each select="">
<VAT_VALUE><xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/BILLING_VALUES/VAT_SUM
MARY/VAT_VALUE"/></VAT_VALUE>
</xsl:for-each>
<xsl:for-each select="">
<NET_VALUE><xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/BILLING_VALUES/VAT_SUM
MARY/NET_VALUE"/></NET_VALUE>
</xsl:for-each>
</VAT_SUM>
</BILL_VAL>
<SERV_DESC>
<DATE> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/DA
TE"/></DATE>
<DOC_NUMBER> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/DO
CUMENT_NUMBER"/></DOC_NUMBER>
<VOUCHER_NUMBER> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/VO
UCHER_NUMBER"/></VOUCHER_NUMBER>
<CC_CODE> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/CC
_CODE"/></CC_CODE>
<CLASS> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/CL
ASS"/></CLASS>
<TXN_TYPE_DETAIL><xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/TX
N_TYPE_DETAIL"/></TXN_TYPE_DETAIL>
<ETIX_QUAL> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/ET
IX_QUALIFIER"/></ETIX_QUAL>
<FLIGHT_TAX> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/FL
IGHT_TAX"/></FLIGHT_TAX>
<A_ADD_INFO_LINE><xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/AD
DITIONAL_INFO/@LINE"/></A_ADD_INFO_LINE>
<xsl:for-each
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/AD
DITIONAL_INFO">
<ADD_INFO> <xsl:value-of select="."/></ADD_INFO>
</xsl:for-each>
<DB_TRAVEL_DATA>
<START_STATION> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/DB
_TRAVEL_DATA/START_STATION"/></START_STATION>
<DEST_STATION> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/DB
_TRAVEL_DATA/DEST_STATION"/></DEST_STATION>
11
<DB_CLASS> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/DB
_TRAVEL_DATA/DB_CLASS"/></DB_CLASS>
<ADULTS> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/DB
_TRAVEL_DATA/ADULTS"/></ADULTS>
<CHILDREN> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/DB
_TRAVEL_DATA/CHILDREN"/></CHILDREN>
</DB_TRAVEL_DATA>
<HT_BOOK_DATA>
<START_DATE> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/HT
_BOOKING_DATA/START_DATE"/></START_DATE>
<END_DATE> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/HT
_BOOKING_DATA/END_DATE"/></END_DATE>
<AMOUNT> <xsl:value-of
select="INVOICE_DETAILS/INVOICE_DETAIL/DETAIL_DESCRIPTIONS/DETAIL_DESCRIPTION/SERVICE_DESCRIPTION/HT
_BOOKING_DATA/AMOUNT"/></AMOUNT>
</HT_BOOK_DATA>
</SERV_DESC>
</DETAIL_DESC>
</xsl:for-each>
</DET_DESCRIP>
</INV_DETAIL>
</xsl:for-each>
</DETAILS>
<!--
NUMBER_OF_INVOICE_DETAIL
<xsl:for-each select="INVOICE_SUMMARY/TOTAL_SALE_VALUES/VAT_SUMMARY">
</xsl:for-each>
<xsl:for-each select="INVOICE_SUMMARY/TOTAL_BILLING_VALUES/VAT_SUMMARY">
<xsl:attribute name="NUMBER_OF_INVOICE_DETAIL" >
</xsl:attribute>
<xsl:attribute name="RATE" ></xsl:attribute>
-->
<SUMMARY>
<xsl:variable name="summary" select="INVOICE_SUMMARY" />
<A_NUM_INV_DET><xsl:value-of select="$summary/@NUMBER_OF_INVOICE_DETAIL"
/></A_NUM_INV_DET>
<xsl:for-each select="$summary/TOTAL_SALE_VALUES">
<TOTAL_SALE_VALUES>
<xsl:variable name="total_sale_values" select="$summary" />
<A_CURRENCY><xsl:value-of select="$total_sale_values/@CURRENCY"/></A_CURRENCY>
<NET_TOTAL> <xsl:value-of select="$total_sale_values/NET_TOTAL"/></NET_TOTAL>
<VAT_TOTAL> <xsl:value-of select="$total_sale_values/VAT_TOTAL"/></VAT_TOTAL>
<xsl:for-each select="INVOICE_SUMMARY/TOTAL_SALE_VALUES/VAT_SUMMARY">
12
<VAT_SUM>
<xsl:variable name="vat_sum" select="$total_sale_values/VAT_SUMMARY" />
<A_RATE><xsl:value-of select="$vat_sum/@RATE" /></A_RATE>
<NET_VALUE><xsl:value-of select="."/></NET_VALUE>
<VAT_VALUE><xsl:value-of select="."/></VAT_VALUE>
</VAT_SUM></xsl:for-each>
</TOTAL_SALE_VALUES>
</xsl:for-each>
<TOTAL_BILL_VALUES>
<NET_TOTAL> <xsl:value-of
select="INVOICE_SUMMARY/TOTAL_BILLING_VALUES/NET_TOTAL"/></NET_TOTAL>
<VAT_TOTAL> <xsl:value-of
select="INVOICE_SUMMARY/TOTAL_BILLING_VALUES/VAT_TOTAL"/></VAT_TOTAL>
<VAT_SUM>
<A_RATE><xsl:value-of
select="INVOICE_SUMMARY/TOTAL_BILLING_VALUES/VAT_SUMMARY/@RATE" /></A_RATE>
<xsl:for-each
select="INVOICE_SUMMARY/TOTAL_BILLING_VALUES/VAT_SUMMARY/NET_VALUE">
<NET_VALUE><xsl:value-of select="."/></NET_VALUE>
</xsl:for-each>
<xsl:for-each
select="INVOICE_SUMMARY/TOTAL_BILLING_VALUES/VAT_SUMMARY/VAT_VALUE">
<VAT_VALUE><xsl:value-of select="."/></VAT_VALUE>
</xsl:for-each>
</VAT_SUM>
<ADD_INS_VAL> <xsl:value-of
select="INVOICE_SUMMARY/TOTAL_BILLING_VALUES/ADDITIONAL_INSURANCE_TOTAL"/></ADD_INS_VAL>
<TOTAL_BILL_AMOUNT> <xsl:value-of
select="INVOICE_SUMMARY/TOTAL_BILLING_VALUES/TOTAL_BILLING_AMOUNT"/></TOTAL_BILL_AMOUNT>
</TOTAL_BILL_VALUES>
</SUMMARY>
</INVOICE_BTM>
</xsl:for-each>
</XML_OUTPUT>
</asx:values>
</asx:abap>
</xsl:template>
</xsl:transform>
XSLT options
Here are the relevant XSLT elements in order of you could need it in your own program. For a good XSLT
reference look at W3Schools.com - reference. In a XSLT program it is also possible to to write comments
with the standard HTML commentfunction "<!>".
13
<xsl:value-of>
to catch the value from the element/attribute and move it to the ABAP variable
<ABAP_FIELD>
</ABAP_FIELD>
<xsl:for-each>
use this element to make loops over your XML Tags, maybe if you have more than one XML tag (street) in
your XML-File
<xsl:for-each select="INVOICE/PARTNER/ADDRESS/street">
</xsl:for-each>
<xsl:variable>
create a variable for access to the XML element. It is just a nice shortcut. Note that you can close this XSL
element it self, look at the slash before the >
</xsl:for-each>
14
<PAYEE>
<PARTYCODE>LASG</PARTYCODE>
<ADDRESS>
<ADDRESSLINE LINE="1">Lufthansa AirPlus
Servicekarten GmbH</ADDRESSLINE>
<ADDRESSLINE LINE="2">Postfach
1552</ADDRESSLINE>
<POST_CODE>63235</POST_CODE>
<CITY>Neu-Isenburg</CITY>
<COUNTRY_CODE>D</COUNTRY_CODE>
<COUNTRY>Deutschland</COUNTRY>
</ADDRESS>
</PAYEE>
<INVOICEE>
<BILLING_LEVEL>122000201089999</BILLING_LEVEL>
<PARTYCODE>DTA9999</PARTYCODE>
<ADDRESS>
<ADDRESSLINE LINE="1">Test Company
GmbH</ADDRESSLINE>
<ADDRESSLINE LINE="2">Frau Verthika
Kaur</ADDRESSLINE>
<ADDRESSLINE LINE="3">Frankfurter Str.
9</ADDRESSLINE>
<POST_CODE>63233</POST_CODE>
<CITY>Oberursel</CITY>
</ADDRESS>
</INVOICEE>
</INVOICE_PARTIES>
<INVOICE_QUALIFIER>TEST</INVOICE_QUALIFIER>
</INVOICE_HEAD>
<INVOICE_DETAILS>
<INVOICE_DETAIL LINE="1" TYP="HOTEL">
<CUSTOMER>
<CARDNUMBER>122000201089999</CARDNUMBER>
<NAME>Test Company GmbH</NAME>
</CUSTOMER>
<SERVICE_PROVIDER>
<COMPANYNAME>Steigenberger Mannheimer
Hof</COMPANYNAME>
<STREET>Augustaanlage 4 - 8</STREET>
<PLACE>Mannheim</PLACE>
<TAX_CODE>114216731</TAX_CODE>
</SERVICE_PROVIDER>
<CUSTOMER_DATA>
<DEPARTMENT_CODE>XX9823483</DEPARTMENT_CODE>
<FILE_DATE>20031230</FILE_DATE>
</CUSTOMER_DATA>
<SALES_DATE>20031230</SALES_DATE>
<PROCESSING_DATE>20040108</PROCESSING_DATE>
<ONLINE_ORDER_REF> no </ONLINE_ORDER_REF>
<SALE_VALUES SALE_TO_BASE_RATE="1.00000">
<CURRENCY>EUR</CURRENCY>
<NET_VALUE>235.55</NET_VALUE>
<VAT_VALUE>88.33</VAT_VALUE>
<GROSS_VALUE>980.50</GROSS_VALUE>
15
<VAT_SUMMARY RATE="16.00">
<NET_VALUE>616.16</NET_VALUE>
<VAT_VALUE>016.32</VAT_VALUE>
</VAT_SUMMARY>
<VAT_SUMMARY RATE="32.00">
<NET_VALUE>632.32</NET_VALUE>
<VAT_VALUE>032.48</VAT_VALUE>
</VAT_SUMMARY>
</SALE_VALUES>
<BILLING_VALUES>
<NET_VALUE>845.25</NET_VALUE>
<VAT_VALUE>135.25</VAT_VALUE>
<GROSS_VALUE>980.50</GROSS_VALUE>
<ADDITIONAL_INSURANCE_VALUE>0.00</ADDITIONAL_INSURANCE_VALUE>
<LINE_GROSS_VALUE>980.50</LINE_GROSS_VALUE>
<VAT_SUMMARY RATE="11.00">
<NET_VALUE>111.11</NET_VALUE>
<VAT_VALUE>011.22</VAT_VALUE>
</VAT_SUMMARY>
<VAT_SUMMARY RATE="22.00">
<NET_VALUE>222.22</NET_VALUE>
<VAT_VALUE>022.33</VAT_VALUE>
</VAT_SUMMARY>
<VAT_SUMMARY RATE="33.00">
<NET_VALUE>333.33</NET_VALUE>
<VAT_VALUE>033.44</VAT_VALUE>
</VAT_SUMMARY>
</BILLING_VALUES>
<DETAIL_DESCRIPTIONS NUMBER_OF_DETAIL_DESCRIPTIONS="5">
<DETAIL_DESCRIPTION LINE="1">
<SALE_VALUES SALE_TO_BASE_RATE="1.00000">
<NET_VALUE>180.17</NET_VALUE>
<VAT_VALUE>28.83</VAT_VALUE>
<GROSS_VALUE>209.00</GROSS_VALUE>
<VAT_SUMMARY RATE="16.00">
<NET_VALUE>180.17</NET_VALUE>
<VAT_VALUE>28.83</VAT_VALUE>
</VAT_SUMMARY>
</SALE_VALUES>
<SERVICE_DESCRIPTION>
<DATE>20031211</DATE>
<DOCUMENT_NUMBER>00255999</DOCUMENT_NUMBER>
<VOUCHER_NUMBER>00204999</VOUCHER_NUMBER>
<TXN_TYPE_DETAIL>V</TXN_TYPE_DETAIL>
<ADDITIONAL_INFO
LINE="1">Restaurant Avalon Getränk</ADDITIONAL_INFO>
<ADDITIONAL_INFO
LINE="2">Rechnung#000400010999</ADDITIONAL_INFO>
<HT_BOOKING_DATA>
<START_DATE>20031211</START_DATE>
16
<END_DATE>20031212</END_DATE>
<AMOUNT>9</AMOUNT>
</HT_BOOKING_DATA>
</SERVICE_DESCRIPTION>
</DETAIL_DESCRIPTION>
<DETAIL_DESCRIPTION LINE="2">
<SALE_VALUES SALE_TO_BASE_RATE="1.00000">
<NET_VALUE>172.41</NET_VALUE>
<VAT_VALUE>27.59</VAT_VALUE>
<GROSS_VALUE>200.00</GROSS_VALUE>
<VAT_SUMMARY RATE="16.00">
<NET_VALUE>172.41</NET_VALUE>
<VAT_VALUE>27.59</VAT_VALUE>
</VAT_SUMMARY>
</SALE_VALUES>
<SERVICE_DESCRIPTION>
<DATE>20031211</DATE>
<DOCUMENT_NUMBER>00255999</DOCUMENT_NUMBER>
<VOUCHER_NUMBER>00204999</VOUCHER_NUMBER>
<TXN_TYPE_DETAIL>V</TXN_TYPE_DETAIL>
<ADDITIONAL_INFO
LINE="1">Restaurant Avalon Speisen</ADDITIONAL_INFO>
<ADDITIONAL_INFO
LINE="2">Rechnung#000400010999</ADDITIONAL_INFO>
<HT_BOOKING_DATA>
<START_DATE>20031211</START_DATE>
<END_DATE>20031212</END_DATE>
<AMOUNT>9</AMOUNT>
</HT_BOOKING_DATA>
</SERVICE_DESCRIPTION>
</DETAIL_DESCRIPTION>
<DETAIL_DESCRIPTION LINE="3">
<SALE_VALUES SALE_TO_BASE_RATE="1.00000">
<NET_VALUE>95.26</NET_VALUE>
<VAT_VALUE>15.24</VAT_VALUE>
<GROSS_VALUE>110.50</GROSS_VALUE>
<VAT_SUMMARY RATE="16.00">
<NET_VALUE>95.26</NET_VALUE>
<VAT_VALUE>15.24</VAT_VALUE>
</VAT_SUMMARY>
</SALE_VALUES>
<SERVICE_DESCRIPTION>
<DATE>20031211</DATE>
<DOCUMENT_NUMBER>00255999</DOCUMENT_NUMBER>
<VOUCHER_NUMBER>00204999</VOUCHER_NUMBER>
<TXN_TYPE_DETAIL>V</TXN_TYPE_DETAIL>
17
<ADDITIONAL_INFO
LINE="1">Restaurant Avalon Getränk</ADDITIONAL_INFO>
<ADDITIONAL_INFO
LINE="2">Rechnung#000400010999</ADDITIONAL_INFO>
<HT_BOOKING_DATA>
<START_DATE>20031211</START_DATE>
<END_DATE>20031212</END_DATE>
<AMOUNT>9</AMOUNT>
</HT_BOOKING_DATA>
</SERVICE_DESCRIPTION>
</DETAIL_DESCRIPTION>
<DETAIL_DESCRIPTION LINE="4">
<SALE_VALUES SALE_TO_BASE_RATE="1.00000">
<NET_VALUE>25.00</NET_VALUE>
<VAT_VALUE>4.00</VAT_VALUE>
<GROSS_VALUE>29.00</GROSS_VALUE>
<VAT_SUMMARY RATE="16.00">
<NET_VALUE>25.00</NET_VALUE>
<VAT_VALUE>4.00</VAT_VALUE>
</VAT_SUMMARY>
</SALE_VALUES>
<SERVICE_DESCRIPTION>
<DATE>20031212</DATE>
<DOCUMENT_NUMBER>00255999</DOCUMENT_NUMBER>
<VOUCHER_NUMBER>00204999</VOUCHER_NUMBER>
<TXN_TYPE_DETAIL>V</TXN_TYPE_DETAIL>
<ADDITIONAL_INFO
LINE="1">Restaurant Avalon Getränk</ADDITIONAL_INFO>
<ADDITIONAL_INFO
LINE="2">Rechnung#000500009999</ADDITIONAL_INFO>
<HT_BOOKING_DATA>
<START_DATE>20031211</START_DATE>
<END_DATE>20031212</END_DATE>
<AMOUNT>9</AMOUNT>
</HT_BOOKING_DATA>
</SERVICE_DESCRIPTION>
</DETAIL_DESCRIPTION>
<DETAIL_DESCRIPTION LINE="5">
<SALE_VALUES SALE_TO_BASE_RATE="1.00000">
<NET_VALUE>372.41</NET_VALUE>
<VAT_VALUE>59.59</VAT_VALUE>
<GROSS_VALUE>432.00</GROSS_VALUE>
<VAT_SUMMARY RATE="16.00">
<NET_VALUE>372.41</NET_VALUE>
<VAT_VALUE>59.59</VAT_VALUE>
</VAT_SUMMARY>
</SALE_VALUES>
<SERVICE_DESCRIPTION>
18
<DATE>20031220</DATE>
<DOCUMENT_NUMBER>00255894</DOCUMENT_NUMBER>
<VOUCHER_NUMBER>00204401</VOUCHER_NUMBER>
<TXN_TYPE_DETAIL>V</TXN_TYPE_DETAIL>
<ADDITIONAL_INFO
LINE="1">Tagespauschale</ADDITIONAL_INFO>
<ADDITIONAL_INFO
LINE="2">12.12.03</ADDITIONAL_INFO>
<HT_BOOKING_DATA>
<START_DATE>20031211</START_DATE>
<END_DATE>20031212</END_DATE>
<AMOUNT>9</AMOUNT>
</HT_BOOKING_DATA>
</SERVICE_DESCRIPTION>
</DETAIL_DESCRIPTION>
</DETAIL_DESCRIPTIONS>
</INVOICE_DETAIL>
</INVOICE_DETAILS>
<INVOICE_SUMMARY NUMBER_OF_INVOICE_DETAIL="00001">
<TOTAL_SALE_VALUES CURRENCY="EUR">
<NET_TOTAL>845.25</NET_TOTAL>
<VAT_TOTAL>135.25</VAT_TOTAL>
<VAT_SUMMARY RATE="16.00">
<NET_VALUE>845.25</NET_VALUE>
<VAT_VALUE>135.25</VAT_VALUE>
</VAT_SUMMARY>
<VAT_SUMMARY RATE="15.00">
<NET_VALUE>745.15</NET_VALUE>
<VAT_VALUE>035.15</VAT_VALUE>
</VAT_SUMMARY>
</TOTAL_SALE_VALUES>
<TOTAL_BILLING_VALUES>
<NET_TOTAL>845.25</NET_TOTAL>
<VAT_TOTAL>135.25</VAT_TOTAL>
<VAT_SUMMARY RATE="16.00">
<NET_VALUE>845.25</NET_VALUE>
<VAT_VALUE>135.25</VAT_VALUE>
</VAT_SUMMARY>
<TOTAL_BILLING_AMOUNT>980.50</TOTAL_BILLING_AMOUNT>
</TOTAL_BILLING_VALUES>
</INVOICE_SUMMARY>
</INVOICE_BTM>
</INVOICES_BTM>
19