Blog > Michal’s Tips: AIF mappings explained ” #2 ” XSLT mappings

Michal’s Tips: AIF mappings explained ” #2 ” XSLT mappings

Michał Kowalczewski Int4 IFTT Product Manager, SAP Press Author
icon__calendar 2016-08-24

Introduction

Many of us who used to work with SAP middleware platforms (SAP PI/PO, Business Connector) are got used to utilizing XSLT mappings in their daily work while developing message mappings. The best part is that there are many graphical XSLT editors available on the market so we can use those to simplify our mapping work a lot. We all know that SAP ABAP engine also provides a way to use XSLT mappings in the form of XSLT_TOOL application but can we somehow use it with SAP AIF. Together with my colleague Michal Rohnka we’ve implemented a simple concept of doing just that using XSLT mappings in SAP AIF structure mappings and I’d like to share the basic ideas of this concept in case anyone would like to use it in other projects.

How does SAP AIF mappings work?

SAP AIF is a pretty flexible tools and allows us not only to use standard AIF mappings or BRFPlus mappings but we can also implement the mapping logic in a form of a custom function module. We will use this custom module to call an XSLT transformation which will map the RAW structure to the SAP structure. Then we will design an XSLT mapping with XSLT_TOOL and we will use the custom function module in the SAP AIF structure mapping of the AIF interface to get the results in the Interface Test Tool.

Step 1

If we know the RAW and SAP structures of the AIF interface we can try to develop the XSLT program which will be responsible for transforming the source data to the target data. In my example I’m using the same structures as used in the previous article. Michal’s Tips: AIF mappings explained ” #1 ” Many qualifiers where those structures are described in detail. The development starts with transaction XSLT_TOOL where we need to select (“XSLT transformation” and not “Simple transformation”) and put in the our XSLT mapping code. The Figure below shows an example of a working XSLT mapping.

Step 2

As a next step we need to create a custom AIF mapping function module (by copying the template function module provided by SAP : /AIF/FILE_TEMP_MAP) which will be calling our XSLT transformation but as you’re about to find out it does not contain a lot of code – only 3 lines, which will just call the XSLT engine and a correct transformation from this engine.

Step 3

Since we have the mapping custom AIF mapping function module calling the XSLT transformation prepared and ready to use we can put it in the AIF structure mapping of the AIF interface where we intend to use it. We can do it as shown in the Figure below inside the Function Before Mapping field.

SAP AIF Testing Transaction

The last step is to give the mapping a try using the SAP AIF testing transaction. For the purpose of this article we’ve only mapped a single field RATE_TYPE_M into target field : RATE_TYPE and as you can see once we run the test the the mapping is showing a perfectly mapped target structure as shown in the Figure below.

Additional information

Special thanks to Michal Rohnka for his help with this concept.

In case you’d like to know how to get the XSDs of the AIF structures in order to use them in any graphical XSLT mapping engines I will try to post another article on the Int4 blog about it in the near future.


Michał Krawczyk – SAP integration consultant since 2004. He has been recognized by SAP included becoming an SAP Mentor in 2007 and winning the top contributor/topic leader award from SDN (SAP Developer Network portal) in SAP PO/PI eight times. Michal is the author many SAP integration related books.

Michał Rohnka – SAP ABAP and integration consultant since 2010. Involved in over 10 new solution implementation and improvement projects with usage of all leading SAP programming and integration technologies (ABAP, SAP PI/PO, BRF+, WebServices). Experienced also in archiving and upgrade projects.

Michał Kowalczewski Int4 IFTT Product Manager, SAP Press Author
SAP integration consultant & architect, team leader and project manager since 2005. Experienced in all leading SAP integration technologies (SAP PI/PO, ALE, HCI, BRF+, Enterprise Services, ABAP). Int4 IFTT Product Manager. In the past he was also involved in SD and CRM consulting. Accomplished more than 20 projects, both full cycle implementation and improvement projects. He holds a master?s degree in computer science and econometrics and is an SAP-certified solution and development consultant as well as SAP PRESS author. Business integration improvements, highly focused on the business processes, deep knowledge of ECC backend and SAP configuration (ALE, SD, MM, FI), advanced ABAP and PI/PO programming, strong leadership & management skills.