You are on page 1of 17

.......com 1 ........ 9 Calling ABAP from XSLT ................ 5 Encodings .................................... 9 Exception Handling in ABAP Calls 2........... 5 3..........................................................8 Useful Tips ..... 36 Sample Deserialization ..........1 Integrating XSLT into the 2.......................................................4 SAP-Specific Extensions .....................................................................................................5 Validating Against DTDs ... 43 3..XML Data Exchange using ABAP Tobias Trapp Contents 1 Introduction ... 24 2..... 14 String Functions ...................................... 44 Response Scenario for a Commands for Nodesets ....................................... 45 www.......................................................0 ..................... 6 XML Library ................. 43 3........................ 32 External Partners .............................. 45 SAP-Specific Restrictions ........ 45 cXML Interface .................................... 25 XML 1................................. 15 from XPath 2..................................................... 9 ABAP Workbench .............................. 17 XML in Application Integration .3 DOM API ................. 5 3..... 44 Unicode .... 6 Identifying Elements with Namespaces ...... 8 4 XSL Transformations ................. 35 SAP Systems .......... 36 Application Integration ..... 7 Using Rule Sets ..............................sap-press....2 Integrating XSLT in ABAP .0 . 7 SAX Interface .... 14 Numeric Functions ..................... 37 3 XML Library ................................... 10 Serializing ABAP Data .....................................................3 Using XML Technologies in from XSLT .......... 25 XML Family ..................................................2 Data Sources ............................................... 10 4........... 23 Data Exchange ..................... 7 3....................................... 26 XML Transformation Using XSLT .. 44 Encodings ........................... 17 Exchanging Data and Documents ..............................................................................7 Event-Based Parsing .......... 29 XML in Integration Scenarios .... 8 4................. 31 Data Exchange with Calling XSLT from ABAP ............. 7 XML Schema for Data Modeling ........ 21 Acknowledgements ................................................... 15 XPath Operators and Path Expressions 3............................3 Transforming ABAP Data ........................ 13 Realistic Scenarios ................. 5 3................. 6 Namespace Support of the System Requirements ......2 Data Exchange in Business Processes ....................................................4 Rendering XML Documents and XML in E-Business . 16 Other Functions ..............................................1 Important Standards of the Pitfalls ............6 Pitfalls Regarding Namespaces ......................................................... 9 4........... 13 4..................1 Important Interfaces . 32 Conclusion .............. 23 2 XML Technologies and 3..................... 20 Structure of this Book ............................... 29 XML Framework in E-Business ............................

....... 65 Data Exchange in the Conflicting Areas Case Distinction ....7 Miscellaneous ................... 84 Expressions ...............................2 Accessing Data Objects .................... 102 Subtemplates ........ .............8 Useful Tips .................. 61 Generating a Proxy Object ........ 46 5.............. 58 Registering the Web Service ..................... 56 Using JAXP 1................................................................................... 77 Definitions of XPath Functions and Namespaces .... 76 Risk Management ............................ 62 Web Service ............. 95 5...................................................................... 84 Text Templates .........5 Mappings .............. 74 of Interfaces ............................ 86 Accessing Elementary Data Objects ........... 84 6.... 89 Data Roots and Data Nodes ........................... 77 Using the Strengths and Weaknesses Calling External ST Programs ...........1 Designing Technical Processes .............................. 50 6.............. All rights reserved............. 102 2 © Galileo Press 2006..... 81 4.. 46 Literal Contents ..................... 51 ABAP-Java Integration .............................................. 56 Handling System Errors ............ 99 Assertions ..... 52 Web Services ................................................................................... 72 Proprietary Interface Formats ...................... 62 6.................................................. 99 Grouping ................................... 101 5.......6 Generating Code ......2 ............ 72 Standards ........................4 Using Web Services through ABAP .. 102 Including Transformations .. 76 7.............................................7 Useful Tips ...................................................................... 99 tt:cond in Detail . 55 Validating XML Documents ...... 81 Output Formatting ...............2 J2EE Infrastructure ........................................ 48 6 Java Integration ........................ 84 Abstract Syntax Trees of XPath Restrictions to the Use of Beans . 93 XML Representation of ABAP Data ........ 85 5.............................. 69 Message Services . and 7 Real-Life Scenarios .....................6 Modular Transformation Programs ................3 Creating a Web Service for 5 Simple Transformations ....................................... 94 5... 73 Further Development and Versioning Structural Mappings .................. 79 Several Input and Output Documents .2 DP Concept of the Process ............................ 55 Creating a Session Bean for the Subroutines and Parameters ............................................... 85 5.................. 50 Session Beans ........Contents 4..................................... 93 Internal Tables ...... 57 Deploying and Testing the Attributes ........................................................ 62 Preconditions............. 100 Mapping with Case Distinctions ................ 48 6........ 46 5............................ 95 Assigning Variables and Parameters ..............................................5 Discussing the Solution ..................................... 99 5................. 66 of B2B and EAI . 77 Grouping XML Elements ................................ 77 Conditional XPath Expressions ..................................... 96 Optional Elements and Attributes ................ 63 7..................................................... 61 Creating a Logical Port ............0 Support ... 58 Web Service .......................................1 Validation Using JAXP ........................ 102 Choosing the Right Technology .................3 Variables and Parameters ..... Conditions....... 72 Using Established E-Business Mapping Attribute ................................ 90 Structures .......................................... 101 Conditional Transformations with Quality of the User Data ............................1 Basic Structure ...............5 XSLT 2............................ 56 Validation . 77 of XML Processes ..................... 84 4.............................................. 101 Variables ......... 59 6.............................. 62 ABAP Program for Calling the Case Distinctions Using Variables ...4 Conditional Transformations .......................

................................ 107 A.................com 3 .................................................................1 Sample Master Data Exchange B Bibliography ....... 108 www........................ 119 Sample BMEcat Catalog ...............3 Regression Tests .........sap-press................................ 107 Catalog of Offerings for Flight Meals ..................................... 112 Documents ..... 113 On the Probability of our Example ... 117 Process ................................................................ 108 Storing and Displaying XML Part of the SPFLI Flight Data Model ... 103 the Sample File ........ 107 Index ................................................................. 104 A............................ 105 cXML-Based Sample Invoice ........................ 103 Note on the Design of Communication Protocols .............................. 113 Structure of the Data Transfer Acknowledgement of an Interface ........................... 104 Invoice Receipt .................2 Invoicing via cXML .............. 113 7.. 113 A Sample Scenarios . Contents Files as Data Sources ........

This ele- XSLT is widely used and well documented by a vast ment has the same functionality as the xsl:stylesheet number of resources. To do mendation” of November 3. This exam- ments or plain text files that are made available as load. transformation is the xsl:transform element.10 of the SAP Web Application Server ( http://www. In the following sections. · Transformation. readable way as stylesheets. document are addressed in a specific language: XPath Figure 4. however. ple already shows some facts: The root element of the able assets to other applications. 2002 ( http:// www.. You can create XSLT programs via Transaction SE80.4 XSL Transformations Since Release 6. XSL Transformations ( XSLT ) have been we’ll assume that you’re familiar with XPath 1. the fact that it is the most powerful and advanced tech.w3. Some of those extensions are only current XSLT 2. and outputs a message for each A element.org/TR/2002/WD-xslt20-20020430 ).org/TR/xpath ). ( SAP Web AS ). a version was implemented that is based on the “W3C Working Draft. as shown in Figure 4. Then you can edit the program in nology available for the transformation of XML docu. Which command you want to use is purely existing XML transformations in ABAP.0 and we’ll integrated in ABAP via the CALL TRANSFORMATION com. you must go to the package view.org/ that. on a package to open its context menu and select Cre- The importance of XSLT for data exchange stems from ate · More. You can also generate HTML docu. An input dialog displays.1 Integrating XSLT into the ABAP Work- we cannot assume that this working draft is generally well bench known. XSLT is not limited to searches all elements of an XML document recursively those types of output.sap-press. it has become common practice to existing XSLT-based data exchange solutions in an SAP refer to transformations that format XML documents in a system.20. discuss only those extensions that SAP has implemented mand. When the XSLT processor was implemented.. XML data can be transformed into ABAP data Figure 4. the in the XSLT processor. we’ll compare it with the current version during the course of this chapter: the “W3C Candidate Recom. available as of SAP Kernel Release 6. Because 4. you can also reuse subjective. an editor.2 shows a sample transformation that structures and vice versa.com 29 . ments.1 Creating XSLT Programs www.w3. then right-click TR/2005/CR-xslt20-20051103 ).0 specification was still under discussion.” on April 30.1. however. For this reason.w3. whereas in the data exchange Elements and attributes in the tree structure of an XML context they are called transformations. Because you can easily integrate statement. 2005 ( http://www.

3 ). you must create a file with the following contents: <?xml version="1. We’ll use the sap:line() and sap:column() commands in the sample transformation ( see Figure 4.com/sapxsl namespace.4 XSL Transformations Figure 4.2 Sample Transformation The sap:line() and sap:column() commands deter. The message specifies the position of the element in the input document. This trans- formation reads all elements of an XML document and outputs a message via the xsl:message command when- ever an A element was found. You can test the transformation in the same way as you would an ABAP program. .4 discusses exten- sions in further detail. Section 4. <A/> mine the line and column of the current context node in </Level1> the original document.0" encoding="iso-8859-1"?> <Root> <Level1> Figure 4. which defines </Root> SAP-specific XSLT extensions. These commands are part of the <A/> http://www. All rights reserved.3 Output of the Sample Program 30 © Galileo Press 2006.sap. To do that.

shows how you can do this via ABAP calls from XSLT. We’ll use ABAP syntax as of Release 6.com 31 .4 shows an output of the debugger for the sam- above input.2 Integrating XSLT in ABAP Figure 4. it returns the output shown in Figure 4. each XSLT processor has its own output 2 The xsl:message command is not very useful here. 4.sap-press.2 Unfortunately. Moreover. Strictly speaking. Section 4. ple transformation. values of variables. You can find more useful infor- that have been output. You can call the XSLT Tester from Transaction SE80 by The output of messages is necessary for testing the highlighting a transaction and clicking on the Test XSLT process and error behavior of a transformation. you can only view the messages output via the xsl:message command when you use the XSLT 4.4 XSLT Debugger When the XSLT Tester runs the transformation with the Figure 4. we don’t recommend that mation on test outputs and on debugging XSLT programs in you use those classes.3. Consequently. how to call ABAP from XSLT. It often method. Lan- guage constructions that are considered “obsolete” are 1 It is a general drawback of the XSLT specification that it doesn’t describe where exactly the messages must be out- put. and the ABAP and alternatively.2 You can also execute XSLT programs step by step. www. the XSLT Cookbook ( Sal Margano: O’Reilly 2005 ). Because Program button.2 Integrating XSLT in ABAP Tester or the XSLT Debugger. however. you can set breakpoints.20 here. the SAP implementation also con. makes more sense to store logging information in separate tains ABAP classes that can be used to evaluate the messages elements in the XML output. you can use messages for manual testing. the document position.1 The debugger can also display the command line that This section describes how to call XSLT programs from is currently executed.

40. ceptions Since Release 6. The CALL TRANSFORMATION command can trigger ex- cepts. Don’t forget exception handling! but it also required the standardization of existing con.4 XSL Transformations still supported for reasons of downward compatibility. data type. or nodeset. we can call 32 © Galileo Press 2006. which is available in the asXML IMPORTING view in the transformation. get ( RESULT parameter ). they should no longer be used because there of XML documents.40 the OPTIONS parameter is available To a certain extent. . object. is available for XSLT set of commands. For example. In the data source ( SOURCE parameter ) and tar. l_var_source_line TYPE i. ods. l_var_include_name TYPE syrepid. you must use an object of the l_var_text = l_rif_ex->get_text( ). You can transfer ABAP data objects l_var_text TYPE string. Among other sion mechanisms. xstring. we only want to briefly describe sive kind of programming. this You can call an XSLT program via the CALL TRANSFORMATION is an indispensable component of a robust and defen- command. To transfer nodesets. one of the following type specifications can l_var_program_name TYPE syrepid. fer ABAP data dynamically by using a variable of the type ABAP_TRANS_RESBIND_TAB. formation. if_ixml_node or if_ixml_collection type. cally and dynamically. or XML documents. The following section pro- vides examples of how to transfer objects and use meth. xstrings. the common basic class ments so they can reduce the degree of complexity in the CX_TRANSFORMATION_ERROR. if_ixml_ostream. XML documents include_name = l_var_include_name. ENDIF. Within the trans. CATCH cx_xslt_runtime_error INTO l_rif_ex. programs and simple transformations ( see Chapter 5 ). are better options available. number. string. for instance. the as- exception handling. l_var_source_line. this parameter can be used for output formatting however. every XSLT processor supports exten- for the CALL TRANSFORMATION command.10 to 6. XML documents are available as WRITE: / l_var_text. boolean. into XML documents. Developers should study these advanced develop. IF l_var_text IS NOT INITIAL. triggers an exception that must CALL TRANSFORMATION transformation be handled. Calling ABAP from XSLT Since Release 6. CALL METHOD Both the source and the result of a transformation con. You will note that especially the general syntax of the call. or as reference variables of one of the WRITE: / 'The error exists in line:'. You can also trans. that contains a transformation error: DATA: l_rif_ex TYPE REF TO The transformation source can be specified both stati. and ABAP data to XML and vice * Log error versa. in our case. Even though the listings shown here don’t contain the Calling XSLT from ABAP handling of system errors due to space limitations. following types: if_ixml_istream. All rights reserved. you should refer to The Official ABAP signment of an alphanumeric value to a numeric ABAP Reference ( Horst Keller: SAP PRESS 2004 ). source_line = l_var_source_line The CALL TRANSFORMATION command enables you to program_name = l_var_program_name transform ABAP data into ABAP data. be used for the parameter: string. Not only did the upgrade from Release 6. This XML * Determine error position library interface was described in detail in Chapter 3. For further details such as when transforming XML data into ABAP data. [PARAMETERS parameters] SOURCE source The following lines show the structure of the CATCH block RESULT result. if_ixml_node. if_ixml_document.20 involve adding new concepts. things. At this point. to the transformation via PARAMETERS. cx_xslt_runtime_error. l_rif_ex->get_source_position sist of either ABAP data.

in the source text. At this point. the logged error rule to the above template. in plate is then evaluated.1 processes an XML docu- ging object. This context contains only the document root. 4. The trans- demonstrate how you can store error messages in a log. formation shown in Listing 4. sap:external-function process is newly set with regard to the element found. the process terminates. use the xsl:apply-templates command. we will the creation of error lists and process tracing. Other areas of application include the For the integration in ABAP log messages. you must understand that a com. The instance is trans- range objects. but not very that can hardly be maintained. I_LINE.w3.1 clearly illustrates the func- error has occurred. the XSLT processor processes LOGGER that contains a save method including the nodes of a context. www.0"> <xsl:param name="OBJECT" /> <xsl:template match="A"> <sap:call-external name="OBJECT" method="save"> <sap:callvalue param="I_STRING" select="'A found'" /> <sap:callvalue param="I_LINE" select="sap:line()" /> <sap:callvalue param="I_COLUMN" select="sap:column()" /> </sap:call-external> <xsl:apply-templates select="*"/> </xsl:template> </xsl:transform> Listing 4. For each node.com 33 . command. Another typical application is the transforma.sap-press. the transformation of an XML document—that a system The example in Listing 4.sap. particularly with regard to ing. In our case. the template that meets the the PARAMETERS3 parameter of the CALL TRANSFORMATION requirements most precisely is used. for example. database access. Once the trans. An XSLT program consists of data quality requirements agreed upon. At the beginning of the process. and I_COLUMN. ment recursively and logs the occurrence of A elements. that the first A element is found.org/1999/XSL/Transform" xmlns:sap="http://www. as well as template is appropriate for the node. The <xsl:param name="OBJECT" /> statement <xsl:transform xmlns:xsl="http://www. If there is more than one template the business application log. And yet the ABAP integra. Section 4. a set of templates that are defined via the xsl:template formation has been analyzed and additional error-han. it means statement. and the context of the The SAP-specific extensions. a function-based style in XSLT often results in programs This type of processing is rather general. For this purpose we’ll define an object called Z_CL_ At each point in time. object must possess another attribute that collects the the template rules are analyzed in order to find out which data in an internal table in the main memory.1 Transformation z_messages_log 3 The OBJECTS that were originally provided for this purpose have become obsolete since Release 6. plate can be used for processing the A elements. efficient.2 Integrating XSLT in ABAP ABAP methods and function modules from a transfor.20.7 deals with this aspect of process- tion is generally unavoidable. we in XSLT. This object is transferred to that meets the requirements. we define implementation of counters and the access to number an object using a save method. This rule states that the tem- messages are collected in a main memory component. Another useful way of applying the ABAP integration is mation. In one application of ABAP integration. or that the data does not meet the tionality of an XSLT program. The identified tem- another method for saving the messages. enable you to integrate ABAP continue the required recursive search for A elements. the three parameters. I_STRING. If no other ele- bination of a procedural programming style in ABAP and ment is found.com/sapxsl" version="1. To and sap:call-external. tion in the data exchange process that discovers—during including their position. The match="A" attribute assigns a template dling mechanisms have been initiated. ferred to the transformation via PARAMETERS object = l_rcl_log.

we can use the type attribute to specify a conversion that’s 4 The contents of the method attribute are an attribute value described in the SAP Library. We’ll extend the Z_CL_LOGGER class bind those parameters to a variable by using the sap: by a static method. a class method respectively ( see Section 3. as shown transformation are translated into the corresponding in the XSLT program in Listing 4. The XSLT processor can use the AVT at run- time to determine a value that is contained in curly brackets to bind the return value to an XSLT variable. that returns an instance of callvariable command: The <sap:callvariable name= Z_CL_LOGGER. This convention is nodeset may be transferred. This method is called within a transfor- "variable" param="E_STRING"/> command transfers the mation. Similarly. CREATE OBJECT l_rcl_log.4 This procedure is very gen- DATA l_var_input TYPE string. eral. Here. The value of the variable variable into the exporting param. Other EXPORTING parameters are ignored. the sap:external-function com- `<R><Level1><A>a</A></Level1> mand has some advantages. define the call of this method as a top-level element by ment. and xsl:stylesheet. too. which generally causes a commonly used in Java. E_STRING . When transferring attributes using the sap:callvalue The call of the external function prv:prot corresponds statement. an exception— At this point. formation instead of being determined at runtime by an ABAP object. ABAP values. the consequence PARAMETERS object = l_rcl_log of that is that a function value must be returned either SOURCE XML l_var_input as a RETURNING parameter or as an individual EXPORTING RESULT XML l_var_output. or a method of the object ( instance ).1 ). In addition. Please refer ( {} ). of the transformation. 34 © Galileo Press 2006. used in XPath expressions. you DATA l_rcl_log can call methods dynamically via the method attribute: TYPE REF TO z_cl_logger. Compared to the sap:call-external command l_var_input = described earlier. This command can also be <A>a</A></R>`. . If this is not the outcome that we want. create(). type error. but not robust if the index is encoded in the trans- DATA l_var_output TYPE string. the value is stored in the to the SAP Library for further details such as handling $index variable. Its syntax is more compact because it corresponds to a function definition at the top CALL TRANSFORMATION z_messages_log level5 of the XSLT program. and the created object is stored in a variable. If a conversion is impossible.3 eter. is carried out. All rights reserved. method that returns a BOOLEAN function value.4 XSL Transformations ensures that the parameter is published within the trans. logging method is then called via this variable. a name of the externally called object. otherwise. a nodeset is automatically When the call is carried out via the sap:external- transformed into an object that is implemented by the function. parameter. The values that are transferred along with the using the sap:external-function command. an implicit conversion process describes this process. However. This conversion enables you template ( AVT ). the syntax required for calling class methods formation: is also described in the SAP Library. When you extend the Z_CL_LOGGER class by a prot() A common source of error is that the value of the trans. We should therefore use the fac- If the method contains return parameters. you can ferred object is not capitalized in the xsl:param state. method="METHOD_{$index}". ( class ). 5 Top-level elements are the child elements of xsl:transform CHANGING parameters. the attribute determines whether the method if_ixml_node or if_ixml_node_collection interface call is a constructor ( constructor ). The same TRANSFORMATION call as well as in the xsl:param element holds true when an object call generates an exception. With the method attribute. you can tory pattern now. you should determine whether you have to to the convention that the first function argument is the convert the attributes into a string first. you could find it disturbing that the log- CX_XSLT_ABAP_CALL_ERROR—is triggered that must be ging object is still contained in the interface of the CALL absorbed by the surrounding ABAP program. Listing 4.2. In this context.

0"> <sap:external-function name="prv:create" class="Z_CL_LOGGER" method="create" kind="class" > <sap:result param="e_object" type="external" /> </sap:external-function> <sap:external-function name="prv:prot" method="prot" kind="instance" > <sap:argument param="i_string"/> <sap:argument param="i_line"/> <sap:argument param="i_column" /> <sap:result param="e_return" type="boolean" /> </sap:external-function> <xsl:variable name="instance" select="prv:create()"/> <xsl:template match="A"> <xsl:value-of select="prv:prot($instance.sap. typically. If an error occurs in a the objects outside of the transformation. There are ABAP programmers who complain that it is we would have to forward the return codes and error impossible to call function modules directly from XSLT. Consequently.3 Instantiating an Object from XSLT www. This restriction. The concept of class-based <xsl:transform xmlns:xsl="http://www.org/1999/XSL/Transform" xmlns:sap="http://www.com/sapxsl" xmlns:prv="urn:mine" version="1. regarded as a weakness as it exemplifies the efficiency of to store references to those objects. If. 'A found'. to access class-based exceptions in ABAP.3. you must pro. the solution may not appear Instead. an ABAP call from XSLT. sap:line(). however. in turn. which. deep software layer.com 35 . tion is canceled. an error occurs in port optional parameters.w3.org/1999/XSL/Transform" xmlns:sap="http://www. because a data record is locked in gram different sap:external-function commands for the database or doesn’t exist. sap:column())"/> <xsl:apply-templates select="A"/> </xsl:template> </xsl:transform> Listing 4. for instance.0"> <xsl:param name="OBJECT" /> <sap:external-function name="prv:prot" method="prot" kind="instance" > <sap:argument param="i_string"/> <sap:argument param="i_line"/> <sap:argument param="i_column" /> <sap:result param="e_return" type="boolean" /> </sap:external-function> <xsl:template match="A"> <xsl:value-of select="prv:prot($OBJECT. they can only call objects that encapsulate those to be adequate. ized in the calling layer.sap. often times the transforma- different calls. logs in an additional interface.sap-press.w3.2 Calling a Method from XSLT In the example in Listing 4. sap:line(). sap:column())"/> <xsl:apply-templates select="A"/> </xsl:template> </xsl:transform> Listing 4. Exception Handling in ABAP Calls from XSLT If there were only function modules available for that. 4.2 Integrating XSLT in ABAP <xsl:transform xmlns:xsl="http://www.com/sapxsl" xmlns:prv="urn:mine" version="1. 'A found'. it can be considered calls. however. it must be logged and then neutral- The sap:external-function command does not sup. causes the calling ABAP program to react. and lastly. should not necessarily be good programming to create objects via factory methods.

To do that. cels and we’ll catch an exception of the type CX_XSLT_ float TYPE f. SAP created a serialization format called l_str_test-string = ` ABC `. transforming an XML document into ABAP data struc. <CHARS>ABC</CHARS> <STRING> ABC </STRING> This identical transformation is integrated in the SAP ker. we recommend encoding="iso-8859-1"?> that you fill the ABAP target structure with values and <asx:abap then transfer it with the identical transformation to XML.45. To do that. <FLOAT>1.45</PACKED> that’s contained in the SXSLT package.com/abapxml" The following call enables you to do just that: version="1. l_str_test-xstring = 'ABCDEFG'.3 Transforming ABAP Data l_var_output TYPE string. </asx:values> chars TYPE c LENGTH 10. <ROOT> RESULT XML l_var_xml_string. and therefore as character strings. To provide access to ABAP data transformations as sources l_str_test-chars = ' ABC '... xmlns:asx="http://www. CALL TRANSFORMATION id SOURCE root = l_str_test Serializing ABAP Data RESULT XML l_var_output. When l_str_test-float = 123. ing this kind of problem. which enables you to program the attributes of l_str_test-numc = '01234'. </asx:abap> 36 © Galileo Press 2006.0" generate it and analyze it. The transformation can. DATA: l_str_test TYPE l_test_typ. The ABAP data struc. If you want to perform a transformation from an XML document into an ABAP data structure. you must know The result of this transformation is the following XML the target data structure in the asXML representation. ABAP_CALL_ERROR in the CATCH block that follows CALL date TYPE d. END OF l_typ_test.. exception in which you can recognize the original excep. and then apply the transformation id to them: </ROOT> TYPES: BEGIN OF l_typ_test. string TYPE string. <TIME>12:01:00</TIME> ture that contains the most common basic ABAP data <XSTRING>q83v</XSTRING> types.sap. If document: you don’t know that representation. tion object by the previous attribute. xstring TYPE xstring.4 XSL Transformations exceptions. in XML format. This exception is actually a chained time TYPE t. however. asXML. you should simply <?xml version="1.0"> CALL TRANSFORMATION id <asx:values> SOURCE p_1 = . represents an elegant way of solv. generates an asXML representation.2345E2</FLOAT> Now we’ll analyze how we can convert basic ABAP <DATE>2006-06-14</DATE> data types to asXML. we can report an exception by using packed TYPE p LENGTH 4 the RAISE EXCEPTION command. 4. TRANSFORMATION. tures..45. all basic and composite ABAP data types and even classes l_str_test-packed = 123. and targets. l_str_test-date = '20060614'. you must implement an XSLT transformation that l_str_test-time = '1201'. DECIMALS 2. an ABAP function. you must define a struc. <NUMC>01234</NUMC> nel and should not be mistaken for the transformation ID <PACKED>123. When a serious error occurs in numc TYPE n LENGTH 5. . All rights reserved. p_2 = . tures are then filled in an implicit conversion step.

w3. Our goal is to assign each ARTICLE element an entry The components correspond to the basic data types of from the SMEAL table. www. whose compo.5 shows a graphical display of the master parameter in the above CALL TRANSFORMATION call. with the objective to create a uniform standard for catalog 6 Except that the year must range between 0 and 9999 in ABAP data in electronic procurement processes. 4. Aus- tria.ietf. the University of Essen. over 150 different standards available for those processes. Currently. The long and short texts from the the l_typ_test structure. In our As an example. and the University of Linz. associated ARTICLE_DETAILS element are transferred into The basic data types are presented in compliance with this table and the associated SMEALT table.sap-press. then it refers to types complies with ISO 8601.com 37 .org/ TR /xmlschema-2/# built-in-datatypes ).txt ).1. there are and the date of 00000000 is permitted. the assignment to one of the three product groups via the Figure 4. integrated data types of the W3C XML Schema ( http:// The CATALOG_STRUCTURE element provides the struc- www. This data. For each item. whereas “DT1020” refers to starters and encoded according to Base64 ( http://www. vice for flight meals as a BMEcat catalog. Germany.5 Display of a BMEcat XML Document 7 BMEcat was developed by the Fraunhofer Institute IAO. Sample Deserialization the values for ABAP data types are asx:values. ture of the contents of the GROUP_ID element. we now want to describe a conversion of example.org/rfc/ “DT1030” to desserts. This is a catalog of meals provided by a catering ser- parameter is assigned a structure. root. which contains the values of the SOURCE A. the only child element of asx:values is the the fictitious master data scenario contained in Section ROOT element.3 Transforming ABAP Data The root element of an asXML document is asx:abap. Figure 4. If the You can see that the implementation of date and time ID begins with the string “DT1010”.7 nents are the child elements of the XML element ROOT. you can determine rfc2045. 6 whereas xstrings are main courses.

All rights reserved. we define a local namespace using the prefix BME because SMACOURSE..Create meal --> <SMEAL> <xsl:call-template name="CreateMeal"> <xsl:with-param name="mealnumber" select="$mealnumber"/> <xsl:with-param name="article" select="$article"/> </xsl:call-template> </SMEAL> <!-. Those items are programmed using the BME:ARTICLE or a dessert. . meals must be saved in different SAP tables ( SSTARTER. For each catalog item.Create long text for meal --> <SMEALT> <xsl:call-template name="CreateMealText"> <xsl:with-param name="mealnumber" select="$mealnumber"/> <xsl:with-param name="article" select="$article"/> </xsl:call-template> </SMEALT> <!-. In our example. for which we have defined a org/XMLSchema/1.sap.2/bmecat_new_catalog" exclude-result-prefixes="BME" version="1. a main course.4.) 38 © Galileo Press 2006. and a dessert.4 performs exactly this SMEALT. or SDESSERT ). recursively.bmecat.org/1999/XSL/Transform" xmlns:sap="http://www.2/bmecat_new_catalog.w3.bmecat. SMEAL and The XSLT program in Listing 4.Determine catalog grouping --> <xsl:variable name="CatalogID" select="string(key('key_article'. we analyze all catalog items ( arti- ment in order to find out if it is a starter.$mealnumber))"/> <!-. In the transformation.4 Z_BME Transformation (cont./BME:SUPPLIER_AID)"/> <!-.Analyze meal type --> <xsl:choose> <xsl:when test="starts-with($CatalogID. we use the item name to determine ment for the BME root element and. cles ). 'DT1010')"> <SMACOURSE> Listing 4. To do that.0"> <xsl:param name="CARRID"/> <xsl:strip-space elements="*"/> <!-. a main course.com/sapxsl" xmlns:asx="http://www. This system is used to create an entry for the elements.Create key for fast access --> <xsl:key match="BME:CATALOG_GROUP_ID" name="key_article" use="string(. a catalog item can be a starter. CATALOGGROUP_MAP element. <xsl:transform xmlns:xsl="http://www.org/XMLSchema/1. Because each of those At the beginning of the XSLT program in Listing 4. we call the CreateMeal corresponding transparent table.com/abapxml" xmlns:BME="http://www. key_article index to increase the system’s performance. we must first define the a local namespace was defined in the original XML docu. types.4 XSL Transformations child elements of the ARTICLE_TO_CATALOGGROUP_MAP ele. for its the associated ID catalog group via the ARTICLE_TO_ children using the following URI: http://www. transformation.Determine item number --> <xsl:variable name="mealnumber" select="string(./BME:ART_ID)"/> <xsl:template match="/"> <asx:abap> <asx:values> <xsl:for-each select="/BME:BMECAT/BME:T_NEW_CATALOG/BME:ARTICLE"> <xsl:variable name="article" select=".sap. template to create an entry for the SAP tables."/> <!-.

99 if_ixml_stream_factory 14 Chained exceptions 36 Enterprise Application Project 90 if_serializable_object 10 Character sets 14.3 97 Data quality 101 JCo 84 Datastore component 26 Default error handler 81 www. 107. 34 eCl@ss 108 businessService 85 if_ixml_node_collection 34 EDIFACT 7. 32 ebXML 5. 61. 93 if_ixml_node 13. 113 group-adjacent() 46 J2EE 11. 59. 32 BMEcat 5. 105 Home interface 84 Displaying XML documents 104 asXML representation 36 HTTP requests 104 Diversifying development and testing Attribute value template 34 105 Document type definitions 8 I B DOM 15 ICF 104 DTD 17 Base64 37 if_ixml 14 bindingTemplate 85 if_ixml_attribute 13 BizTalk messages 5 E if_ixml_document 13. 81 group-starting-with() 46 JAXP 81 Data integration 9 gXML 5 JAXP 1. 50 F 11 ISO-8859-1 14 Complex transformations 104 Factory pattern 34 ISO 4217 52 Content models function-available() 45 iXML library 13 Non-deterministic 61 current-group() 46 G current-grouping-key() 46 Generic object services 104 J cXML 5.com 119 . 32. 99 businessEntity 85. 108 if_ixml_event 14. 84 group-by() 46 J2EE connector architecture 84 D group-ending-with() 46 Java 54. 32 EJB specification C restrictions 84 if_ixml_parser 14. 19 if_ixml_renderer 17 CALL TRANSFORMATION 32.sap-press. 16.Index A Default namespace 46 H Deployment descriptors 84 A2A integration 10 Head-body pattern 27 Deserialization 57 Abstract syntax trees 51 HL7 messages 5 Design pattern 26 asXML 36. 15. 24. 37. 68. 52 Exceptions Interface formats CIF 5 Chained 36 Proprietary 101 CL_GUI_HTML_VIEWER 104 Internet Communication Framework (ICF) CL_IXML 14 Code generation 11. 25 E-business standards 100 BMEcat catalog 37 if_ixml_istream 14. 69. 27. 56 Encodings 14 if_ixml_stream 14 CDATA sections 25 Enterprise Application Integration 9. 8 if_ixml_node_filter 27 EJB 84 if_ixml_ostream 14.

99 SAX 23 tt:d-cond 63. 102 tt:context 61. 104 Outside-in approach 94 sap:log() 44 Standard deserialization 72 sap:log10() 44 Standard serialization 67 P sap:lower-case() 44 STX (Streaming Transformations for XML) sap:max() 45 103 PARAMETERS 33 sap:min() 45 Symmetrical case distinctions 68 Pattern 65. 55. 34 Case distinctions using variables 62 Middleware 102 sap:callvalue 34 Condition 63 Mime64 9 sap:callvariable 34 Conditional transformation 65 Modular schemas 96 sap:column 30 Conditional transformations with sap:concat 50 variables 73 N sap:cos() 44 Data nodes 57 sap:ends-with() 44 Data roots 57 Namespace 20. 89 tt:copy 61 Request-response processes 8. 66 Generic 104 sap:intersection 45 Symmetry 57. 23. 74 Resolving release dependencies 102 SAXParserFactory 81 tt:deserialize 73. 21. 79 120 © Galileo Press 2006. 67. . 65. 77 Session beans 84. 74. 77 sap:timestamp() 45. 64. 77 Proprietary interface formats 101 sap:string-pad() 44 tt:assign 62. 66 Message implementation guidelines 8 sap:call-external 33. 45. All rights reserved. 99. 81. 75 Proxy class 95 sap:tan() 44 tt:attribute 58 Proxy object 94 sap:target 48 tt:call 56. 85 Logical port 95 Simple Transformations LSMW 50 S Sample applications 55 Safety facades 86 Simple transformations 103 M sap:abs() 44 ABAP structures 58 sap:acos() 44 Assertion 64 Markup 7 sap:asin() 44 Attributes 58 Mass data 14. 101 sap:atan() 44 Case distinctions 62. 35 Internal tables 59 Null namespace 46 sap:find-first() 44 Literal contents 77 sap:find-first-of() 44 Mappings 72 O sap:find-last() 44 Modularization 76 sap:find-last-not-of() 44 Namespace declarations 77 Object identifiers 52 sap:find-last-of() 44 Parameters 62 Object services sap:if() 48 Precondition 64. 52 tt:clear 62 R sap:upper-case() 44 tt:cond 63. 76 Remote interface 84 SAP XML Toolkit for Java 23.Index L Result fragment tree 45 Schemas Risk management 102 modular 96 Literal result elements 46 RosettaNet 5 Serialization 57 Literal text 62. 72 sap:node-set() 45 Payload 8 sap:otr-string() 45 Port sap:parse-xpath() 51 T logical 95 sap:resolve-uri() 44 Tail recursion 52 Ports 11 sap:sin() 44 tModel 85. 27. 96 sap:escape-uri() 44 Expressiveness 74 Namespace axis 45 sap:exp() 44 Grouping 69 Non-deterministic content models 61 sap:external-function 33. 93 Process integration 9 sap:sqrt() 44 tt:apply 56. 16. 74. 66. 74 RELAX NG 81 10. 67 Regression tests 104 SAP NetWeaver Exchange Infrastructure tt:cond-var 62. 79 Online text repository 45 sap:let() 45 Variables 61 Optional elements 62 sap:line 30 SOAP 11. 34.

74 WSDL 11.0 43 User defined XPath functions 48 XSLT 2.com 121 . 48. 74.sap-press. 76 ABAP extensions 33 tt:transform 55. 67. 15 user defined 48 www. 100 xsl:import 52. 73 Wellformedness 7. 44 Unicode 14. 25. 46. 102 xsl:transform 29 tt:switch-var 73. Index tt:group 69. 48.0 46. 94 XSLT 29. 93 xsl:output 48 tt:serialize 79 Calling from ABAP 95 xsl:result 48 tt:skip 63. 103. 61 Calling from ABAP 32 tt:value 56 X Exception handling 35 tt:variable 56. 15 XSLT Debugger 31 XPath functions UTF-8 14. 53 Versioning interfaces 101 tt:loop 59. 73 Java extensions 54 xCBL 5 tt:with-parameter 76 Limits of the SAP processor 45 XML 5 tt:with-root 76 Modularization 52 XML 1.1 97 tt:write 62 Output formatting 48. 53 XPath 2. 72 V xs:include 96 tt:include 56. 105 tt:template 56. 77 Webservices Navigator 94 xsl:stylesheet 29 tt:switch 66.0 compliance 46. 84. 75 xsl:apply-templates 33 tt:namespace 79 xsl:for-each-group 42. 92. 18 tt:lax 65 xsl:apply-imports 52. 57 Web service interface 90 xsl:message 30 tt:s-cond 63. 53 XPath 29. 52 XSLT 2. 61. 53 tt:root 56. 53 tt:parameter 56 W xsl:function 48 tt:read 62 W3C XML Schema 8. 50 XML declaration 50 Platform-independent transformations XML Encryption 81 53 XML library 102 U XML signature 81 SAP-specific extensions 43 UDDI tool 93 XSLT 2. 77 XSF data streams 10 Validation 8. 53 tt:ref 57 Expressiveness 8 xsl:include 52.0 conformity 43 UTF-16 14.0 conformity 29 XPath 2. 66 Web services 11.