Creating SAP NetWeaver PI Mapping Programs Using XQuery

  • by James Wood, Founder and Principal Consultant, Bowdark Consulting
  • November 6, 2013
Learn how to use the World Wide Web Consortium (W3C) standard XQuery language to create message mapping programs in SAP NetWeaver Process Integration (PI.) Identify scenarios in which XQuery can simplify complex mapping requirements.
Learning Objectives

By reading this article, you will be able to:

  •  Use XQuery as a part of your XML developer’s toolkit
  •  Understand basic and complex coding for XQuery queries
  •  Integrate XQuery into a Process Integration (PI) Platform
Key Concept

Within the W3C, XQuery is positioned as an XML query language. This is to say that XQuery allows XML developers to query the contents of related XML documents in much the same way that SQL allows for querying data from relational databases. This analogy has become so pervasive that in some circles XQuery is known as the SQL for XML.

One of the great things about the SAP NetWeaver Process Integration (PI) platform is that it provides developers with a number of options for implementing XML transformation programs. For example, with Java-based mappings, the PI mapping engine places few restrictions on conforming mapping programs, allowing developers to implement the XML transformation logic however they like. The PI mapping engine doesn’t care how you generate the resultant XML so long as the XML is well-formed, and you don’t consume too many resources along the way.

Traditionally, Java-based mapping programs have been implemented using various application performance interfaces (APIs) provided with the Java API for XML Processing (JAXP). Indeed, if you look at the pre-delivered enterprise services repository (ESR) content provided by SAP, you’ll find that much of it is implemented using the standard document object model (DOM) API included with JAXP. This approach is straightforward enough, though it can be a bit tedious. This is particularly the case with complex source documents where the data has been flattened out in such a way that data is not organized in a hierarchical fashion. For these kinds of tasks, developers are often forced to unmarshal the data into intermediate data structures that lend themselves toward simplified querying, cross-referencing, and indexing.

In this article, I show you a much more elegant alternative for implementing complex transformation scenarios, like the one outlined above, by looking at how to integrate queries based on the W3C’s standard XQuery language into PI mapping programs. Though XQuery is not a panacea, it certainly has an important place in an XML developer’s toolkit.

James Wood

James Wood is the founder and principal consultant of Bowdark Consulting, Inc., an SAP NetWeaver consulting and training organization. With more than 10 years of experience as a software engineer, James specializes in custom development in the areas of ABAP Objects, Java/J2EE, SAP NetWeaver Process Integration, and SAP NetWeaver Portal. Before starting Bowdark Consulting, Inc. in 2006, James was an SAP NetWeaver consultant for SAP America, Inc., and IBM Corporation, where he was involved in multiple SAP implementations. He holds a master’s degree in software engineering from Texas Tech University. He is also the author of Object-Oriented Programming with ABAP Objects (SAP PRESS, 2009), ABAP Cookbook (SAP PRESS, 2010), and SAP NetWeaver Process Integration: A Developer’s Guide (Bowdark Press, 2011). James is also a contributor to Advancing Your ABAP Skills, an anthology that holds a collection of articles recently published in SAP Professional Journal and BI Expert.

See more by this author


No comments have been submitted on this article. 

Please log in to post a comment.

To learn more about subscription access to premium content, click here.