Michal’s Tips: AIF mappings explained – #2 – XSLT mappings
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 that 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.
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.
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.
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.
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.
Question for readers
Have you been using AIF mappings in a way described in this blog ? If so can you please share your experience in the comment section ?
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 that in the near future.