SAP AIF mappings
In this mapping series I will try to explain how to do different types of structure mappings in AIF. AIF’s mapping engine works in a different way as SAP PO, Service/SOA Mapping Tool (SMT) and Business Connector so it would be good to understand how to use it properly in your new integration projects. In case you’d know a different way (easier/better, etc.) to solve the same requirement as shown in the article please post a comment so we will have a single source where all AIF mapping best practice is shown.
There are situations where we need to create two or more lines from a single input line. A typical example of such a case might be when we need to map an input structure to an IDOC with multiple qualifiers. How to do this sort of mapping in AIF ?
Imagine we have a table structure with two types of rates: rate type M and rate type B are available in a single row or this structure as shown on Figure below. I’m using the exchange rate example as it’s available on most of the SAP application systems.
We need to map this to the standard IDOC with exchange rates where each rate needs to be mapped as a single row with a rate type (M or B) as a segment qualifier.
This means that for each row of the input structure we need to create two rows in the IDOC struture : E1BP1093_0.
We need to start by creating a target structure for E1EXCHANGE_RATE as shown in Figure below.
In the Field mapping for this structure we need to define how many times should the E1BP1093_0 structure be created. In our case we want to create it as many times as rows in the RATES table so we need to define this in the subtable. Subtable works in such a way that for every entry in the subtable a destination structure will be created.
In the next step we need to define the two indirect mappings one for each rate type (M and B). This is because we want to create twice as many times target structures E1BP1093_0 as source RATE structures (one for each rate qualifier).
Now for each of the indirect mappings we need to do the “real” field mapping. For the example we will only map “rate type” and “from currency” fields. The figure below shows the mapping of rate type M but you’d need to do the same for rate type B in the second indirect mapping of E1BP1093_0.
After we’d done with the mapping we can use the AIF testing tool to test if the mapping works correctly. The source structure contains two rows, each with two types of rates (M and B) as shown in figure below.
The target structure contains twice as many rows as the source structure due due to the requirement which was saying that each of the rate types needs to be created as a separate segment E1BP1093_0.
I hope the example will be useful for those starting with AIF mappings. If you’d have any comments, please do let me know.
Other AIF mapping resources:
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.