
Mapping is one of the central parts of SAP Application Interface Framework. It happens quite seldom that a partner can deliver data in the way the SAP system needs, or SAP can deliver it in a way the partner needs it. So, often, we have mappings.
The first step is always to tell which field in the source structure shall be used for which target field. This is called the structure mapping.
If the relevant field is found, it might be usable directly. But it's also possible that we have to convert it, for example, $ to USD or 10.05.2019 to 20191005. This conversion is called value mapping. If a source structure can not provide a field at all, we might have to set fixed values or look it up in a table.
Additionally, SAP Application Interface Framework gives us the possibility to use conditions and have different mappings depending on those conditions. This makes it possible to use a special field if a fit exists, and use a more global field if not.
Structure mapping is done via Define Structure Mappings in SAP Application Interface Framework Customizing. The structure mapping activity contains different steps. These steps are described in a subprocess.

The source and destination structure of an interface usually differ. Therefore, structure mapping is needed. The structure mapping defines how the data from the source structure should be passed to the destination structure. To achieve this, some other SAP Application Interface Framework objects (for example, checks, value mappings, or fix values) are needed for structure mapping.
- Source Structure: Select the source structure.
- Destination Structure: Assign the destination structure corresponding to the source structure.
- Field Mappings: Map matching fields from source to destination structure.
- Checks: Create checks.
- Value Mappings: Derive a value from other values.
- Fix Values: Assign a fix value to a field.
- Conditions: Create a condition.
- Actions: Create an action to be executed during the processing of the interface.
Source Structure

To map structures, you need to select the source structure.
The source structure can be the root structure or any substructure or subtable of the root structure.
Depending on whether the processed interface is inbound or outbound, the source structure is:
- The raw data structure or a substructure/-table of it if the interface is an inbound interface
- The SAP data structure or a substructure/-table of it if the interface is an outbound interface
Destination Structure

The destination structure can be the root structure or any substructure or subtable of the root structure. It needs to be the counterpart of the previously selected source structure.
If the mapped structures are identical, you can map the fields of the structure via the Move Corresponding Fields functionality. Separate field mappings are not required in this case but can be added if needed.
If you select the Move Corresponding Fields checkbox, the complete structure including the substructure and subtables are mapped.
If you select the Copy Fields only checkbox, in addition to the Move Corresponding Fields checkbox, only the fields are mapped.
Field Mappings

If the structures are not identical, field mappings are required to map the different fields from the source structure to their counterparts in the destination structure.
A field in the destination structure can be build out of up to five fields of the source structure.

You have to map the fields of the source structure to the fields of the destination structure. You do this via field mappings.
To create a field mapping, at least the field in the destination structure and the field name of the source field is required. All other options are not mandatory.
In a field mapping, you can maintain the following information:
- Field in Destination Structure: Defines a field in the destination structure to where the data is mapped.
- Source Fields: You can insert up to five fields as source fields in the field name. The fields contain the name of a field in the source structure. These fields can also contain the field names of a destination structure field. In case a destination structure field was selected, an @ sign must prepend the field name. The defined fields are available as parameters and can be used in value mappings or checks. An offset and a length can be defined, as well as a separator string. The contents of the field name fields are split by this character or symbol in the destination structure. If multiple field names are maintained and no further settings are made, the values of the fields are concatenated into the destination field.
- Offset and Field Length: Specify the offset and field length of the data that should be passed into the destination field.
- Field Name for Data Link: If multiple fields are maintained in field name 1 to field name 5, this field indicates to which field an error should be linked in Monitoring and Error Handling if an error occurs during field mapping. If only field name 1 is maintained, this field is used automatically to create the link.
- Value Mapping Function: Maintain a function module for a value mapping.
- Value Mapping: The fields defined in field names 1 to 5 are available as parameters for the value mapping. To make use of the parameter, you have to insert '$<Fieldname number>' in an appropriate field in the value mapping. At runtime, '$<Fieldname number>’ is replaced by the current value of the field. They can be used in a "where" condition or in a value mapping function defined in this value mapping. If an error message was defined in the value mapping, the fields can be used to replace placeholders in the error message as well. Furthermore, they can be used as external values for a single or multiple value mapping table. If you enter a name of a value mapping that does not exist, the system offers you the opportunity to create the value mapping.
- Data Element for Conversion/Conversion Routine/Direction of Conversion Exit: Enter the conversion routine (for example, ALPHA) in the Conversion Routine field. Maintain the direction of the conversion in the Direction of Conversion field. Instead of entering a conversion routine, you can also insert a Data Element for Conversion (for example DATS).
- Namespace / Check: You can enter the namespace and name of a check here. The check is executed during field mapping. If the check fails, the field mapping will also fail. Per default, the data in field in Destination Structure will be checked. Select the Check Before Mapping checkbox to check the source data.
You can enter a fix value directly in the Field Name field. If a fix value should be entered in one of the source fields, you require a % followed by the value. For example, if the fix value for the field is 5, the field input has to be %5.

The SAP Application Interface Framework provides a tool to test interfaces. The tool can be started via the /AIF/IFTEST transaction. Create a test file for your interface. Test transformation from source to destination structure. Process test data.