1

SAP TechEd ‘04
ABAP 252:
ABAP – XML Mapping
2
SAP TechEd ‘04
Peter McNulty, SAP Labs
Karsten Bohlmann, SAP AG
Christoph Wedler, SAP AG
3
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 3
Learning Objectives
As a result of this workshop, you will:
Þ learn about the role of XML in open system integration
(e.g. in Web Services)
Þ know the ABAP tools for basic XML processing
Þ understand SAP’s approach to data / XML mapping
(in relation to other approaches, e.g. JAXB)
Þ be able to write mappings between ABAP data structures
and XML …
4 … using XSLT
4 … using Simple Transformations
Þ know when to use what
4
SAP TechEd ‘04
Intro
XML in Open Systems
XML in ABAP
ABAP – XML Mapping: Concepts
ABAP – XML Mapping with XSLT
Simple Transformations
Summary
5
SAP TechEd ‘04
Intro
XML in Open Systems
XML in ABAP
ABAP – XML Mapping: Concepts
ABAP – XML Mapping with XSLT
Simple Transformations
Summary
6
SAP TechEd ‘04
Intro
XML in Open Systems
XML in ABAP
ABAP – XML Mapping: Concepts
ABAP – XML Mapping with XSLT
Simple Transformations
Summary
7
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 7
From HTML to XML
The Web is evolving …
Þ … from HTML – a fixed language for human viewing
Þ … to XML – a generic language for machine processing
Þ People navigate through information in the form of
HTML documents.
HTML
HTML
HTML
XML
XML
XML
Þ Machines exchange data and metadata in the form of XML
documents.
Þ If information is data with a meaning (interpreted data), then the enrichment of data
with metadata in XML can be seen as an attempt to approximate information.
Þ Nevertheless, an XML document means nothing, regardless of the amount of
metadata, without a data processing system interpreting it correctly.
Þ Hence, we are interested in uses of XML that support automated processing of
data based on application-specific metadata.
8
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 8
Example: Slashdot.org
RSS feed (news syndication)
URI in:
http://slashdot.org/it.rss
XML out:
as HTML
Set up system
reports as RSS
feeds …
…more effective viewing with RSS aggregators
Þ “RSS” stands for “RDF Site Summary” (or a few other meanings, depending on the
version level). RDF, the Resource Description Framework, is an XML based
language for metadata.
Þ An RSS reader, or aggregator, supports more effective ways of monitoring a
personal set of RSS feeds than can be achieved by manually tracking web pages
with a normal HTML browser.
Þ There is a large number of RSS aggregators, many of them freely available. A free
reader for Windows is the Sharp Reader (http://www.sharpreader.net/index.html).
Þ The predominant application area of RSS at the moment is news and weblogs. For
example, the SAP Developer Network has extensive RSS support – see
https://weblogs.sdn.sap.com/pub/q/weblogs_rss?x-ver=1.0.
Þ However, the extensible nature of RSS 1.0 qualifies it for many kinds of summary /
reporting tasks. Using BSP (Business Server Pages) or HTTP directly, you could
export regular system reports (e.g. batch logs) from your WebAS in RSS format.
9
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 9
Example: Xignite Financial Web Services
Realtime currency exchange rates
URI in:
http://www.xignite.com/xCurrencies.asmx/GetRealTimeCrossRateTable?
Symbols=USD%2CEUR%2CJPY%2CGBP&InvokeButton=Invoke&
xMethod=GET
XML out:
Call a
business
service from
ABAP …
Or offer one.
10
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 10
Example: Amazon Web Services
Transactions on the Amazon marketplace
URI in:
http://xml.amazon.com/onca/xml3?locale=us&t=te&dev-t=te
&KeywordSearch=ABAP&mode=books&sort=+daterank
&offer=All&type=lite&page=1&f=xml
XML out:
Retrieval: GET
Change: POST
Þ Amazon Web Services are offered both in RPC style (SOAP) and REST style. The
REST (REpresentational State Transfer) style is simply the well-known interaction
pattern of the web, based on URIs and XML (instead of HTML).
11
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 11
XML from a Programmer‘s Perspective (1)
From a programmer’s perspective, XML is ...
Þ a generic data model (“XML Infoset”) for trees with
Þ ordered, structured nodes (“elements”)
Þ unordered, unstructured nodes (“attributes”)
Þ a generic syntax (“markup”) for representation of trees
Þ the basis for an open set of standards and tools
Þ parsing: text ➠tree; rendering: tree ➠text
Þ typing, validating: XSchema, RELAX NG
Þ querying, transforming: XPath, XSLT
¬ a generic data structure concept for programming languages
Þ primitive: DOM, SAX
Þ data binding: JAXB
Þ For all kinds of processing except input/output, XML documents should be thought
of in terms of the data model, not in terms of their textual representation. I.e., trees
of nodes, not sequences of tags.
Þ The XML Information Set is the data model defined along with XML itself.
Unfortunately, there are slight variations in the data models used by other XML
standards. The XPath data model is very similar, but not identical to the XML
Infoset.
Þ The DOM is not a data model, but an object-oriented interface to another variation
of the XML Infoset.
Þ Though XML is “generic”, it is not a completely general model of trees. In particular,
it lacks the concept of unordered, structured nodes. (I.e., there are no structured
attributes.)
Þ JAXB is available as part of the Java Web Services Developer Pack (WSDP) 1.4
(http://java.sun.com/xml/jaxb/). Version 2.0 is being developed through the Java
Community Process
SM
program under JSR-222.
12
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 12
XML from a Programmer‘s Perspective (2)
Reasons for using XML
Þ handle document-like data (e.g. forms)
Þ represent data under heavy schema evolution
Þ extensibility, flexibility, persistence
Þ combine heterogeneous data
Þ "framework" applications, middleware, ...
Þ platform-independent modeling
Þ "repositories", e.g. SAP WebDynpro
Þ ignorance / abuse
Þ too lazy to design & implement adequate object model
...
Þ open communication format
Þ Document-like data typically have a heterogeneous, flexible structure which is hard
to capture with an object model.
Þ "Schema evolution" means that the structures of an application tend to change
perpetually. This is also hard to capture with an object model, especially across
multiple systems.
Þ The mechanism of XML Namespaces supports the combination of data from
several application areas. E.g., an XML based message middleware typically
defines an "envelope" consisting of a few elements in its own namespace in which
arbitrary content may be enclosed.
Þ An application that uses XML extensively as a platform-independent modeling
language is SAP WebDynpro: Both ABAP and Java classes are generated from the
same XML source.
13
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 13
XML from a Programmer‘s Perspective (3)
Using XML
Þ Problems solved
Þ standard syntax
Þ standard tools
Þ can model almost anything
Þ Problems gained
Þ performance drain
Þ no semantics
Þ unclear relationship with data structures (data conversion)
¬Part II (XML from/to ABAP)
Þ schema inflation
4 "Business ML" by standards body X
4 "Business ML" by vendor Y
4 Proprietary format by application Z
need for
transformations
Þ Co-existence of different schemas for the same application area is inevitable.
Therefore, XML-to-XML transformations must occur in communication middleware
or at XML-based interfaces.
Þ Data structures in application-language interfaces can also be considered
"schemas", leading to XML-to-data / data-to-XML transformations.
14
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 14
Transforming XML with XSLT (1)
Tree transformations with XSLT
(a) XML tree to XML tree (data-centric)
(b) XML tree to text (document-centric)
XML Tree
...
... ...
......
...
...
HTML / Text
(b)
XML Tree
(a)
XSLT
Þ Data-centric tree transformations: XML ¯XML
4 adapt different XML formats
4 e.g. in B2B scenarios, “message brokering”
Þ Document-centric tree transformations: XML = HTML / WML / Text
4 e.g. produce HTML in Business Server Pages (BSP)
4 e.g. generate program sources from an XML repository
Þ In a data-centric application, both source and result represent data, usually not
intended for direct viewing by a user. The goal of the transformation is to obtain data
in a different format.
In a document-centric transformation, the source is either data or a document in an
abstract format; the result is a document in a concrete format.
The development of XSL was originally motivated by document-centric applications,
hence the term “stylesheet”. Then it was recognized that the structure-transforming
part of XSL was useful by itself, and it was separated as XSLT.
15
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 15
Transforming XML with XSLT (2)
XSLT* is ...
Þ a high-level tree-transformation language
Þ with XML syntax
Þ declarative
Þ no "state"
Þ rule-based
Þ pattern matching against source tree
Þ functional
Þ source tree navigation by XPath expressions
Þ compositional
Þ result tree construction by XSLT instructions mixed with
literal XML fragments
Þ "the SQL of the Web"
* "Extensible Stylesheet Language / Transformations"
Þ XSLT (http://www.w3.org/TR/xslt) and XPath (http://www.w3.org/TR/xpath) are
W3C recommendations, current version 1.0 from 11/1999.
XSLT 2.0 (quite stable) and XPath 2.0 (not stable) are under development
(Working Draft 07/2004).
Þ “Declarative” means: Say what you want to do, not how you want to do it. The
fundamental operation is function [“template”] invocation, not variable assignment.
Þ “Rule-based” means: In any given context, the XSLT engine picks the appropriate
transformation rule from the program (by matching the context against the rule’s
pattern) and instantiates it, using the rule body as a template.
Þ XSLT’s concrete syntax is in XML format. Clumsy to write, but this way
4 it mixes conveniently with XML result fragments
4 XSLT can be processed (esp.: generated) by XSLT
Þ Unnecessarily, there is another XML query language, XQuery, under development
by the W3C. Anything done in that language could also be done in XSLT / XPath or
in natural extensions thereof.
16
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 16
Transforming XML with XSLT (3)
book
editor
last first
name
chapter
section
author
section
chapter
Smith John
book book
head = The Pain of DOM Programming
XPath example: tree navigation
book[editor[name/last='Smith' and name/first='John']]
//section[contains(@head,'DOM')]
/ancestor::chapter[1]/author
Þ XPath is a simple expression language with non-XML syntax.
Þ The basic types of values on which XPath operates are: String, number, boolean,
and nodeset. A nodeset is an unordered, duplicate-free collection of nodes from an
XML document. XPath and XSLT deal only with the semantic values of XML
documents (trees), not with their textual representations.
Þ The most important type of XPath expression is the location path, which evaluates
to a nodeset. A location path consists of a sequence of location steps. A location
step consists of an axis (e.g. child, parent, following-sibling), a node test, and
optional predicates. The default axis is child, so the expression book yields all
children of the current node named “book”.
Þ The location path in the example contains ten location steps, six of which are
nested in predicates. It finds all authors of chapters in books edited by John Smith
which contain a section whose heading contains the phrase “DOM”.
17
SAP TechEd ‘04
Intro
XML in Open Systems
XML in ABAP
ABAP – XML Mapping: Concepts
ABAP – XML Mapping with XSLT
Simple Transformations
Summary
18
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 18
XML in ABAP: iXML Package (1)
The iXML package (since 4.6D): features
Þ implemented in kernel (C++)
Þ encapsulated in ABAP proxy classes
Þ general XML parser / renderer
Þ event-based parser (~ SAX)
Þ DOM (Document Object Model)
Þ superset of DOM level 1 (incl. XML namespaces)
Þ Validation
Þ DTD (since 6.10)
Þ not XMLSchema
Þ The iXML library is implemented in the SAP kernel and is made available in ABAP
Objects by means of ABAP proxy classes. Parsing is fast because it is done
completely in the kernel. ABAP objects corresponding to DOM nodes are not
created until they are accessed from ABAP.
19
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 19
XML in ABAP: iXML Package (2)
iXML interfaces in ABAP Objects
Þ OO design: interfaces, inheritance, factories
Þ main factory class CL_IXML
Þ ~40 Interfaces
IF_IXML_PARSER, IF_IXML_NODE, ...
Þ documentation: SAP Library
[ →“SAP NetWeaver Components” ]
→“SAP Web Application Server”
→“Basis Services / Communication”
→“XML Library”
Þ used by many SAP applications
Þ The design of the iXML package is completely object oriented. In particular,
interfaces, inheritance and the factory pattern are frequently used. The main factory
interface IF_IXML is the origin (direct or indirect) of all iXML objects.
Þ The iXML main factory class implements the singleton pattern; i.e., when the call
cl_ixml=>create( )is done repeatedly, it yields the same object.
Þ All iXML objects are integrated into the general ABAP Objects garbage collection
mechanism.
Þ The SAP Library is found in the Help menu. The iXML documentation is organized
in several “packages” (DOM, Parser, Stream, etc.) and a “jumpstart” section. E.g.,
in the “DOM” package, all DOM-related interfaces (IF_IXML_ELEMENT, etc.) are
explained. The jumpstart section should be referred to for an introduction to the
concepts and services of the iXML library.
20
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 20
XML in ABAP: iXML Package (3)
iXML example programs in package SIXML_TEST
Þ parsing into a DOM: T_PARSING_DOM
Þ manipulating a DOM: T_DOM_MANIPULATE
Þ rendering a DOM: T_RENDERING_DOM
Þ validating with a DTD: T_DTD_VALIDATION
data element type ref to if_ixml_element.
element = document->create_element( name = 'date' ).
element->set_attribute(
name = 'format' value = 'yyyymmdd' ).
element->set_value( value = ldate ).
21
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 21
XML in ABAP: XSLT Processor (1)
The SAP XSLT processor (since 6.10): features
Þ performance implementation in SAP kernel (C++)
Þ scalability optimization for server-side execution
Þ interoperability with iXML package
Þ conformance (except for justified omissions)
Þ integration into language environment
call from ABAP, call back to ABAP
Þ integration into development environment
workbench, transport
Þ Scalability is essential: Performance must not degrade when the number of XSLT
programs in parallel use increases. The SAP XSLT processor is scalable because
it adopts a byte code / virtual machine approach (similar to Java and ABAP).
Þ An XSLT program is parsed and analysed only at development time. It is then
compiled into a byte code (developed by SAP specifically for XSLT) which is stored
in the database. When an XSLT program is run, the byte code is loaded and
executed on the virtual machine in the SAP kernel. An application-server-global
buffer (the same which is used for ABAP programs) prevents frequent re-loading
from the database.
22
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 22
XML in ABAP: XSLT Processor (2)
Unimplemented XSLT 1.0 features
E xsl:number
E Forwards-compatible processing, fallback processing
E Attribute sets
E Namespace aliasing
Implemented XSLT 2.0 features
E Grouping (xsl:for-each-group)
E User-defined XPath functions (xsl:function)
E Multiple results (xsl:result-document)
Extensions: namespace http://www.sap.com/sapxsl
E ABAP Calls (by extension function or extension instruction)
E many extension functions
E XPath 2.0 features
Þ Forwards-compatible processing is not supported because it is not expected that
XSLT programs using a higher XSLT version will be maintained in a SAP system
supporting a lower XSLT version.
Þ Fallback is not supported because forwards-compatible processing is not
supported, and it is not expected that XSLT programs using extension instructions
of other XSLT processors will be maintained in the SAP repository.
Þ Conversely, the SAP namespace need not be declared in extension-element-
prefixes; SAP extensions are recognized automatically.
Þ Stylesheet inclusion and import uses the sap:name attribute instead of the href
attribute in order to refer to XSLT programs (programs are in the SAP repository).
Þ Examples of extension functions: upper-case, lower-case, string-pad,
ends-with, find-first, find-first-of, find-first-not-of, find-
last, find-last-of, find-last-not-of, timestamp, otr-string, otr-
text, line, column, max, min, abs, exp, log, parse-xpath.
Þ Implemented XPath 2.0 features: generalized location paths A/(B|C); generic
namespace *:A; escaping quotes in string literals ("abc""def").
Þ Conditional expression: [ [sap:if(e0,e1,e2)] ] = if [ [e0] ] then [ [e1] ] else [ [e2] ]
Þ Variable binding: [ [sap:let(x,e1,e2)] ] = [ [e2] ] (x← [ [e1] ])
23
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 23
XML in ABAP: XSLT Processor (3)
Extension example: ABAP Call by extension function from XPath
<sap:external-function name="p:f1" method="METH">
<sap:argument param="IP_1"/>
<sap:argument param="IP_2"/>
<sap:result param="EP" type="number"/>
</sap:external-function>
At top level: Declare external function
In XPath expression: Invoke instance method on external object
<xsl:value-of select = "p:f1($obj, 42,'foo') + 1"/>
function parameter declarations
function result declaration
XSLT variable bound to ABAP object XPath parameter values
Þ The function name must use a non-reserved namespace.
Þ The attribute kind of sap:external-function specifies whether it is a class
or an instance method (default) or a constructor. For class methods and
constructors, the ABAP class is specified in the class attribute.
Þ Invocations of instance methods require an external object as first function
argument (as in the common Java binding mechanism). The object can come from
a program parameter, a constructor call, or a preceding ABAP call.
Þ Appropriate conversions are applied between XPath and ABAP values. Nodesets
correspond to iXML node collections.
Þ Multiple return values can be retrieved (less elegantly) by an extension instruction:
<sap:call-external name="obj" method="METH">
<sap:callvalue param="IP" select="42"/>
<sap:callvalue param="CP" select="'foo'"/>
<sap:callvariable param="EP" name="v1" type="number"/>
<sap:callvariable param="CP" name="v2"/>
</sap:call-external>
Here, XSLT variables v1 and v2 are bound to ABAP exporting / changing
parameters EP and CP. The variable scope is the same as for xsl:variable.
24
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 24
XML in ABAP: Invocation of XSLT
ABAP statement CALL TRANSFORMATION
TRY.
CALL TRANSFORMATION my_trans
or (my_trans_name)
PARAMETERS p_1 = my_par_1 ... p_n = my_par_n
or (my_par_table)
SOURCE XML my_xml_source
RESULT XML my_xml_result.
CATCH cx_transformation_error INTO exc.
...
ENDTRY.
static or dynamic call of
XSLT program
program parameters
XML source: (x)string or table
or REF TO IF_IXML_ISTREAM
or REF TO IF_IXML_NODE
XML result: (x)string or table
or REF TO IF_IXML_OSTREAM
or REF TO IF_IXML_DOCUMENT
runtime errors throw exceptions
Þ This syntax example shows the case “source XML, result XML”. The syntax for
“source ABAP” / “result ABAP” follows later.
Þ Since ABAP is case insensitive, the case of the parameter names does not matter.
In the XSLT program, however, they must be declared in upper case (because
XSLT is case sensitive). Since the parameter names must be legal ABAP names,
they cannot have a URI component.
Þ A dynamic list of parameters is passed as a table of type
ABAP_TRANS_PARMBIND_TAB.
Þ Any ABAP type with a “natural” conversion to an XPath type can be passed as a
parameter.
Þ Both character and binary tables are allowed as the XML source and result.
Þ An alternative way to execute XSLT programs is the class CL_XSLT_PROCESSOR.
Its use is deprecated because it requires the application to take care of the lifetime
of the processor object (which the ABAP instruction handles automatically).
Basically there are two exceptions to this rule:
(i) Separate evaluation of XPath expressions (see class documentation).
(ii) Messages produced by the XSLT program are to be retrieved.
25
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 25
XML in ABAP: XSLT Development
Workbench integration
Þ SE80: Edit object → More... → Transformation
Þ object tree, context menu: Create → More... → Transformation
Þ direct: transaction STRANS (6.20: XSLT_TOOL)
Þ testing: transaction XSLT
Þ programs must be activated before use
Þ check / activate triggers compilation
Þ maintenance API: function XSLT_MAINTENANCE
Þ XSLT programs are development objects, like ABAP programs. They are not in the
MIME repository. From the workbench point of view, XSLT sources are primarily
programs. That they are in XML format is secondary. This is in contrast with CSS
stylesheets, which are mere content.
Þ XSLT programs are assigned to development classes / packages. Changes and
transports are under the control of the transport system.
Þ An XSLT program can not be activated if it contains syntax errors. Only active
programs can be included or imported by other programs. Consequently, only
correct programs can be included / imported. However, programs which are correct
in isolation may lead to errors in an including program (e.g. due to multiply declared
templates).
Þ The XSLT tester loads the XML source from a frontend file. It offers four modes:
4Transform directly to a string, display the string as a list.
4Send result to a frontend file.
4Transform to a DOM, then render the DOM with iXML methods; display as a list. In this case,
XSLT output settings have no effect.
4View result in HTML viewer.
26
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 26
Demo
Demo
· Transformations in the ABAP Workbench
Check – Activate – Test
· “Flights” example (SSTDEMO2):
· XML to XML with XSLT
· XML to HTML with XSLT
27
SAP TechEd ‘04
Intro
XML in Open Systems
XML in ABAP
ABAP – XML Mapping: Concepts
ABAP – XML Mapping with XSLT
Simple Transformations
Summary
28
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 28
XML +¬ ABAP: Application Areas
Who needs (de)serialization?
XML tree
data tree
serialization deserialization
Þ XML-based communication
middleware
Þ SAP Exchange Infrastructure (XI)
Þ Web Services
Þ XML-based persistence
Þ SAP Archiving
Þ XML repositories ↔DB tables
import / export
Þ SAP WebDynpro metadata
Þ application-specific uses
Þ XML via HTTP / in database / ...
Þ In the Java data-binding community, the terms "marshalling" and "unmarshalling"
are often used in place of "serialization" and "deserialization", respectively.
29
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 29
XML +¬ ABAP: Structure Mapping
The structure mapping problem
o
u
t
s
i
d
e
i
n
s
i
d
e
ABAP functionality
ABAP
applications
external
applications
ABAP data structure
external XML format
XML-based communication
structure difference
Þ The general situation depicted here is that there is an ABAP system implementing
certain functionality for which it offers an ABAP interface, and that there are other
applications (maybe physically on the same server, but not in the ABAP system)
offering an XML-based interface. The perspective is that of an ABAP developer,
which leads to the "inside" / "outside" classification.
30
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 30
XML +¬ ABAP: Approaches
Which side is driving?
Þ inside-out approach
Þ outside-in approach
Þ symmetric approach (6.20)
Þ canonical XML encoding of data structures
+
Þ transformation with XSLT
Þ symmetric approach (6.40)
Þ dedicated XML / data transformation language
Þ no conceptual "canonical encoding" indirection
Þ "Inside-out": The ABAP structure determines the XML structure.
Þ "Outside-in": The XML structure determines the ABAP structure.
Þ "Symmetric" approaches retain given structures on each side. The two symmetric
approaches presented here are original SAP developments.
Þ The first symmetric solution is based on an encoding of arbitrary ABAP data
structures in XML: the canonical XML format asXML. This format is used as the
source or result of XSLT transformations.
Þ The second symmetric solution works without a canonical XML format. It is based
on a dedicated XML / data transformation language.
31
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 31
XML +¬ ABAP: Inside-out
The inside-out approach
ABAP functionality
ABAP data structure
1
o
u
t
s
i
d
e
i
n
s
i
d
e
external XML format
3
external mapping (XSLT...)
canonical XML encoding
2
XML handler
6.20 kernel
Þ The inside-out approach is available with the 6.20 kernel: Using CALL
TRANSFORMATION and the identity transformation, any ABAP data structure can
be represented in a canonical XML encoding.
Þ But for communication with external applications, this is usually not sufficient, as
they will require different XML formats.
Þ Consequently, XML-to-XML transformations will have to be performed. Note that
such a transformation is not provided "inside" in this approach; it is the problem of
the "outside" applications.
Þ Even if the canonical format were accepted by the "outside", it would usually not be
the best choice, because it exposes directly the "inside" data structures. For a
communication format, modifications are often desirable, e.g. different XML names,
element / attribute distinctions, or even structural changes.
32
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 32
generated
[ generated ]
6.20 kernel
XML +¬ ABAP: Outside-in
The outside-in approach ("data binding")
ABAP functionality
ABAP data structure
1b
o
u
t
s
i
d
e
i
n
s
i
d
e
external XML format
1a
ABAP adapter
3
XML handler
ABAP proxy
ABAP proxy interface
2
Þ Numerous data binding frameworks are available in Java, most notably JAXB. The
basic idea is always that XML structures are somehow reflected in Java structures
which are generated from an XML schema. Thus, every XML schema that a
system must handle leads to the generation of proxy classes (about as many as
node types in the schema).
Þ In addition to the proxy classes, adapter code for given "inside" functionality may
also be generated. Alternatively, it may be written by hand.
Þ An even more radical outside-in approach would be to use the proxy classes
directly as the interface and possibly even as the internal data model of the
application. However, this approach is almost as inadequate as using the DOM as
a data model: Data communication structures are hardly appropriate as data
processing structures.
33
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 33
XML +¬ ABAP: Symmetric
The symmetric approach (6.20)
o
u
t
s
i
d
e
i
n
s
i
d
e
ABAP functionality
ABAP data structure
1
external XML format
1
2
Mapping
Engine
(6.20 Kernel)
XSLT programs
XSLT
Þ This picture omits a small piece of code that actually invokes the XSLT program
with the XML document and ABAP data structure. This (trivial) adapter code could
be located either in the application (if the corresponding XML format is
implemented as part of its interface) or on top of it.
Þ The XSLT programs work on asXML, the canonical ABAP Serialization XML format
(more details later).
34
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 34
ABAP ¬ XML with XSLT
Outbound XML
transform
DOM to
outbound
XML
XSLT
(outbound)
construct
canonical
DOM for
data tree
XML
ABAP
Þ The first step in the "outbound XML" case is the construction of the ABAP data
structure's asXML representation as a DOM (implicitly done by the CALL
TRANSFORMATION statement).
Þ This is a prerequisite for the "outbound XSLT" program; more precisely, for the
evaluation of the XPath expressions in it.
Þ The DOM representation is the basis for powerful XPath navigation on the data
structure. But of course, it is also the cause of considerable memory consumption.
35
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 35
XML ¬ ABAP with XSLT
Inbound XML
transform
DOM to
data tree
(directly)
XML
conceptual:
transform
to canonical
XML tree
XSLT
(inbound)
ABAP
parse
inbound
XML to DOM
Þ The first step in the "inbound XML" case is the construction of the XML DOM (if it is
received as text).
Þ Note that the "inbound XSLT" program is different from the "outbound XSLT"
program. It does not consume asXML, but produces it.
Þ The construction of the asXML tree is only conceptual. In fact, the ABAP data
structure is filled directly.
Þ Thus, inbound and outbound XML have approximately the same complexity: DOM
construction, XSLT exceution, data structure traversal.
36
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 36
XML +¬ ABAP with XSLT: Scope
Scope:
HTTP
...
Þ not a communication mechanism
Þ only a mapping engine
...
Web
Services
Þ not an RPC framework
Þ The ABAP / XML mapping engine presented here does not cover communication;
i.e., it is left open how XML documents enter and leave the system. For example,
communication could utilize the HTTP capabilities of the SAP Web AS.
Þ Also, the mapping is not tied to any kind of RPC (Remote Procedure Call)
mechanism. Any XML format can be processed; mapping is not limited to a "call /
parameter" format.
37
SAP TechEd ‘04
Intro
XML in Open Systems
XML in ABAP
ABAP – XML Mapping: Concepts
ABAP – XML Mapping with XSLT
Simple Transformations
Summary
38
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 38
XML +¬ ABAP: Invocation of XSLT
Serialization
CALL TRANSFORMATION ...
PARAMETERS ...
OPTIONS option_1 = string ... option_n = string
SOURCE XP_1 = my_var_1 ... XP_n = my_var_n
or (my_var_table)
RESULT XML my_xml_result.
CALL TRANSFORMATION ...
PARAMETERS ...
OPTIONS option_1 = string ... option_n = string
SOURCE XML my_xml_source
RESULT XP_1 = my_var_1 ... XP_n = my_var_n
or (my_var_table).
Deserialization
binding of
program variables
to symbolic XML names
Þ When the source of a transformation is a set of ABAP variables, XML bindings for
these variables are specified after the keyword SOURCE. If the variables are the
transformation result, then the bindings are specified after RESULT.
Þ An XML binding X = V associates an ABAP variable V with an XML name X in the
asXML document. (Without this indirection, a transformation would be tied to a
fixed set of variable names.)
Þ Since ABAP is case insensitive and normalizes parameter names to uppercase,
the corresponding XML name is uppercase. Consequently, XSLT programs must
specify these names in uppercase, since XML is case sensitive. In order to avoid
confusion, XML names in ABAP should be specified in uppercase as well.
Þ By combining SOURCE and RESULT clauses, ABAP-to-ABAP is also possible.
Þ The option XML_HEADER = 'NONE' | 'WITHOUT_ENCODING' | 'FULL' controls
output of the XML header <?xml … ?>.
Þ The option INITIAL_COMPONENTS = 'SUPPRESS' suppresses ABAP fields with
initial value during serialization.
Þ The option VALUE_HANDLING = 'MOVE' tolerates “illegal” values (e.g. non-digits
in type N fields), corresponding to the behavior of the MOVE instruction.
39
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 39
Exercise
Exercise
“Customers” example:
My first ABAP-XML Mapping (XSLT)
· ABAP to XML
· XML to ABAP
40
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 40
ABAP ¬ XML: Invocation of XSLT (Example)
ABAP fragment
DATA num TYPE P LENGTH 5 DECIMALS 2.
DATA txt TYPE STRING.
num = '1.23-'.
txt = 'Yes, 2 < 3'.
CALL TRANSFORMATION id
SOURCE Foo = num bar = txt
RESULT XML my_xml_result.
XML result fragment
...
<FOO>-1.23</FOO>
<BAR>Yes, 2 &lt; 3</BAR>
...
symbolic names are normalized to uppercase
format depends on corresponding ABAP variable
identity transformation
Þ When the transformation is not the identity (the required result XML format is not
asXML), it must process the asXML representation generated for the ABAP source
variables.
Þ Data is written in the canonical (XML Schema) lexical representation.
41
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 41
XML ¬ ABAP: Invocation of XSLT (Example)
ABAP fragment
DATA num TYPE P LENGTH 5 DECIMALS 2.
DATA txt TYPE STRING.
CALL TRANSFORMATION id
SOURCE XML my_xml_source
RESULT Foo = num bar = txt.
WRITE: / num, / txt.
XML source fragment
...
<FOO>E-1.23E</FOO>
<BAR>Yes, 2 &lt; 3</BAR>
...
insignificant whitespace
ABAP type determines expected XML content
1.23-
Yes, 2 < 3
Þ When the transformation is not the identity (the required source XML format is not
asXML), it must generate the asXML representation required for the ABAP result
variables.
Þ Data is accepted in any form that matches the lexical representation. Thus,
deserialization is more liberal than serialization (e.g., leading and trailing spaces
are not significant for most datatypes).
Þ XML-to-ABAP example with dynamic parameter passing:
TYPE-POOLS: abap.
DATA bind TYPE abap_trans_resbind.
DATA itab TYPE abap_trans_resbind_tab.
DATA num TYPE P LENGTH 5 DECIMALS 2.
DATA txt TYPE STRING.
bind-name = 'FOO'. GET REFERENCE OF num INTO bind-value.
APPEND bind TO itab.
bind-name = 'BAR'. GET REFERENCE OF txt INTO bind-value.
APPEND bind TO itab.
CALL TRANSFORMATION ID
SOURCE XML my_xml_source
RESULT (itab).
42
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 42
XML +¬ ABAP with XSLT: asXML Format
ABAP Types and the asXML Format
Þ ABAP →asXML : type of ABAP source variable(s)
determines generated asXML representation
Þ asXML →ABAP : type of ABAP result variable(s)
determines required asXML representation
¬ source / result ABAP variables must be typed
A Data Exchange Format
Þ XML-Schema datatypes
Þ "Human-readability" not a top priority
Þ no dependence on customization
Þ no dependence on locale settings
Þ no use of conversion exits
Þ The asXML format adopts XML Schema datatypes
(http://www.w3.org/TR/xmlschema-2), on which many XML standards (e.g. SOAP)
are based. (If asXML used a more ABAP-like format, XSLT programs would have
to be used to do much more work than structural transformations, especially string
operations.)
43
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 43
asXML Format: Simple Types
Simple Types
ABCDEF
456789AB
201501
20010820
-3.14E-2
1.23-
123-
001234
EHello
EHiEE
ABAP
Example*
-1.23 decimal P
string of digits 001234 string ([0-9]+) N
q83v base64Binary X
base64-encoded
binary data
RWeJqw== base64Binary XSTRING
20:15:01 time T
ISO 8601
date/time
2001-08-20 date D
-3.14E-2 double F
number
-123
int
unsignedByte, short
I
INT1, INT2
EHello string C
string of
characters
EHiEE string STRING
Comment
XML
Example
XML Schema
Type
ABAP
Type
* Internal string representation of ABAP datatypes
Þ STRING: Leading and trailing spaces are significant.
Þ C: Only leading spaces are significant.
Þ N: String of digits, i.e., leading 0s are significant (restriction of XML Schema type
'string').
Þ I, P, F: leading -, uppercase E (lowercase ok in input), no leading 0s (ok in input),
no after-decimal-point trailing 0s (ok in input).
Þ D,T: No timezone, year in range 1-9999 (less than is allowed by XML Schema
type), some invalid dates are allowed (e.g., year 0).
Þ XSTRING, X: Base-64 encoding is commonly used in an XML context (e.g. SOAP).
Þ Graphs of objects or data references need not be tree-shaped. Therefore,
corresponding asXML documents contain in-document references to represent
such graphs. Here, object and data references are not presented in further detail.
For objects, the implementer of a class has the possibility to state whether its
instances can be serialized and if so, which values constitute the serialized object.
44
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 44
asXML Format: Structures
Structures
DATA miles TYPE person.
miles-name = 'Miles Davis'.
miles-born = '19260526'.
CALL TRANSFORMATION id
SOURCE LEGEND = miles
RESULT XML my_xml_result.
...
<LEGEND>
<NAME>Miles Davis</NAME>
<BORN>1926-05-26</BORN>
</LEGEND>
...
DDict Structure PERSON:
NAME TYPE STRING
BORN TYPE D
component names determine
XML sub-element names
Þ All types are allowed in components, including structures and internal tables.
Þ Program-local types can be used.
Þ Matching components are set as by MOVE-CORRESPONDING. Additional
subelements are ignored in XML input, components without a corresponding XML
element keep their value. In contrast with MOVE-CORRESPONDING, the "matching
algorithm" is applied recursively.
Þ Components are serialized in the order in which they are defined in the structure.
Order in input is insignificant; components are addressed by name.
Þ The DDict type PERSON is hypothetical.
45
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 45
asXML Format: Internal Tables
Internal Tables
DATA: one TYPE person.
DATA: itab TYPE STANDARD TABLE OF person.
one-name = 'John Coltrane'. one-born = '19260923'. APPEND one TO itab.
one-name = 'Miles Davis'. one-born = '19260526'. APPEND one TO itab.
one-name = 'Charlie Parker'. one-born = '19200829'. APPEND one TO itab.
CALL TRANSFORMATION id
SOURCE GREATEST = itab
RESULT XML my_xml_result.
...
<GREATEST>
<PERSON><NAME>John Coltrane</NAME> <BORN>1926-09-23</BORN></PERSON>
<PERSON><NAME>Miles Davis</NAME> <BORN>1926-05-26</BORN></PERSON>
<PERSON><NAME>Charlie Parker</NAME><BORN>1920-08-29</BORN></PERSON>
</GREATEST>
...
line type from DDict (or <item>)
Þ Any kind of table (standard, sorted, hashed) and any line type (including non-
structures) is allowed.
Þ During deserialization, the name of the element representing a table line is
irrelevant.
Þ Table lines for sorted tables do not have to be sorted (will be sorted automatically).
Þ The example XML fragments are pretty-printed only for presentation.
46
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 46
asXML Format: Envelope
asXML Envelope
<asx:abap version = "1.0"
xmlns:asx = "http://www.sap.com/abapxml">
<asx:values>
<XP_1> ... </XP_1>
...
<XP_n> ... </XP_n>
</asx:values>
<!--
additional XML elements for objects
and referenced data structures
-->
</asx:abap>
list of ABAP-XML bindings
Þ The version attribute indicates the asXML version used in the document.
Currently it must be set to 1.0.
Þ The top-level element must be <asx:abap>, where the (arbitrary) prefix asx is
bound to the asXML namespace http://www.sap.com/abapxml.
Þ For each asXML representation of an ABAP variable bound to an XML name, there
is an element with this XML name inside the asx:values element.
47
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 47
Exercise
Exercise
“Customers” example:
Full version (XSLT)
48
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 48
XML +¬ ABAP with XSLT: Advantages
Advantages of the XSLT solution
Þ no restrictions
Þ arbitrary XML schemas
Þ arbitrary data & object types
4 graphs of objects
Þ arbitrarily complex structural transformations
Þ no redundancy
Þ no generation of schemas from types (schema inflation)
Þ no generation of types from schemas (type inflation)
Þ each side retains its structures
Þ high abstraction level
Þ no low-level XML handling in applications
Þ separate, expressive transformation language
Þ Data binding approaches are usually restricted to certain classes of XML schemas
and offer only limited mapping capabilities. This is because they do not employ a
programming language, but only a configuration mechanism.
Þ By not generating types from schemas, the symmetric approach prevents the
schema inflation in the "outside" XML world to cause a type inflation on the "inside".
Controlling the amount of types in a system is generally a good thing.
Þ With XSLT as a distinct programming language, mapping code is clearly separated
from application code, and programmers are not tempted to abuse the DOM as a
generic data structure.
49
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 49
XML +¬ ABAP with XSLT: Disadvantages
Disadvantages of the XSLT solution
Þ learning XSLT
Þ overkill for simple conversion tasks
Þ no tool support
Þ asymmetric programs
Þ one for XML¬ABAP, one for ABAP ¬XML
Þ resource consumption (Time & Space)
Þ T / S : DOM construction (on source side)
Þ T : codepage conversions (internal encoding ≠ SAP CP)
Þ T : XSLT engine overhead (complex state, powerful operations)
Þ no static type checking
Þ asXML DOMs can easily become huge. Due to the OO overhead, a DOM typically
requires about 10 times the memory of the XML text representation – which is
already large compared to the data structure.
Þ iXML and the SAP XSLT processor work internally with encoding UTF-16. If this is
not the SAP codepage (i.e. the system is non-Unicode), frequent conversions are
necessary.
Þ Static type checking is impossible because XPath navigation on the asXML input
(serialization) or control flow in the XSLT templates (deserialization) is not statically
analyzable.
50
SAP TechEd ‘04
Intro
XML in Open Systems
XML in ABAP
ABAP – XML Mapping: Concepts
ABAP – XML Mapping with XSLT
Simple Transformations
Summary
51
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 51
XML +¬ ABAP without XSLT: Requirements
Requirements for a dedicated XML/ABAP mapping engine
Þ time: increase throughput by factor ≥ 10
Þ space: increase / eliminate upper limit on size of data
Þ ease of use
Þ simple syntax & semantics, statically type-checked
Þ tool support for creating mappings
Þ one program for XML→ABAP and ABAP→XML
Deliberate trade-offs
Þ lower expressive power (but cover 90% of typical applications)
Þ not usable for XML ↔XML
¬ "Simple Transformations"
Þ The XSLT-based solution is used in XI 2.0.
Þ Simple Transformations are the basis for XI 3.0 and Web Services.
52
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 52
random access
linear
(stream reader)
linear
(modulo
component order)
random access
(XPath)
ABAP result
tree construction
XML source
tree navigation
linear
random access
linear
random access
(XPath on
canonical DOM)
XML result
tree construction
ABAP source
tree navigation
Simple Transformations: Tree Access
Tree access in XSLT vs. Simple Transformations
Simple
Transfomations
XSLT
D
e
s
e
r
i
a
l
i
z
a
t
i
o
n
S
e
r
i
a
l
i
z
a
t
i
o
n
Þ XSLT programs always produce the result in strictly linear fashion. However, order
of ABAP structure components is irrelevant during deserialization.
Þ In contrast, Simple Transformations always access the XML document in linear
order (even if it is on the source side) and the ABAP data structure in non-linear
order (even if it is on the result side).
53
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 53
Simple Transformations: Expressive Power
Anything that can be done with ...
Þ accessing each node in the data tree
any number of times
Þ accessing each node in the XML tree
at most once,
in document order (with "lookahead 1" on XML source)
... which includes (any combination of) ...
Þ renamings (e.g.: structure-component / element names)
Þ projections (omission of sub-trees)
Þ permutations (changes in sub-tree order)
Þ constants (e.g.: constant values, insertion of tree levels)
Þ defaults (for initial / special values)
Þ conditionals (e.g.: existence of sub-trees, value of nodes)
Þ value maps
¬ covers most data mappings in practice
54
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 54
Simple Transformations: Key Features (1)
Programs are XML templates
Þ literal XML with
interspersed instructions
Þ declarative, straightforward
semantics
Data tree access by
node references
Þ instructions access data by
simple “reference expressions”
Þ all named children of a data node
are accessible by name
Þ tables are accessible as a whole
(all lines or none)
<Customers>
<tt:loop ref="CUSTTAB">
<LastName>
<tt:value ref=
"NAME.LAST"/>
</LastName>
</tt:loop>
</Customers>
Þ The concept of literal XML with interspersed instructions is the same as in XSLT.
55
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 55
Simple Transformations: Key Features (2)
Programs are reversible
Þ serialization : write (produce) tokens to stream
Þ deserialization : match (consume) tokens from stream
Þ invocation determines direction
Þ if no asymmetric construct is used:
Þ D[program] ( S[program] (data) ) = data
Þ S[program] ( D[program] (document) ) ≈ document
(D: deserialization, S: serialization)
Þ Of course, the "reversibility" equations do not hold for programs that lose
information, e.g. by not serializing a data component at all (projection).
56
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 56
From 6.20 to 6.40
“XSLT” is generalized to:
“Transformation” = “XSLT” or “Simple Transformation”
Þ workbench integration
Þ same workbench / transport object type
Þ same access paths
Þ transformation type determined in creation dialog
Þ XSLT_MAINTENANCE works for both types
Þ ABAP integration
Þ CALL TRANSFORMATION works for both types
Þ both types take same XML input / output types
(e.g. iXML streams)
Þ exception hierarchy generalized (new common root)
¬ uniform appearance (easy to switch from XSLT solutions)
57
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 57
Simple Transformations: Implementation
Virtual machine (VM)
Þ compilation of programs to bytecode
Þ storage of bytecode in database / buffering in shared memory
Þ interpretation of bytecode in kernel (lean engine)
¬ scalable performance
XML stream reader / writer
Þ reader: efficient "token pull" discipline
Þ specialized for standard encoding UTF-8
Þ also usable directly from ABAP:
classes CL_FX_READER, CL_FX_WRITER
¬ limit on data size lifted
Þ Like the SAP XSLT processor, the Simple Transformations implementation re-uses
the infrastructure for ABAP programs, in particular the load table and the program
buffer.
Þ However, execution takes place on a dedicated engine (neither ABAP nor XSLT). It
works directly with UTF-8, which is the encoding that is used most frequently for
XML communication.
58
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 58
Demo
Demo
“Flights” example (SSTDEMO2):
· ABAP to XML with ST
· XML to ABAP with ST
59
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 59
Simple Transformations: Programs
<tt:transform
xmlns:tt="http://www.sap.com/transformation-templates">
( <tt:include name="name"/> )*
( <tt:root name="name"/> )*
( variable / parameter declaration )*
( <tt:template [name="name"]>
[ context declaration ]
template content
</tt:template> )*
</tt:transform>
formal root name(s)
transformation template(s)
Þ A program can have several named templates for the purpose of applying them
several times (in the main template, or in an including program). In most cases a
program will contain only one template. There is no concept of template selection
by pattern matching, as in XSLT.
Þ If there are several templates, then the main template is either specified by a
template="name" attribute on the tt:transform element, or it is the (single)
unnamed template.
60
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 60
ST Constructs: Value
Value
S ref-node value to XML
D XML value to ref-node
<tt:value
[ref="ref"]
[map="mapping-list"] />
example
copy value from/to field CHAR,
with special mappings:
S map {∗, +, –} to ~
D map ~ to ∗
<tt:value
ref="CHAR"
map="
val('*') = xml('~'),
val('+','-') > xml('~')" />
61
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 61
ST Constructs: Literal Element / Attribute
Literal element / attribute
S write literal content
D match literal content
(no match →error)
<element-name
[literal-attributes]
[ tt:ref="ref"
| tt:value-ref="ref" ]>
[template content]
</element-name>
example
alternative
<Time zone="CET" tt:value-ref="TIME"/>
<Time zone="CET" tt:ref="TIME">
<tt:value/>
</Time>
<Time zone="CET">12:59:00</Time> XML
62
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 62
ST Constructs: Literal Text
Literal text
S write literal text
D match literal text
<tt:text>text</tt:text>
example
alternative
<Time>
<tt:value ref="TIME"/>
<tt:text> CET</tt:text>
</Time>
text
<Time> <tt:value
ref="TIME"/> CET</Time>
<Time>12:59:00 CET</Time> XML
63
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 63
ST Constructs: Attribute
Attribute
S write attribute
D match attribute
<tt:attribute name="attribute-name"
[ref="ref"]>
[template content]
</tt:attribute>
example
<Time tt:ref="ZTIME">
<tt:attribute name="zone"
value-ref="TZONE"/>
<tt:value ref="TIME"/>
</Time>
<tt:attribute name="attribute-name"
value-ref="ref" [map="mapping-list"] />
<Time zone="CET">12:59:00</Time> XML
64
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 64
ST Constructs: Deep Copy
Deep Copy
S copy sub-tree below
ref-node to stream
D copy sub-tree below
current XML node to ref-node
<tt:copy [ref="ref"]/>
example
<tt:copy ref="ZTIME_TAB"/>
<ZTIME>
<TZONE>CET</TZONE>
<TIME>12:59:00</TIME>
</ZTIME>
<ZTIME>
<TZONE>EST</TZONE>
<TIME>06:59:00</TIME>
</ZTIME>
XML
Þ Note that tt:copy does not introduce an element for the root of the tree being
copied (in this case, the internal table itself). Below the root node, elements are
introduced according to the canonical XML representation of ABAP data structures.
In this case, it is assumed that the line type of ZTIME_TAB is a dictionary type
ZTIME with two components TZONE and TIME.
65
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 65
ST Constructs: Table Loop
Table Loop
S evaluate content for all lines
of table
D evaluate content, insert lines
into table until matching fails
<tt:loop [ref="ref"]
[name="line-name"] >
template content
</tt:loop>
example
<tt:loop ref="ZTIME_TAB"/>
<tt:copy/>
</tt:loop>
<TZONE>CET</TZONE>
<TIME>12:59:00</TIME>
<TZONE>EST</TZONE>
<TIME>06:59:00</TIME>
XML
Þ The name attribute on tt:loop serves to declare a symbolic name for the current
table line which is in scope in the body of the loop. This is necessary if you want to
refer to (components of) this line from within a nested loop: Having declared
name="line-name", you can use the syntax $line-name as a reference expression
in order to refer to the current line of this loop.
66
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 66
Exercise
Exercise
“Customers” example:
My first Simple Transformation
67
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 67
ST Constructs: Basic Conditional (1)
Basic Conditional
S [if data condition is true:]
evaluate template content
D [if template content matches:]
evaluate template content
[establish assertions]
[evaluate check-clause]
<tt:cond
[data="assertion-list"]
[[s-|d-]check="check-clause"]>
template content
</tt:cond>
example
S if TZONE='CET' and
TIME = t > 000000:
write <CET>t</CET>
D if <CET>t</CET>:
TIME:=t, TZONE:='CET',
check TIME > 000000
<tt:cond
data="TZONE='CET'"
check="TIME>T('000000')">
<CET tt:value-ref="TIME"/>
</tt:cond>
Þ Using s-check / d-check instead of check causes the check-clause to be
evaluated only during serialization / deserialization.
Þ The “data condition” evaluated during serialization is the conjunction of the
assertion-list and the check-clause. If there is no such condition, then the template
content is evaluated unconditionally during serialization.
Þ The template content of the conditional is a pattern if it is (i) a single literal element
[with content], (ii) a tt:attribute instruction, (iii) a single non-empty literal text,
(iv) the keyword <tt:empty/> (matching empty content), or (v) an application of
a template whose body is a pattern, or (vi) a loop whose body is a pattern.
If the body is not a pattern, then it is evaluated unconditionally during
deserialization.
Þ Deserialization fails if evaluation of the check-clause yields false or if a value
different from the assertion value is assigned to a node with an assertion (during
evaluation of the body).
68
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 68
ST Constructs: Basic Conditional (2)
Value Assertions
• C('string') or 'string'
• D('yyyymmdd')
• F(float)
• I(integer) or integer
• N('digits')
• P('decimal')
• T('hhmmss')
• X('xstring')
• initial(ref)
• ref = constant
<tt:cond data =
" assertion ( , assertion )* ">
ref :
• general: ref('name')
• simplified: name
for name of the form
letter ( letter | digit | _ )*
example
COUNT = 1,
ref('PRICE.%OFF') = P('7.5')
ref-nodes in expressions
constants
Þ The general form of the ref-node syntax for expressions is necessary because
ABAP and the dictionary admit almost any character in names, which is impossible
with the Simple Transformations expression parser (a reduced variant of the XPath
parser).
69
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 69
ST Constructs: Basic Conditional (3)
Check-clause
expr :
• ref op ( constant | ref ) with op in {=, !=, <, >, <=, >=}
• initial(ref), not-initial(ref)
• exist(ref) (node-existence check)
• t-op(ref) with t-op = type-C|D|F|I|N|P|T|X (node-type check)
• expr and expr
• expr or expr
• not(expr)
• ( expr )
<tt:cond [s-|d-]check="expr" >
example
TIME>CTIME and (initial(TZONE) or TZONE='CET')
Þ Apart from the value assertions and check-clause, tt:cond may have an attribute
using, containing a comma-separated list of node-existence and node-type
checks.
Þ This list of “using assertions” is evaluated first. If it fails (because a node does not
exist or does not have the required type), then the condition body is not evaluated.
If a using assertion fails during deserialization and the body is a pattern, then the
matching part of the XML source (e.g. the XML element) is skipped.
70
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 70
ST Constructs: Composite Conditional
Switch
S evaluate first case with true data
condition
D evaluate first case with matching
pattern
<tt:switch>
case*
</tt:switch>
<tt:group>
case*
</tt:group>
Group
S evaluate all cases with true
data condition
D evaluate all cases with
matching pattern
case :
• <tt:cond ...>
• <tt:s-cond ...> (only serialization)
• <tt:d-cond ...> (only deserialization)
Þ At most one case in a switch may have no data condition. If such a case exists, it is
the serialization default.
Þ At most one case in a switch may have no pattern content. If such a case exists, it
is the deserialization default.
71
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 71
ST Constructs: Modularization (1)
Variable / Parameter Declaration
declaration :
• <tt:root name="name"/>
• <tt:variable name="name"
[val="constant"]/>
• <tt:parameter name="name"
[val="constant"]
[kind="in"|"out"|"in/out"]/>
<tt:transform>
declaration*
<tt:template name="name">
<tt:context>
declaration*
</tt:context>
template content
</tt:template>
</tt:transform>
Þ Context of main template: top-level declarations
Þ Default context of sub-template: one unnamed root
Þ initial / default value in val
Þ parameter direction (kind) independent of transformation direction
Þ Each template works on a certain “context”. The context of the main template is the
set of roots and variables / parameters declared at the top level of the
transformation. A sub-template (i.e., non-main template) can have its own context
declaration, in which it declares its roots, parameters, and variables. By default,
sub-templates have a single unnamed root and no variables / parameters.
Þ The treatment of root nodes (and all ref-nodes) depends on the transformation
direction: Serialization reads them, deserialization writes them. They are either
read-only or write-only. In contrast, variables can always be read and written. In
particular, transformation parameters can be read during deserialization and written
during serialization, which can’t be done with ref-nodes.
72
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 72
ST Constructs: Modularization (2)
Apply Template
<tt:apply
name="template-name">
binding*
</tt:apply>
binding :
• <tt:with-root name="name"
[ref="ref"] />
• <tt:with-parameter name="name"
[ ref="ref"
| var="name"
| val="constant" ] />
<tt:call
transformation="name">
binding*
</tt:call>
Call Transformation
Þ tt:apply: named template in main or included program
Þ tt:call: existing ST program (separate load)
Þ A sub-template without an explicit root declaration has an implicit unnamed root.
This root is bound to the current node at the point of invocation (tt:apply).
73
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 73
Exercise
Exercise
“Customers” example:
Full version (Simple Transformation)
74
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 74
ST Constructs: Variable [De]Serialization
Read Variable
S no effect
D XML value to variable
<tt:read var="name"
[type="C|D|F|I|N|P|T|X"]
[map="mapping-list"] />
Write Variable
S variable value to XML
D no effect
<tt:write var="name"
[map="mapping-list"] />
75
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 75
ST Constructs: Assignment
Assign to Ref-Node
S no effect
D assign to ref-node
<tt:assign to-ref="ref"
( var="name" | val="constant" )/>
Assign to Variable
S assign to variable
D …except if ref (no
effect)
<tt:assign to-var="name"
[ var="name" | ref="ref"
| val="constant" ] />
example
same effect as
<tt:value ref="A"/>
<tt:assign to-var="V" ref="A"/>
<tt:write var="V"/>
<tt:read var="V"/>
<tt:assign to-ref="A" var="V"/>
S
D
<tt:clear var="name"/>
<tt:clear ref="ref"/>
76
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 76
ST Constructs: Variable Conditional
Basic Variable Condition
<tt:cond-var check="check-clause"
template content
</tt:cond-var>
Variable Switch
<tt:switch-var>
case*
</tt:switch-var>
Þ check-clause uses variables (not ref-nodes)
Þ at most one case in tt:switch-var may have no condition (default)
Þ The tt:cond and tt:switch constructs have direction-dependent semantics:
During deserialization, the condition is on the XML content, not on the values of ref-
nodes. (As a matter of principle, it is impossible to let the values of ref-nodes
influence the transformation result.)
In contrast, the tt:cond-var and tt:switch-var constructs are always
conditions on the values of variables, even during deserialization. Consequently,
the check-clause of tt:cond-var cannot use ref-nodes.
77
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 77
ST Constructs: Directional
Serialize
S evaluate template content
D no effect
<tt:serialize>
template content
</tt:serialize>
Deserialize
S no effect
D evaluate template content
<tt:deserialize>
template content
</tt:deserialize>
Skip
S no effect
D match & skip [number of]
nodes [named element-name]
<tt:skip [name="element-name"]
[count="number" | "*"]>
template content
</tt:skip>
78
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 78
ST Exception Hierarchy
CX_TRANSFORMATION_ERROR
CX_ST_ERROR
CX_ST_REF_ACCESS
CX_ST_CONDITION
CX_ST_COND_CHECK_FAIL
CX_ST_GROUP_MISSING_CASE
CX_ST_SWITCH_NO_CASE
CX_ST_MATCH
CX_ST_MATCH_NAMED
CX_ST_MATCH_ATTRIBUTE
CX_ST_MATCH_ELEMENT
CX_ST_MATCH_TEXT
CX_ST_MATCH_TYPE
CX_ST_FORMAT_ERROR
CX_ST_DESERIALIZATION_ERROR
CX_ST_SERIALIZATION_ERROR
CX_ST_INVALID_XML
CX_ST_CALL_ERROR
79
SAP TechEd ‘04
Intro
XML in Open Systems
XML in ABAP
ABAP – XML Mapping: Concepts
ABAP – XML Mapping with XSLT
Simple Transformations
Summary
80
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 80
Summary: ABAP – XML Mapping
ABAP
Data
….. ….
…. … ..
.. …. …. ..
… …. .. ..
XML
Doc
XSLT
….. ….
…. … ..
.. …. …. ..
HTML / Text
X
S
L
T
X
S
L
T
Simple
Transformations
DB
Network
X
S
L
T
X
S
L
T
n
e
w
i
n
6
.
4
0
81
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 81
Summary: Available Demos
Transactions in the Basis delivery
Þ (6.20) SXSLTDEMO1 : XSLT
Þ (6.40) SSTDEMO1 : ST
Þ (6.40 SP9) SSTDEMO2 : XSLT and ST
82
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 82
Summary: Transformation Languages for ABAP
XSLT (since 6.10)
× works on canonical XML representation of ABAP data (asXML)
× builds DOM for source side
× arbitrarily complex transformations
Simple Transformations (since 6.40)
× only for ABAP ↔XML
× only linear transformations (no DOM)
× speedup over XSLT: 10 – 30; “unlimited” size of data
× reversible (one program for both directions)
Both
× symmetric: no generation of ABAP code / XML schemas
× integrated in workbench (maintenance / transport)
× integrated in ABAP: CALL TRANSFORMATION
basis of:
XI 2.0
basis of:
XI 3.0 / Web
Services
83
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 83
Summary: When To Use What
System Landscape Integration
¬Exchange Infrastructure
RPC-Style Web Services
¬ABAP Web Services
Direct XML Processing in ABAP
· REST-Style Web Services (URI in, XML out)
· Custom XML Persistence
· XML-Based Repositories
· …
Simple mappings, high throughput
¬Simple Transformations
Complex mappings, limited throughput
¬XSLT
84
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 84
Further Information
¬
Public Web:
SAP Developer Network: www.sdn.sap.com ¬Forums ¬Web Application
Server ¬ABAP Programming
¬
Related Workshops/Lectures at SAP TechEd 2004
¤ ABAP 256: “Utilizing Web Services with ABAP and SAP Web Application
Server 6.40” (4h Hands-on)
¤ XI 252: “SAP Exchange Infrastructure - Integrating Heterogeneous
Applications” (4h Hands-on)
¬
SAP Professional Journal
¤ Jul/Aug 2002: “From XML to ABAP Data Structures and Back: Bridging the
Gap with XSLT”
¤ Nov/Dec 2002: “Mastering the asXML Format to Leverage ABAP-XML
Serialization”
¤ Coming up: “Simple Transformations between ABAP and XML”
85
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 85
SAP Developer Network
Look for SAP TechEd ’04
presentations and videos on
the SAP Developer Network.
Coming in November.
http://www.sdn.sap.com/
86
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 86
Q&A
Questions?
87
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 87
Please complete your session evaluation.
Be courteous —deposit your trash,
and do not take the handouts for the following session.
Feedback
Thank You !
88
SAP TechEd ‘04
© SAP AG 2004, SAP TechEd / ABAP 252 / 88
Þ No part of this publication may be reproduced or transmitted in any form or for any purpose without the express
permission of SAP AG. The information contained herein may be changed without prior notice.
Þ Some software products marketed by SAP AG and its distributors contain proprietary software components of other
software vendors.
Þ Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
Þ IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries,
pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, and Informix are trademarks or
registered trademarks of IBM Corporation in the United States and/or other countries.
Þ Oracle is a registered trademark of Oracle Corporation.
Þ UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Þ Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered
trademarks of Citrix Systems, Inc.
Þ HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium,
Massachusetts Institute of Technology.
Þ Java is a registered trademark of Sun Microsystems, Inc.
Þ JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and
implemented by Netscape.
Þ MaxDB is a trademark of MySQL AB, Sweden.
Þ SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver and other SAP products and services mentioned herein
as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other
countries all over the world. All other product and service names mentioned are the trademarks of their respective
companies. Data contained in this document serves informational purposes only. National product specifications may vary.
Þ These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated
companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group
shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and
services are those that are set forth in the express warranty statements accompanying such products and services, if any.
Nothing herein should be construed as constituting an additional warranty.
Copyright 2004 SAP AG. All Rights Reserved
Þ I would suggest moving this slide before the guidelines, so people don‘t
accidentally delete it with all the guideline slides

SAP TechEd ‘04

Karsten Bohlmann, SAP AG Christoph Wedler, SAP AG Peter McNulty, SAP Labs

2

SAP TechEd ‘04

Learning Objectives

As a result of this workshop, you will:
learn about the role of XML in open system integration (e.g. in Web Services) know the ABAP tools for basic XML processing understand SAP’s approach to data / XML mapping (in relation to other approaches, e.g. JAXB) be able to write mappings between ABAP data structures and XML … … using XSLT … using Simple Transformations know when to use what

© SAP AG 2004, SAP TechEd / ABAP 252 / 3

3

SAP TechEd ‘04

Intro XML in Open Systems XML in ABAP ABAP – XML Mapping: Concepts ABAP – XML Mapping with XSLT Simple Transformations Summary

4

SAP TechEd ‘04 Intro XML in Open Systems XML in ABAP ABAP – XML Mapping: Concepts ABAP – XML Mapping with XSLT Simple Transformations Summary 5 .

SAP TechEd ‘04 Intro XML in Open Systems XML in ABAP ABAP – XML Mapping: Concepts ABAP – XML Mapping with XSLT Simple Transformations Summary 6 .

we are interested in uses of XML that support automated processing of data based on application-specific metadata. Machines exchange data and metadata in the form of XML documents. © SAP AG 2004. then the enrichment of data with metadata in XML can be seen as an attempt to approximate information. Hence. SAP TechEd / ABAP 252 / 7 If information is data with a meaning (interpreted data). without a data processing system interpreting it correctly. an XML document means nothing. 7 .SAP TechEd ‘04 From HTML to XML The Web is evolving … … from HTML – a fixed language for human viewing … to XML – a generic language for machine processing HTML HTML HTML XML XML XML People navigate through information in the form of HTML documents. regardless of the amount of metadata. Nevertheless.

is an XML based language for metadata.com/pub/q/weblogs_rss?x-ver=1.sharpreader. depending on the version level).html).sdn. There is a large number of RSS aggregators. SAP TechEd / ABAP 252 / 8 “RSS” stands for “RDF Site Summary” (or a few other meanings.sap. the Resource Description Framework.SAP TechEd ‘04 Example: Slashdot.rss XML out: Set up system reports as RSS feeds … as HTML … more effective viewing with RSS aggregators © SAP AG 2004. or aggregator.org RSS feed (news syndication) URI in: http://slashdot. For example. Using BSP (Business Server Pages) or HTTP directly. many of them freely available.net/index. An RSS reader. The predominant application area of RSS at the moment is news and weblogs. RDF. the SAP Developer Network has extensive RSS support – see https://weblogs.org/it. you could export regular system reports (e.g. 8 . A free reader for Windows is the Sharp Reader (http://www. supports more effective ways of monitoring a personal set of RSS feeds than can be achieved by manually tracking web pages with a normal HTML browser. the extensible nature of RSS 1. However. batch logs) from your WebAS in RSS format.0.0 qualifies it for many kinds of summary / reporting tasks.

xignite. © SAP AG 2004. SAP TechEd / ABAP 252 / 9 9 .asmx/GetRealTimeCrossRateTable? Symbols=USD%2CEUR%2CJPY%2CGBP&InvokeButton=Invoke& xMethod=GET XML out: Call a business service from ABAP … Or offer one.SAP TechEd ‘04 Example: Xignite Financial Web Services Realtime currency exchange rates URI in: http://www.com/xCurrencies.

com/onca/xml3?locale=us&t=te&dev-t=te &KeywordSearch=ABAP&mode=books&sort=+daterank &offer=All&type=lite&page=1&f=xml XML out: Retrieval: GET Change: POST © SAP AG 2004. The REST (REpresentational State Transfer) style is simply the well-known interaction pattern of the web.SAP TechEd ‘04 Example: Amazon Web Services Transactions on the Amazon marketplace URI in: http://xml.amazon. SAP TechEd / ABAP 252 / 10 Amazon Web Services are offered both in RPC style (SOAP) and REST style. based on URIs and XML (instead of HTML). 10 .

e. The XML Information Set is the data model defined along with XML itself. In particular. validating: XSchema. XML is .sun. structured nodes (“elements”) unordered. Unfortunately. XML documents should be thought of in terms of the data model. trees of nodes. Version 2.0 is being developed through the Java Community ProcessSM program under JSR-222.. it lacks the concept of unordered.4 (http://java.) JAXB is available as part of the Java Web Services Developer Pack (WSDP) 1. Though XML is “generic”. a generic data model (“XML Infoset”) for trees with ordered.. unstructured nodes (“attributes”) a generic syntax (“markup”) for representation of trees the basis for an open set of standards and tools parsing: text ➠ tree.e. structured nodes. The XPath data model is very similar.com/xml/jaxb/). rendering: tree ➠ text typing.. not in terms of their textual representation. RELAX NG querying. not sequences of tags. The DOM is not a data model. transforming: XPath. SAX data binding: JAXB © SAP AG 2004. SAP TechEd / ABAP 252 / 11 For all kinds of processing except input/output. but an object-oriented interface to another variation of the XML Infoset. there are slight variations in the data models used by other XML standards. but not identical to the XML Infoset. 11 . (I.SAP TechEd ‘04 XML from a Programmer‘s Perspective (1) From a programmer’s perspective.. I. there are no structured attributes. XSLT a generic data structure concept for programming languages primitive: DOM. it is not a completely general model of trees.

.g. 12 .. middleware... This is also hard to capture with an object model. flexible structure which is hard to capture with an object model. The mechanism of XML Namespaces supports the combination of data from several application areas. flexibility. SAP WebDynpro ignorance / abuse too lazy to design & implement adequate object model . An application that uses XML extensively as a platform-independent modeling language is SAP WebDynpro: Both ABAP and Java classes are generated from the same XML source. . E. "Schema evolution" means that the structures of an application tend to change perpetually.. SAP TechEd / ABAP 252 / 12 Document-like data typically have a heterogeneous. especially across multiple systems. e. an XML based message middleware typically defines an "envelope" consisting of a few elements in its own namespace in which arbitrary content may be enclosed.g. open communication format © SAP AG 2004. persistence combine heterogeneous data "framework" applications.SAP TechEd ‘04 XML from a Programmer‘s Perspective (2) Reasons for using XML handle document-like data (e. platform-independent modeling "repositories". forms) represent data under heavy schema evolution extensibility.g.

SAP TechEd ‘04 XML from a Programmer‘s Perspective (3) Using XML Problems solved standard syntax standard tools can model almost anything Problems gained performance drain no semantics unclear relationship with data structures (data conversion) Part II (XML from/to ABAP) schema inflation "Business ML" by standards body X "Business ML" by vendor Y Proprietary format by application Z need for transformations © SAP AG 2004. leading to XML-to-data / data-to-XML transformations. 13 . XML-to-XML transformations must occur in communication middleware or at XML-based interfaces. Data structures in application-language interfaces can also be considered "schemas". Therefore. SAP TechEd / ABAP 252 / 13 Co-existence of different schemas for the same application area is inevitable.

In a document-centric transformation. The development of XSL was originally motivated by document-centric applications. Then it was recognized that the structure-transforming part of XSL was useful by itself... SAP TechEd / ABAP 252 / 14 Data-centric tree transformations: XML adapt different XML formats e. usually not intended for direct viewing by a user. . HTML / Text © SAP AG 2004..SAP TechEd ‘04 Transforming XML with XSLT (1) Tree transformations with XSLT (a) XML tree to XML tree (data-centric) (b) XML tree to text (document-centric) XML Tree XML Tree (a) XSLT (b) . ... both source and result represent data. . the result is a document in a concrete format. produce HTML in Business Server Pages (BSP) HTML / WML / Text e.. and it was separated as XSLT... “message brokering” XML Document-centric tree transformations: XML e.g.... the source is either data or a document in an abstract format. generate program sources from an XML repository In a data-centric application. .g.g... The goal of the transformation is to obtain data in a different format.. 14 . in B2B scenarios. hence the term “stylesheet”.. .

Clumsy to write.0 (not stable) are under development (Working Draft 07/2004). 15 . XSLT 2. current version 1.w3. SAP TechEd / ABAP 252 / 15 XSLT (http://www.w3. Anything done in that language could also be done in XSLT / XPath or in natural extensions thereof. there is another XML query language..0 (quite stable) and XPath 2.0 from 11/1999.org/TR/xpath) are W3C recommendations. under development by the W3C. The fundamental operation is function [“template”] invocation. not variable assignment. XSLT’s concrete syntax is in XML format. “Declarative” means: Say what you want to do. not how you want to do it.. XQuery. but this way it mixes conveniently with XML result fragments XSLT can be processed (esp. using the rule body as a template. the XSLT engine picks the appropriate transformation rule from the program (by matching the context against the rule’s pattern) and instantiates it.org/TR/xslt) and XPath (http://www.SAP TechEd ‘04 Transforming XML with XSLT (2) XSLT* is .: generated) by XSLT Unnecessarily. a high-level tree-transformation language with XML syntax declarative no "state" rule-based pattern matching against source tree functional source tree navigation by XPath expressions compositional result tree construction by XSLT instructions mixed with literal XML fragments "the SQL of the Web" * "Extensible Stylesheet Language / Transformations" © SAP AG 2004. “Rule-based” means: In any given context.

A location step consists of an axis (e.SAP TechEd ‘04 Transforming XML with XSLT (3) XPath example: tree navigation book[editor[name/last='Smith' and name/first='John']] //section[contains(@head. boolean. a node test. child. duplicate-free collection of nodes from an XML document. following-sibling). 16 . which evaluates to a nodeset. and optional predicates. so the expression book yields all children of the current node named “book”.'DOM')] /ancestor::chapter[1]/author book book chapter book editor chapter name last first Smith John section section author head = The Pain of DOM Programming © SAP AG 2004. and nodeset. parent. A nodeset is an unordered. SAP TechEd / ABAP 252 / 16 XPath is a simple expression language with non-XML syntax. The basic types of values on which XPath operates are: String. not with their textual representations. It finds all authors of chapters in books edited by John Smith which contain a section whose heading contains the phrase “DOM”.g. six of which are nested in predicates. The most important type of XPath expression is the location path. number. XPath and XSLT deal only with the semantic values of XML documents (trees). A location path consists of a sequence of location steps. The default axis is child. The location path in the example contains ten location steps.

SAP TechEd ‘04 Intro XML in Open Systems XML in ABAP ABAP – XML Mapping: Concepts ABAP – XML Mapping with XSLT Simple Transformations Summary 17 .

SAP TechEd / ABAP 252 / 18 The iXML library is implemented in the SAP kernel and is made available in ABAP Objects by means of ABAP proxy classes.10) not XMLSchema © SAP AG 2004. Parsing is fast because it is done completely in the kernel.6D): features implemented in kernel (C++) encapsulated in ABAP proxy classes general XML parser / renderer event-based parser (~ SAX) DOM (Document Object Model) superset of DOM level 1 (incl. XML namespaces) Validation DTD (since 6.SAP TechEd ‘04 XML in ABAP: iXML Package (1) The iXML package (since 4. 18 . ABAP objects corresponding to DOM nodes are not created until they are accessed from ABAP.

IF_IXML_NODE. The main factory interface IF_IXML is the origin (direct or indirect) of all iXML objects. documentation: SAP Library [ → “SAP NetWeaver Components” ] → “SAP Web Application Server” → “Basis Services / Communication” → “XML Library” used by many SAP applications © SAP AG 2004. SAP TechEd / ABAP 252 / 19 The design of the iXML package is completely object oriented.) and a “jumpstart” section. etc. inheritance and the factory pattern are frequently used. inheritance. interfaces.e.. The iXML main factory class implements the singleton pattern. all DOM-related interfaces (IF_IXML_ELEMENT.SAP TechEd ‘04 XML in ABAP: iXML Package (2) iXML interfaces in ABAP Objects OO design: interfaces. Stream.g. factories main factory class CL_IXML ~40 Interfaces IF_IXML_PARSER. The SAP Library is found in the Help menu. All iXML objects are integrated into the general ABAP Objects garbage collection mechanism.. when the call cl_ixml=>create( )is done repeatedly. 19 . E.. The iXML documentation is organized in several “packages” (DOM. .. The jumpstart section should be referred to for an introduction to the concepts and services of the iXML library. Parser. In particular. i. it yields the same object.) are explained. in the “DOM” package. etc.

element = document->create_element( name = 'date' ). SAP TechEd / ABAP 252 / 20 20 . © SAP AG 2004. element->set_attribute( name = 'format' value = 'yyyymmdd' ).SAP TechEd ‘04 XML in ABAP: iXML Package (3) iXML example programs in package SIXML_TEST parsing into a DOM: manipulating a DOM: rendering a DOM: validating with a DTD: T_PARSING_DOM T_DOM_MANIPULATE T_RENDERING_DOM T_DTD_VALIDATION data element type ref to if_ixml_element. element->set_value( value = ldate ).

The SAP XSLT processor is scalable because it adopts a byte code / virtual machine approach (similar to Java and ABAP). transport © SAP AG 2004.SAP TechEd ‘04 XML in ABAP: XSLT Processor (1) The SAP XSLT processor (since 6.10): features performance scalability interoperability conformance integration integration implementation in SAP kernel (C++) optimization for server-side execution with iXML package (except for justified omissions) into language environment call from ABAP. SAP TechEd / ABAP 252 / 21 Scalability is essential: Performance must not degrade when the number of XSLT programs in parallel use increases. the byte code is loaded and executed on the virtual machine in the SAP kernel. call back to ABAP into development environment workbench. When an XSLT program is run. 21 . An XSLT program is parsed and analysed only at development time. It is then compiled into a byte code (developed by SAP specifically for XSLT) which is stored in the database. An application-server-global buffer (the same which is used for ABAP programs) prevents frequent re-loading from the database.

the SAP namespace need not be declared in extension-elementprefixes. string-pad.0 features xsl:number Forwards-compatible processing.0 features: generalized location paths A/(B|C). find-last-of. find-first. min. SAP TechEd / ABAP 252 / 22 Forwards-compatible processing is not supported because it is not expected that XSLT programs using a higher XSLT version will be maintained in a SAP system supporting a lower XSLT version.sap. find-first-of. Implemented XPath 2. generic namespace *:A. Examples of extension functions: upper-case.e2)] = if [e0] then [e1] else [e2] ] ] ] ] Variable binding: [sap:let(x. lower-case. find-first-not-of. exp. otrtext. column. findlast. Conversely. fallback processing Attribute sets Namespace aliasing Implemented XSLT 2. find-last-not-of.e1.e2)] = [e2] (x← [e1]) ] ] ] 22 . Conditional expression: [sap:if(e0. ends-with. parse-xpath. max. abs.SAP TechEd ‘04 XML in ABAP: XSLT Processor (2) Unimplemented XSLT 1. and it is not expected that XSLT programs using extension instructions of other XSLT processors will be maintained in the SAP repository.com/sapxsl ABAP Calls (by extension function or extension instruction) many extension functions XPath 2. line.0 features © SAP AG 2004. otr-string. SAP extensions are recognized automatically.e1. log. Stylesheet inclusion and import uses the sap:name attribute instead of the href attribute in order to refer to XSLT programs (programs are in the SAP repository). Fallback is not supported because forwards-compatible processing is not supported. escaping quotes in string literals ("abc""def").0 features Grouping (xsl:for-each-group) User-defined XPath functions (xsl:function) Multiple results (xsl:result-document) Extensions: namespace http://www. timestamp.

Multiple return values can be retrieved (less elegantly) by an extension instruction: <sap:call-external name="obj" method="METH"> <sap:callvalue param="IP" select="42"/> param="CP" select="'foo'"/> <sap:callvalue <sap:callvariable param="EP" name="v1" type="number"/> <sap:callvariable param="CP" name="v2"/> </sap:call-external> Here.'foo') + 1"/> XSLT variable bound to ABAP object XPath parameter values © SAP AG 2004. For class methods and constructors. The attribute kind of sap:external-function specifies whether it is a class or an instance method (default) or a constructor. 42. XSLT variables v1 and v2 are bound to ABAP exporting / changing parameters EP and CP. SAP TechEd / ABAP 252 / 23 The function name must use a non-reserved namespace. Appropriate conversions are applied between XPath and ABAP values. The object can come from a program parameter. 23 . The variable scope is the same as for xsl:variable.SAP TechEd ‘04 XML in ABAP: XSLT Processor (3) Extension example: ABAP Call by extension function from XPath At top level: Declare external function <sap:external-function name="p:f1" method="METH"> <sap:argument param="IP_1"/> function parameter declarations <sap:argument param="IP_2"/> <sap:result param="EP" type="number"/> </sap:external-function> function result declaration In XPath expression: Invoke instance method on external object <xsl:value-of select = "p:f1($obj. a constructor call. Nodesets correspond to iXML node collections. Invocations of instance methods require an external object as first function argument (as in the common Java binding mechanism). or a preceding ABAP call. the ABAP class is specified in the class attribute.

. A dynamic list of parameters is passed as a table of type ABAP_TRANS_PARMBIND_TAB. Its use is deprecated because it requires the application to take care of the lifetime of the processor object (which the ABAP instruction handles automatically). they cannot have a URI component. XML source: (x)string or table or REF TO IF_IXML_ISTREAM or REF TO IF_IXML_NODE XML result: (x)string or table or REF TO IF_IXML_OSTREAM or REF TO IF_IXML_DOCUMENT CATCH cx_transformation_error INTO exc. An alternative way to execute XSLT programs is the class CL_XSLT_PROCESSOR. © SAP AG 2004. (ii) Messages produced by the XSLT program are to be retrieved. SAP TechEd / ABAP 252 / 24 This syntax example shows the case “source XML. however. Any ABAP type with a “natural” conversion to an XPath type can be passed as a parameter. Since the parameter names must be legal ABAP names. Since ABAP is case insensitive. Basically there are two exceptions to this rule: (i) Separate evaluation of XPath expressions (see class documentation). The syntax for “source ABAP” / “result ABAP” follows later. runtime errors throw exceptions ENDTRY. p_n = my_par_n or (my_par_table) SOURCE XML RESULT XML my_xml_source my_xml_result. Both character and binary tables are allowed as the XML source and result.SAP TechEd ‘04 XML in ABAP: Invocation of XSLT ABAP statement CALL TRANSFORMATION static or dynamic call of TRY. they must be declared in upper case (because XSLT is case sensitive). . In the XSLT program. result XML”. 24 .. the case of the parameter names does not matter... XSLT program CALL TRANSFORMATION my_trans or (my_trans_name) program parameters PARAMETERS p_1 = my_par_1 .

display as a list. In this case. Transform to a DOM.g. programs which are correct in isolation may lead to errors in an including program (e. However. → Transformation object tree. XSLT programs are assigned to development classes / packages. → Transformation direct: transaction STRANS (6. From the workbench point of view... Changes and transports are under the control of the transport system. This is in contrast with CSS stylesheets. 25 . then render the DOM with iXML methods. View result in HTML viewer. due to multiply declared templates). Only active programs can be included or imported by other programs.20: XSLT_TOOL) testing: transaction XSLT programs must be activated before use check / activate triggers compilation maintenance API: function XSLT_MAINTENANCE © SAP AG 2004. XSLT sources are primarily programs. SAP TechEd / ABAP 252 / 25 XSLT programs are development objects.. only correct programs can be included / imported. display the string as a list.SAP TechEd ‘04 XML in ABAP: XSLT Development Workbench integration SE80: Edit object → More. Send result to a frontend file. The XSLT tester loads the XML source from a frontend file. like ABAP programs. Consequently. which are mere content. They are not in the MIME repository. context menu: Create → More. It offers four modes: Transform directly to a string. An XSLT program can not be activated if it contains syntax errors. XSLT output settings have no effect.. That they are in XML format is secondary.

SAP TechEd / ABAP 252 / 26 26 .SAP TechEd ‘04 Demo Demo Transformations in the ABAP Workbench Check – Activate – Test “Flights” example (SSTDEMO2): XML to XML with XSLT XML to HTML with XSLT © SAP AG 2004.

SAP TechEd ‘04 Intro XML in Open Systems XML in ABAP ABAP – XML Mapping: Concepts ABAP – XML Mapping with XSLT Simple Transformations Summary 27 .

.. respectively. 28 .SAP TechEd ‘04 XML  ABAP: Application Areas Who needs (de)serialization? XML-based communication middleware SAP Exchange Infrastructure (XI) Web Services XML tree XML-based persistence SAP Archiving serialization deserialization data tree XML repositories ↔ DB tables import / export SAP WebDynpro metadata application-specific uses XML via HTTP / in database / . the terms "marshalling" and "unmarshalling" are often used in place of "serialization" and "deserialization". SAP TechEd / ABAP 252 / 28 In the Java data-binding community. © SAP AG 2004.

and that there are other applications (maybe physically on the same server. which leads to the "inside" / "outside" classification. The perspective is that of an ABAP developer. outside inside external applications external XML format structure difference XML-based communication ABAP applications ABAP data structure ABAP functionality © SAP AG 2004.SAP TechEd ‘04 XML  ABAP: Structure Mapping The structure mapping problem The general situation depicted here is that there is an ABAP system implementing certain functionality for which it offers an ABAP interface. SAP TechEd / ABAP 252 / 29 29 . but not in the ABAP system) offering an XML-based interface.

40) dedicated XML / data transformation language no conceptual "canonical encoding" indirection © SAP AG 2004.20) canonical XML encoding of data structures + transformation with XSLT symmetric approach (6. The two symmetric approaches presented here are original SAP developments. The first symmetric solution is based on an encoding of arbitrary ABAP data structures in XML: the canonical XML format asXML.SAP TechEd ‘04 XML  ABAP: Approaches Which side is driving? inside-out approach outside-in approach symmetric approach (6. It is based on a dedicated XML / data transformation language. This format is used as the source or result of XSLT transformations. "Symmetric" approaches retain given structures on each side. 30 . "Outside-in": The XML structure determines the ABAP structure. SAP TechEd / ABAP 252 / 30 "Inside-out": The ABAP structure determines the XML structure. The second symmetric solution works without a canonical XML format.

20 kernel: Using CALL TRANSFORMATION and the identity transformation. this is usually not sufficient. it is the problem of the "outside" applications.. outside inside 3 canonical XML encoding 6. For a communication format.. modifications are often desirable. any ABAP data structure can be represented in a canonical XML encoding. or even structural changes. because it exposes directly the "inside" data structures. different XML names.g. XML-to-XML transformations will have to be performed. Note that such a transformation is not provided "inside" in this approach. Consequently.SAP TechEd ‘04 XML  ABAP: Inside-out The inside-out approach external XML format external mapping (XSLT. it would usually not be the best choice. e. SAP TechEd / ABAP 252 / 31 31 . But for communication with external applications. element / attribute distinctions. as they will require different XML formats.20 kernel XML handler ABAP data structure 1 ABAP functionality © SAP AG 2004.) 2 The inside-out approach is available with the 6. Even if the canonical format were accepted by the "outside".

In addition to the proxy classes. it may be written by hand. every XML schema that a system must handle leads to the generation of proxy classes (about as many as node types in the schema). outside inside 1a external XML format 6.SAP TechEd ‘04 XML  ABAP: Outside-in The outside-in approach ("data binding") Numerous data binding frameworks are available in Java. However. Alternatively. An even more radical outside-in approach would be to use the proxy classes directly as the interface and possibly even as the internal data model of the application. SAP TechEd / ABAP 252 / 32 32 . most notably JAXB. Thus. this approach is almost as inadequate as using the DOM as a data model: Data communication structures are hardly appropriate as data processing structures. The basic idea is always that XML structures are somehow reflected in Java structures which are generated from an XML schema. adapter code for given "inside" functionality may also be generated.20 kernel 2 generated [ generated ] 3 1b XML handler ABAP proxy ABAP proxy interface ABAP adapter ABAP data structure ABAP functionality © SAP AG 2004.

SAP TechEd ‘04 XML  ABAP: Symmetric The symmetric approach (6.20) This picture omits a small piece of code that actually invokes the XSLT program with the XML document and ABAP data structure.20 Kernel) XSLT programs ABAP data structure 1 ABAP functionality © SAP AG 2004. SAP TechEd / ABAP 252 / 33 33 . This (trivial) adapter code could be located either in the application (if the corresponding XML format is implemented as part of its interface) or on top of it. The XSLT programs work on asXML. outside inside 1 external XML format 2 XSLT Mapping Engine (6. the canonical ABAP Serialization XML format (more details later).

for the evaluation of the XPath expressions in it. more precisely. SAP TechEd / ABAP 252 / 34 The first step in the "outbound XML" case is the construction of the ABAP data structure's asXML representation as a DOM (implicitly done by the CALL TRANSFORMATION statement).SAP TechEd ‘04 ABAP XML with XSLT Outbound XML XML XSLT (outbound) transform DOM to outbound XML construct canonical DOM for data tree ABAP © SAP AG 2004. This is a prerequisite for the "outbound XSLT" program. 34 . The DOM representation is the basis for powerful XPath navigation on the data structure. it is also the cause of considerable memory consumption. But of course.

Note that the "inbound XSLT" program is different from the "outbound XSLT" program. data structure traversal. The construction of the asXML tree is only conceptual. inbound and outbound XML have approximately the same complexity: DOM construction. but produces it. 35 . In fact. the ABAP data structure is filled directly. Thus.SAP TechEd ‘04 XML ABAP with XSLT Inbound XML XML XSLT (inbound) parse inbound XML to DOM transform DOM to data tree (directly) ABAP conceptual: transform to canonical XML tree © SAP AG 2004. SAP TechEd / ABAP 252 / 35 The first step in the "inbound XML" case is the construction of the XML DOM (if it is received as text). It does not consume asXML. XSLT exceution.

. it is left open how XML documents enter and leave the system. mapping is not limited to a "call / parameter" format. For example. communication could utilize the HTTP capabilities of the SAP Web AS.. Any XML format can be processed. HTTP Scope: not a communication mechanism not an RPC framework only a mapping engine Web Services .e.. i. SAP TechEd / ABAP 252 / 36 The ABAP / XML mapping engine presented here does not cover communication. Also. © SAP AG 2004.. the mapping is not tied to any kind of RPC (Remote Procedure Call) mechanism.SAP TechEd ‘04 XML  ABAP with XSLT: Scope .. 36 .

SAP TechEd ‘04

Intro XML in Open Systems XML in ABAP ABAP – XML Mapping: Concepts ABAP – XML Mapping with XSLT Simple Transformations Summary

37

SAP TechEd ‘04

XML 

ABAP: Invocation of XSLT

Serialization
CALL TRANSFORMATION ... PARAMETERS ... option_1 = string ... option_n = string OPTIONS SOURCE XP_1 = my_var_1 ... XP_n = my_var_n or (my_var_table) RESULT XML my_xml_result.

Deserialization

binding of program variables to symbolic XML names

CALL TRANSFORMATION ... PARAMETERS ... option_1 = string ... option_n = string OPTIONS SOURCE XML my_xml_source RESULT XP_1 = my_var_1 ... XP_n = my_var_n or (my_var_table).
© SAP AG 2004, SAP TechEd / ABAP 252 / 38

When the source of a transformation is a set of ABAP variables, XML bindings for these variables are specified after the keyword SOURCE. If the variables are the transformation result, then the bindings are specified after RESULT. An XML binding X = V associates an ABAP variable V with an XML name X in the asXML document. (Without this indirection, a transformation would be tied to a fixed set of variable names.) Since ABAP is case insensitive and normalizes parameter names to uppercase, the corresponding XML name is uppercase. Consequently, XSLT programs must specify these names in uppercase, since XML is case sensitive. In order to avoid confusion, XML names in ABAP should be specified in uppercase as well. By combining SOURCE and RESULT clauses, ABAP-to-ABAP is also possible. The option XML_HEADER = 'NONE' | 'WITHOUT_ENCODING' | 'FULL' controls output of the XML header <?xml … ?>. The option INITIAL_COMPONENTS = 'SUPPRESS' suppresses ABAP fields with initial value during serialization. The option VALUE_HANDLING = 'MOVE' tolerates “illegal” values (e.g. non-digits in type N fields), corresponding to the behavior of the MOVE instruction.

38

SAP TechEd ‘04

Exercise

Exercise
“Customers” example: My first ABAP-XML Mapping (XSLT) ABAP to XML XML to ABAP

© SAP AG 2004, SAP TechEd / ABAP 252 / 39

39

SAP TechEd ‘04

ABAP

XML: Invocation of XSLT (Example)

ABAP fragment
DATA num TYPE P LENGTH 5 DECIMALS 2. DATA txt TYPE STRING. num = '1.23-'. identity transformation txt = 'Yes, 2 < 3'. CALL TRANSFORMATION id SOURCE Foo = num bar = txt RESULT XML my_xml_result.

XML result fragment
format depends on corresponding ABAP variable ... <FOO>-1.23</FOO> <BAR>Yes, 2 &lt; 3</BAR> ... symbolic names are normalized to uppercase

© SAP AG 2004, SAP TechEd / ABAP 252 / 40

When the transformation is not the identity (the required result XML format is not asXML), it must process the asXML representation generated for the ABAP source variables. Data is written in the canonical (XML Schema) lexical representation.

40

. GET REFERENCE OF num INTO bind-value. deserialization is more liberal than serialization (e. bind-name = APPEND bind bind-name = APPEND bind CALL TRANSFORMATION ID SOURCE XML my_xml_source RESULT (itab).. Thus. <FOO> -1. 2 < 3 © SAP AG 2004. TO itab. DATA DATA DATA DATA bind TYPE abap_trans_resbind. 1. 'BAR'. 3</BAR> .23Yes. itab TYPE abap_trans_resbind_tab.. WRITE: / num. Data is accepted in any form that matches the lexical representation. 41 . DATA txt TYPE STRING. 'FOO'. num TYPE P LENGTH 5 DECIMALS 2..23 </FOO> <BAR>Yes. / txt.SAP TechEd ‘04 XML ABAP: Invocation of XSLT (Example) XML source fragment insignificant whitespace . SAP TechEd / ABAP 252 / 41 When the transformation is not the identity (the required source XML format is not asXML). XML-to-ABAP example with dynamic parameter passing: TYPE-POOLS: abap.g. GET REFERENCE OF txt INTO bind-value. txt TYPE STRING. ABAP type determines expected XML content CALL TRANSFORMATION id SOURCE XML my_xml_source RESULT Foo = num bar = txt. 2 &lt. leading and trailing spaces are not significant for most datatypes). TO itab. it must generate the asXML representation required for the ABAP result variables. ABAP fragment DATA num TYPE P LENGTH 5 DECIMALS 2..

XSLT programs would have to be used to do much more work than structural transformations. SAP TechEd / ABAP 252 / 42 The asXML format adopts XML Schema datatypes (http://www.) 42 .org/TR/xmlschema-2). on which many XML standards (e. SOAP) are based. especially string operations.SAP TechEd ‘04 XML  ABAP with XSLT: asXML Format ABAP Types and the asXML Format ABAP → asXML : determines asXML → ABAP : determines type of ABAP source variable(s) generated asXML representation type of ABAP result variable(s) required asXML representation source / result ABAP variables must be typed A Data Exchange Format XML-Schema datatypes "Human-readability" not a top priority no dependence on customization no dependence on locale settings no use of conversion exits © SAP AG 2004.g.w3. (If asXML used a more ABAP-like format.

year 0).T: No timezone. no leading 0s (ok in input). no after-decimal-point trailing 0s (ok in input). SOAP).SAP TechEd ‘04 asXML Format: Simple Types Simple Types ABAP Type STRING C N I INT1. N: String of digits. leading 0s are significant (restriction of XML Schema type 'string').g. Graphs of objects or data references need not be tree-shaped. uppercase E (lowercase ok in input).14E-2 2001-08-20 20:15:01 RWeJqw== q83v Comment string of characters string of digits number ISO 8601 date/time base64-encoded binary data P F D T XSTRING X decimal double date time base64Binary 456789AB base64Binary * Internal string representation of ABAP datatypes © SAP AG 2004. F: leading -. the implementer of a class has the possibility to state whether its instances can be serialized and if so. X: Base-64 encoding is commonly used in an XML context (e. C: Only leading spaces are significant.23-3. short XML Example Hi Hello 001234 -123 -1.23 -3. SAP TechEd / ABAP 252 / 43 STRING: Leading and trailing spaces are significant. Here.14E-2 20010820 201501 ABCDEF XML Schema Type string string string ([0-9]+) int unsignedByte. I. INT2 ABAP Example* Hi Hello 001234 1231. Therefore. some invalid dates are allowed (e. year in range 1-9999 (less than is allowed by XML Schema type).g... P.e. i. corresponding asXML documents contain in-document references to represent such graphs. For objects. D. 43 . object and data references are not presented in further detail. XSTRING. which values constitute the serialized object.

© SAP AG 2004. the "matching algorithm" is applied recursively. miles-born = '19260526'. Program-local types can be used. components without a corresponding XML element keep their value. Order in input is insignificant. including structures and internal tables.. miles-name = 'Miles Davis'. SAP TechEd / ABAP 252 / 44 component names determine XML sub-element names All types are allowed in components. Additional subelements are ignored in XML input. components are addressed by name. DDict Structure PERSON: NAME TYPE STRING BORN TYPE D .. The DDict type PERSON is hypothetical. In contrast with MOVE-CORRESPONDING. Matching components are set as by MOVE-CORRESPONDING. Components are serialized in the order in which they are defined in the structure. <LEGEND> <NAME>Miles Davis</NAME> <BORN>1926-05-26</BORN> </LEGEND> . CALL TRANSFORMATION id SOURCE RESULT XML LEGEND = miles my_xml_result..SAP TechEd ‘04 asXML Format: Structures Structures DATA miles TYPE person. 44 ..

one-name = 'Charlie Parker'. one-name = 'Miles Davis'. sorted. The example XML fragments are pretty-printed only for presentation. one-born = '19200829'. the name of the element representing a table line is irrelevant. Table lines for sorted tables do not have to be sorted (will be sorted automatically).. one-born = '19260923'.. During deserialization.. . APPEND one TO itab. one-born = '19260526'.. APPEND one TO itab. hashed) and any line type (including nonstructures) is allowed. DATA: itab TYPE STANDARD TABLE OF person.SAP TechEd ‘04 asXML Format: Internal Tables Internal Tables DATA: one TYPE person. <GREATEST> <PERSON><NAME>John Coltrane</NAME> <BORN>1926-09-23</BORN></PERSON> <PERSON><NAME>Miles Davis</NAME> <BORN>1926-05-26</BORN></PERSON> <PERSON><NAME>Charlie Parker</NAME><BORN>1920-08-29</BORN></PERSON> </GREATEST> . one-name = 'John Coltrane'. SAP TechEd / ABAP 252 / 45 Any kind of table (standard. CALL TRANSFORMATION id SOURCE GREATEST = itab RESULT XML my_xml_result. APPEND one TO itab. line type from DDict (or <item>) © SAP AG 2004. 45 .

<XP_n> . where the (arbitrary) prefix asx is bound to the asXML namespace http://www.. For each asXML representation of an ABAP variable bound to an XML name.sap.0. </XP_1> ..sap.com/abapxml.. The top-level element must be <asx:abap>. Currently it must be set to 1..com/abapxml"> <asx:values> list of ABAP-XML bindings <XP_1> . SAP TechEd / ABAP 252 / 46 The version attribute indicates the asXML version used in the document...SAP TechEd ‘04 asXML Format: Envelope asXML Envelope <asx:abap version = "1.0" xmlns:asx = "http://www. </XP_n> </asx:values> <!-additional XML elements for objects and referenced data structures --> </asx:abap> © SAP AG 2004. there is an element with this XML name inside the asx:values element. 46 .

SAP TechEd ‘04 Exercise Exercise “Customers” example: Full version (XSLT) © SAP AG 2004. SAP TechEd / ABAP 252 / 47 47 .

SAP TechEd ‘04 XML  ABAP with XSLT: Advantages Advantages of the XSLT solution no restrictions arbitrary XML schemas arbitrary data & object types graphs of objects arbitrarily complex structural transformations no redundancy no generation of schemas from types (schema inflation) no generation of types from schemas (type inflation) each side retains its structures high abstraction level no low-level XML handling in applications separate. SAP TechEd / ABAP 252 / 48 Data binding approaches are usually restricted to certain classes of XML schemas and offer only limited mapping capabilities. and programmers are not tempted to abuse the DOM as a generic data structure. With XSLT as a distinct programming language. mapping code is clearly separated from application code. but only a configuration mechanism. expressive transformation language © SAP AG 2004. Controlling the amount of types in a system is generally a good thing. By not generating types from schemas. This is because they do not employ a programming language. 48 . the symmetric approach prevents the schema inflation in the "outside" XML world to cause a type inflation on the "inside".

iXML and the SAP XSLT processor work internally with encoding UTF-16. frequent conversions are necessary.e. a DOM typically requires about 10 times the memory of the XML text representation – which is already large compared to the data structure. Static type checking is impossible because XPath navigation on the asXML input (serialization) or control flow in the XSLT templates (deserialization) is not statically analyzable. Due to the OO overhead. SAP TechEd / ABAP 252 / 49 asXML DOMs can easily become huge. one for ABAP XML resource consumption (Time & Space) T / S : DOM construction (on source side) T : codepage conversions (internal encoding ≠ SAP CP) T : XSLT engine overhead (complex state. If this is not the SAP codepage (i.SAP TechEd ‘04 XML  ABAP with XSLT: Disadvantages Disadvantages of the XSLT solution learning XSLT overkill for simple conversion tasks no tool support asymmetric programs one for XML ABAP. powerful operations) no static type checking © SAP AG 2004. 49 . the system is non-Unicode).

SAP TechEd ‘04 Intro XML in Open Systems XML in ABAP ABAP – XML Mapping: Concepts ABAP – XML Mapping with XSLT Simple Transformations Summary 50 .

51 .0 and Web Services. Simple Transformations are the basis for XI 3. SAP TechEd / ABAP 252 / 51 The XSLT-based solution is used in XI 2.SAP TechEd ‘04 XML  ABAP without XSLT: Requirements Requirements for a dedicated XML/ABAP mapping engine time: increase throughput by factor ≥ 10 space: increase / eliminate upper limit on size of data ease of use simple syntax & semantics. statically type-checked tool support for creating mappings one program for XML→ABAP and ABAP→XML Deliberate trade-offs lower expressive power (but cover 90% of typical applications) not usable for XML ↔XML "Simple Transformations" © SAP AG 2004.0.

Serialization Deserialization linear linear random access (XPath) linear (stream reader) linear ABAP result (modulo tree construction component order) random access 52 .SAP TechEd ‘04 Simple Transformations: Tree Access Tree access in XSLT vs. SAP TechEd / ABAP 252 / 52 XSLT programs always produce the result in strictly linear fashion. However. In contrast. order of ABAP structure components is irrelevant during deserialization. Simple Transformations XSLT ABAP source tree navigation XML result tree construction XML source tree navigation random access (XPath on canonical DOM) Simple Transfomations random access © SAP AG 2004. Simple Transformations always access the XML document in linear order (even if it is on the source side) and the ABAP data structure in non-linear order (even if it is on the result side).

in document order (with "lookahead 1" on XML source) . value of nodes) value maps covers most data mappings in practice © SAP AG 2004.g. accessing each node in the data tree any number of times accessing each node in the XML tree at most once..: constant values. which includes (any combination of) . SAP TechEd / ABAP 252 / 53 53 .: structure-component / element names) projections (omission of sub-trees) permutations (changes in sub-tree order) constants (e...SAP TechEd ‘04 Simple Transformations: Expressive Power Anything that can be done with . insertion of tree levels) defaults (for initial / special values) conditionals (e..: existence of sub-trees...g.g. renamings (e.

SAP TechEd ‘04 Simple Transformations: Key Features (1) Programs are XML templates literal XML with interspersed instructions declarative. SAP TechEd / ABAP 252 / 54 The concept of literal XML with interspersed instructions is the same as in XSLT. straightforward semantics <Customers> <tt:loop ref="CUSTTAB"> <LastName> <tt:value ref= "NAME. 54 .LAST"/> </LastName> </tt:loop> </Customers> Data tree access by node references instructions access data by simple “reference expressions” all named children of a data node are accessible by name tables are accessible as a whole (all lines or none) © SAP AG 2004.

e. by not serializing a data component at all (projection). 55 .SAP TechEd ‘04 Simple Transformations: Key Features (2) Programs are reversible serialization : deserialization : write (produce) tokens to stream match (consume) tokens from stream invocation determines direction if no asymmetric construct is used: D[program] ( S[program] (data) ) = data S[program] ( D[program] (document) ) ≈ document (D: deserialization. the "reversibility" equations do not hold for programs that lose information. S: serialization) © SAP AG 2004. SAP TechEd / ABAP 252 / 55 Of course.g.

g.SAP TechEd ‘04 From 6. iXML streams) exception hierarchy generalized (new common root) uniform appearance (easy to switch from XSLT solutions) © SAP AG 2004. SAP TechEd / ABAP 252 / 56 56 .40 “XSLT” is generalized to: “Transformation” = “XSLT” or “Simple Transformation” workbench integration same workbench / transport object type same access paths transformation type determined in creation dialog XSLT_MAINTENANCE works for both types ABAP integration CALL TRANSFORMATION works for both types both types take same XML input / output types (e.20 to 6.

SAP TechEd / ABAP 252 / 57 Like the SAP XSLT processor. execution takes place on a dedicated engine (neither ABAP nor XSLT). It works directly with UTF-8. in particular the load table and the program buffer. However. which is the encoding that is used most frequently for XML communication.SAP TechEd ‘04 Simple Transformations: Implementation Virtual machine (VM) compilation of programs to bytecode storage of bytecode in database / buffering in shared memory interpretation of bytecode in kernel (lean engine) scalable performance XML stream reader / writer reader: efficient "token pull" discipline specialized for standard encoding UTF-8 also usable directly from ABAP: classes CL_FX_READER. 57 . the Simple Transformations implementation re-uses the infrastructure for ABAP programs. CL_FX_WRITER limit on data size lifted © SAP AG 2004.

SAP TechEd ‘04 Demo Demo “Flights” example (SSTDEMO2): ABAP to XML with ST XML to ABAP with ST © SAP AG 2004. SAP TechEd / ABAP 252 / 58 58 .

59 .sap. or it is the (single) unnamed template. as in XSLT. If there are several templates. or in an including program). In most cases a program will contain only one template. There is no concept of template selection by pattern matching. then the main template is either specified by a template="name" attribute on the tt:transform element. SAP TechEd / ABAP 252 / 59 formal root name(s) transformation template(s) A program can have several named templates for the purpose of applying them several times (in the main template.com/transformation-templates"> ( <tt:include name="name"/> )* ( <tt:root name="name"/> )* ( variable / parameter declaration )* ( <tt:template [name="name"]> [ context declaration ] template content </tt:template> )* </tt:transform> © SAP AG 2004.SAP TechEd ‘04 Simple Transformations: Programs <tt:transform xmlns:tt="http://www.

–} to ~ map ~ to ∗ <tt:value ref="CHAR" map=" val('*') = xml('~'). +. val('+'.SAP TechEd ‘04 ST Constructs: Value Value S D ref-node value to XML XML value to ref-node <tt:value [ref="ref"] [map="mapping-list"] /> example copy value from/to field CHAR. SAP TechEd / ABAP 252 / 60 60 .'-') > xml('~')" /> © SAP AG 2004. with special mappings: S D map {∗.

SAP TechEd / ABAP 252 / 61 <Time zone="CET" tt:value-ref="TIME"/> <Time zone="CET">12:59:00</Time> 61 .SAP TechEd ‘04 ST Constructs: Literal Element / Attribute Literal element / attribute S D write literal content match literal content (no match → error) <element-name [literal-attributes] [ tt:ref="ref" | tt:value-ref="ref" ]> [template content] </element-name> example <Time zone="CET" tt:ref="TIME"> <tt:value/> </Time> alternative XML © SAP AG 2004.

SAP TechEd / ABAP 252 / 62 <Time>12:59:00 CET</Time> 62 .SAP TechEd ‘04 ST Constructs: Literal Text Literal text S D write literal text match literal text text <tt:text>text</tt:text> example <Time> <tt:value ref="TIME"/> <tt:text> CET</tt:text> </Time> alternative <Time> <tt:value ref="TIME"/> CET</Time> XML © SAP AG 2004.

SAP TechEd / ABAP 252 / 63 63 .SAP TechEd ‘04 ST Constructs: Attribute Attribute S D write attribute match attribute <tt:attribute name="attribute-name" [ref="ref"]> [template content] </tt:attribute> <tt:attribute name="attribute-name" value-ref="ref" [map="mapping-list"] /> example <Time tt:ref="ZTIME"> <tt:attribute name="zone" value-ref="TZONE"/> <tt:value ref="TIME"/> </Time> XML <Time zone="CET">12:59:00</Time> © SAP AG 2004.

elements are introduced according to the canonical XML representation of ABAP data structures. it is assumed that the line type of ZTIME_TAB is a dictionary type ZTIME with two components TZONE and TIME. 64 . In this case. Below the root node. SAP TechEd / ABAP 252 / 64 Note that tt:copy does not introduce an element for the root of the tree being copied (in this case.SAP TechEd ‘04 ST Constructs: Deep Copy Deep Copy S D copy sub-tree below ref-node to stream copy sub-tree below current XML node to ref-node <tt:copy ref="ZTIME_TAB"/> <ZTIME> <TZONE>CET</TZONE> <TIME>12:59:00</TIME> </ZTIME> <ZTIME> <TZONE>EST</TZONE> <TIME>06:59:00</TIME> </ZTIME> <tt:copy [ref="ref"]/> example XML © SAP AG 2004. the internal table itself).

65 . insert lines into table until matching fails <tt:loop [ref="ref"] [name="line-name"] > template content </tt:loop> example <tt:loop ref="ZTIME_TAB"/> <tt:copy/> </tt:loop> XML <TZONE>CET</TZONE> <TIME>12:59:00</TIME> <TZONE>EST</TZONE> <TIME>06:59:00</TIME> © SAP AG 2004. This is necessary if you want to refer to (components of) this line from within a nested loop: Having declared name="line-name". SAP TechEd / ABAP 252 / 65 The name attribute on tt:loop serves to declare a symbolic name for the current table line which is in scope in the body of the loop.SAP TechEd ‘04 ST Constructs: Table Loop Table Loop S D evaluate content for all lines of table evaluate content. you can use the syntax $line-name as a reference expression in order to refer to the current line of this loop.

SAP TechEd / ABAP 252 / 66 66 .SAP TechEd ‘04 Exercise Exercise “Customers” example: My first Simple Transformation © SAP AG 2004.

The “data condition” evaluated during serialization is the conjunction of the assertion-list and the check-clause. check TIME > 000000 © SAP AG 2004. TZONE:='CET'.SAP TechEd ‘04 ST Constructs: Basic Conditional (1) Basic Conditional S D <tt:cond [data="assertion-list"] [if data condition is true:] [[s-|d-]check="check-clause"]> evaluate template content template content [if template content matches:] </tt:cond> evaluate template content [establish assertions] [evaluate check-clause] <tt:cond data="TZONE='CET'" check="TIME>T('000000')"> <CET tt:value-ref="TIME"/> </tt:cond> example S if TZONE='CET' and TIME = t > 000000: write <CET>t</CET> D if <CET>t</CET>: TIME:=t. or (v) an application of a template whose body is a pattern. then it is evaluated unconditionally during deserialization. If the body is not a pattern. 67 . The template content of the conditional is a pattern if it is (i) a single literal element [with content]. then the template content is evaluated unconditionally during serialization. (iv) the keyword <tt:empty/> (matching empty content). SAP TechEd / ABAP 252 / 67 Using s-check / d-check instead of check causes the check-clause to be evaluated only during serialization / deserialization. or (vi) a loop whose body is a pattern. (iii) a single non-empty literal text. If there is no such condition. Deserialization fails if evaluation of the check-clause yields false or if a value different from the assertion value is assigned to a node with an assertion (during evaluation of the body). (ii) a tt:attribute instruction.

ref('PRICE. SAP TechEd / ABAP 252 / 68 The general form of the ref-node syntax for expressions is necessary because ABAP and the dictionary admit almost any character in names.SAP TechEd ‘04 ST Constructs: Basic Conditional (2) Value Assertions ref-nodes in expressions ref : • general: ref('name') • simplified: name for name of the form letter ( letter | digit | _ )* <tt:cond data = " assertion ( . which is impossible with the Simple Transformations expression parser (a reduced variant of the XPath parser). 68 .%OFF') = P('7. assertion )* "> • initial(ref) • ref = constant constants • C('string') or 'string' • D('yyyymmdd') example COUNT = 1.5') • F(float) • I(integer) or integer • N('digits') • P('decimal') • T('hhmmss') • X('xstring') © SAP AG 2004.

!=. containing a comma-separated list of node-existence and node-type checks. then the matching part of the XML source (e. This list of “using assertions” is evaluated first. >=} • initial(ref). <. the XML element) is skipped. SAP TechEd / ABAP 252 / 69 Apart from the value assertions and check-clause. tt:cond may have an attribute using. then the condition body is not evaluated. If a using assertion fails during deserialization and the body is a pattern. If it fails (because a node does not exist or does not have the required type).g. <=. >.SAP TechEd ‘04 ST Constructs: Basic Conditional (3) Check-clause expr : • ref op ( constant | ref ) with op in {=. not-initial(ref) • exist(ref) (node-existence check) • t-op(ref) with t-op = type-C|D|F|I|N|P|T|X (node-type check) • expr and expr • expr or expr • not(expr) • ( expr ) example TIME>CTIME and (initial(TZONE) or TZONE='CET') <tt:cond [s-|d-]check="expr" > © SAP AG 2004. 69 .

.SAP TechEd ‘04 ST Constructs: Composite Conditional Switch S D evaluate first case with true data condition evaluate first case with matching pattern <tt:switch> case* </tt:switch> case : • <tt:cond .> • <tt:s-cond . If such a case exists..> (only deserialization) Group S D evaluate all cases with true data condition evaluate all cases with matching pattern <tt:group> case* </tt:group> © SAP AG 2004.> (only serialization) • <tt:d-cond . it is the serialization default. At most one case in a switch may have no pattern content.. If such a case exists.. it is the deserialization default. SAP TechEd / ABAP 252 / 70 At most one case in a switch may have no data condition. 70 ...

parameters. In particular. The context of the main template is the set of roots and variables / parameters declared at the top level of the transformation. In contrast. 71 .e. and variables.SAP TechEd ‘04 ST Constructs: Modularization (1) Variable / Parameter Declaration declaration : • <tt:root name="name"/> • <tt:variable name="name" [val="constant"]/> • <tt:parameter name="name" [val="constant"] [kind="in"|"out"|"in/out"]/> <tt:transform> declaration* <tt:template name="name"> <tt:context> declaration* </tt:context> template content </tt:template> </tt:transform> Context of main template: top-level declarations Default context of sub-template: one unnamed root initial / default value in val parameter direction (kind) independent of transformation direction © SAP AG 2004. SAP TechEd / ABAP 252 / 71 Each template works on a certain “context”. By default. They are either read-only or write-only.. in which it declares its roots. variables can always be read and written. which can’t be done with ref-nodes. transformation parameters can be read during deserialization and written during serialization. The treatment of root nodes (and all ref-nodes) depends on the transformation direction: Serialization reads them. sub-templates have a single unnamed root and no variables / parameters. non-main template) can have its own context declaration. deserialization writes them. A sub-template (i.

SAP TechEd ‘04 ST Constructs: Modularization (2) Apply Template binding : • <tt:with-root name="name" [ref="ref"] /> • <tt:with-parameter name="name" [ ref="ref" | var="name" | val="constant" ] /> <tt:call transformation="name"> binding* </tt:call> <tt:apply name="template-name"> binding* </tt:apply> Call Transformation tt:apply: named template in main or included program tt:call: existing ST program (separate load) © SAP AG 2004. SAP TechEd / ABAP 252 / 72 A sub-template without an explicit root declaration has an implicit unnamed root. This root is bound to the current node at the point of invocation (tt:apply). 72 .

SAP TechEd / ABAP 252 / 73 73 .SAP TechEd ‘04 Exercise Exercise “Customers” example: Full version (Simple Transformation) © SAP AG 2004.

SAP TechEd / ABAP 252 / 74 74 .SAP TechEd ‘04 ST Constructs: Variable [De]Serialization Read Variable S D no effect XML value to variable <tt:read var="name" [type="C|D|F|I|N|P|T|X"] [map="mapping-list"] /> Write Variable S D variable value to XML no effect <tt:write var="name" [map="mapping-list"] /> © SAP AG 2004.

SAP TechEd ‘04 ST Constructs: Assignment Assign to Ref-Node S D no effect assign to ref-node <tt:assign to-ref="ref" ( var="name" | val="constant" )/> <tt:clear ref="ref"/> Assign to Variable S D assign to variable … except if ref (no effect) <tt:assign to-var="name" [ var="name" | ref="ref" | val="constant" ] /> <tt:clear var="name"/> example same effect as <tt:value ref="A"/> <tt:assign to-var="V" ref="A"/> <tt:write var="V"/> <tt:read var="V"/> <tt:assign to-ref="A" var="V"/> S D © SAP AG 2004. SAP TechEd / ABAP 252 / 75 75 .

the tt:cond-var and tt:switch-var constructs are always conditions on the values of variables. (As a matter of principle.) In contrast. Consequently. the condition is on the XML content. the check-clause of tt:cond-var cannot use ref-nodes. SAP TechEd / ABAP 252 / 76 The tt:cond and tt:switch constructs have direction-dependent semantics: During deserialization.SAP TechEd ‘04 ST Constructs: Variable Conditional Basic Variable Condition <tt:cond-var check="check-clause" template content </tt:cond-var> Variable Switch <tt:switch-var> case* </tt:switch-var> check-clause uses variables (not ref-nodes) at most one case in tt:switch-var may have no condition (default) © SAP AG 2004. 76 . it is impossible to let the values of ref-nodes influence the transformation result. not on the values of refnodes. even during deserialization.

SAP TechEd ‘04 ST Constructs: Directional Serialize S D evaluate template content no effect <tt:serialize> template content </tt:serialize> Deserialize S D no effect evaluate template content <tt:deserialize> template content </tt:deserialize> Skip S D no effect match & skip [number of] nodes [named element-name] <tt:skip [name="element-name"] [count="number" | "*"]> template content </tt:skip> © SAP AG 2004. SAP TechEd / ABAP 252 / 77 77 .

SAP TechEd / ABAP 252 / 78 78 .SAP TechEd ‘04 ST Exception Hierarchy CX_TRANSFORMATION_ERROR CX_ST_ERROR CX_ST_REF_ACCESS CX_ST_CONDITION CX_ST_COND_CHECK_FAIL CX_ST_GROUP_MISSING_CASE CX_ST_SWITCH_NO_CASE CX_ST_MATCH CX_ST_MATCH_NAMED CX_ST_MATCH_ATTRIBUTE CX_ST_MATCH_ELEMENT CX_ST_MATCH_TEXT CX_ST_MATCH_TYPE CX_ST_FORMAT_ERROR CX_ST_DESERIALIZATION_ERROR CX_ST_SERIALIZATION_ERROR CX_ST_INVALID_XML CX_ST_CALL_ERROR © SAP AG 2004.

SAP TechEd ‘04 Intro XML in Open Systems XML in ABAP ABAP – XML Mapping: Concepts ABAP – XML Mapping with XSLT Simple Transformations Summary 79 .

…. … . ….. . . . . DB HTML / Text 80 . . …. ….. …. … ….. XS LT Simple Transformations XS Network XSLT XS LT © SAP AG 2004... …..4 XML Doc … . .. ….. … ..SAP TechEd ‘04 Summary: ABAP – XML Mapping LT ABAP Data in ne w 0 6.. …. SAP TechEd / ABAP 252 / 80 LT XS … .

40) SSTDEMO1 : ST (6.SAP TechEd ‘04 Summary: Available Demos Transactions in the Basis delivery (6.40 SP9) SSTDEMO2 : XSLT and ST © SAP AG 2004. SAP TechEd / ABAP 252 / 81 81 .20) SXSLTDEMO1 : XSLT (6.

SAP TechEd / ABAP 252 / 82 82 .0 Simple Transformations (since 6.SAP TechEd ‘04 Summary: Transformation Languages for ABAP XSLT (since 6.40) only for ABAP ↔ XML only linear transformations (no DOM) speedup over XSLT: 10 – 30.10) works on canonical XML representation of ABAP data (asXML) builds DOM for source side arbitrarily complex transformations basis of: XI 2.0 / Web Services Both symmetric: no generation of ABAP code / XML schemas integrated in workbench (maintenance / transport) integrated in ABAP: CALL TRANSFORMATION © SAP AG 2004. “unlimited” size of data reversible (one program for both directions) basis of: XI 3.

limited throughput XSLT © SAP AG 2004. high throughput Simple Transformations Complex mappings. SAP TechEd / ABAP 252 / 83 83 .SAP TechEd ‘04 Summary: When To Use What System Landscape Integration Exchange Infrastructure RPC-Style Web Services ABAP Web Services Direct XML Processing in ABAP REST-Style Web Services (URI in. XML out) Custom XML Persistence XML-Based Repositories … Simple mappings.

SAP TechEd / ABAP 252 / 84 84 .sdn.40” (4h Hands-on) XI 252: “SAP Exchange Infrastructure .com Server ABAP Programming Forums Web Application SAP Professional Journal Jul/Aug 2002: “From XML to ABAP Data Structures and Back: Bridging the Gap with XSLT” Nov/Dec 2002: “Mastering the asXML Format to Leverage ABAP-XML Serialization” Coming up: “Simple Transformations between ABAP and XML” Related Workshops/Lectures at SAP TechEd 2004 ABAP 256: “Utilizing Web Services with ABAP and SAP Web Application Server 6.Integrating Heterogeneous Applications” (4h Hands-on) © SAP AG 2004.SAP TechEd ‘04 Further Information Public Web: SAP Developer Network: www.sap.

http://www.com/ © SAP AG 2004.SAP TechEd ‘04 SAP Developer Network Look for SAP TechEd ’04 presentations and videos on the SAP Developer Network. Coming in November.sap. SAP TechEd / ABAP 252 / 85 85 .sdn.

SAP TechEd / ABAP 252 / 86 86 .SAP TechEd ‘04 Questions? Q&A © SAP AG 2004.

SAP TechEd / ABAP 252 / 87 87 . and do not take the handouts for the following session. Thank You ! © SAP AG 2004.SAP TechEd ‘04 Feedback Please complete your session evaluation. Be courteous — deposit your trash.

and Motif are registered trademarks of the Open Group. OS/400. mySAP. DB2. SAP. used under license for technology invented and implemented by Netscape. National product specifications may vary. XML. xApps. Sweden. VideoFrame. All other product and service names mentioned are the trademarks of their respective companies. so people don‘t accidentally delete it with all the guideline slides 88 . Java is a registered trademark of Sun Microsystems. iSeries. AFP. ICA. xApp. zSeries. All Rights Reserved No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. MaxDB is a trademark of MySQL AB. AIX. IBM. and PowerPoint are registered trademarks of Microsoft Corporation. WebSphere. SAP TechEd / ABAP 252 / 88 I would suggest moving this slide before the guidelines. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only. JavaScript is a registered trademark of Sun Microsystems. X/Open.. Tivoli. if any. MetaFrame. World Wide Web Consortium.com. S/390. R/3. OSF/1. and Informix are trademarks or registered trademarks of IBM Corporation in the United States and/or other countries. without representation or warranty of any kind. Massachusetts Institute of Technology. XHTML and W3C are trademarks or registered trademarks of W3C®. Outlook. Inc. DB2 Universal Database. Parallel Sysplex. OS/390. Inc. SAP NetWeaver and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. AS/400. Program Neighborhood. xSeries. Inc. pSeries. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. MVS/ESA. These materials are subject to change without notice. Citrix. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services. © SAP AG 2004. Windows. Intelligent Miner. UNIX. and SAP Group shall not be liable for errors or omissions with respect to the materials. Oracle is a registered trademark of Oracle Corporation. Data contained in this document serves informational purposes only. and MultiWin are trademarks or registered trademarks of Citrix Systems. HTML. The information contained herein may be changed without prior notice. mySAP. OS/2. Netfinity.SAP TechEd ‘04 Copyright 2004 SAP AG. Microsoft. Nothing herein should be construed as constituting an additional warranty. z/OS. WinFrame.

Sign up to vote on this title
UsefulNot useful