Technical Articles
Excel Upload into AIF – using Hana Migration Cockpit
Some time ago we have checked the functionality of SAP Application Interface Framework (AIF) File Adapter to upload Excel Files into AIF (see Excel Upload using AIF File Adapter). Due to design of the AIF File Adapter it is not possible to provide complex structures within the excel. Also one outcome was that a header/item dependency cannot get customized and further development is needed within AIF to merge header/item data again. This articel shows some more comprehensive way of performing excel uploads into an AIF interface. Excel Uploads in general are provided with SAP S/4HANA migration cockpit. There are bunches of standard excel templates already provided to load data into the system. This blog post will explain how to create an own custom Hana Migration Object and connect it to an AIF interface. This allows you to upload data with the structures you have defined for your AIF Interfaces performing all the checks and value mappings (or any other custom data enrichments) that got implemented within the custom AIF interface.
In the blog post we will look at all the required steps that are needed to build up such a scenario. We are using in this blog post an AIF interface using the XML persistence of AIF. For a custom migration object all you need is a function that does the posting of the data you want to upload. This can be a BAPI e.g. or an own function. Our function will call the AIF Interface. Please expect a high level walkthrough.
This blog post was a co-work together with my colleague Alex Pfeil. Thank you Alex for your support putting together the scenario for this demonstration.
So lets start…
We will build up a scenario for a Business Partner Interface within SAP S/4HANA.
1) AIF Interface
AIF Structure defined (Structures from BAPI BAPI_BUPA_FS_CREATE_FROM_DATA2):
SE11
AIF Interface (/AIF/CUST)
No real structure mapping here, just “Move Corresponding”
/AIF/CUST
Action defined:
/AIF/ACTIONS
Action is calling the BAPI mentioned above:
ZAIF_BUPA_POST
Don´t forget to assign the action to the structure mapping:
Assign Actions
We use XML Engine, so change the Engines to XML (Default is Proxy)
Define Interfaces (Engine Fields)
2) Migration Cockpit Objects
Create Migration Project in transaction LTMC
LTMC
Create wrapper function module to call AIF interface The wrapper function is using the AIF interface structure as importing parameter:
ZAIF_MIG_BUPA
You might want to return the AIF Message ID in the Migration Cockpit:
ET_RETURN
Create Migration Object in SAP S/4HANA migration object modeler (transaction LTMOM)
LTMOM
LTMOM – Details
Fill in the Information from the wrapper function module as target structure.
LTMOM – Target Structure
Add the source structures for the Excel file
LTMOM – Source Structure
Export the fields from the target structure to an CSV file to reduce the effort for source fields
LTMOM – Export CSV
Import the CSV file in the source structure
LTMOM – Import CSV
(Tipp: In column group text you can group fields together)
Additional field MESSAGE_ID (for sending multiple AIF messages with 1 file) added and marked as key field + additional field TIMESTAMP in HEADER structure
LTMOM – Keyfield
Other fields can also be added as key fields to enable multiple rows of a structure:
LTMOM – Additional Keyfields
Structure mapping: Move the source structures to the target structures:
LTMOM – Structure Mapping
As we exported and imported the technical field names the source field names match with the target field names, so we can use the proposals feature in the field mapping:
LTMOM – Field Proposal
To make sure every source Field got mapped we can set a filter:
LTMOM – Show unmapped fields
MESSAGE_ID is not mapped, but only used to assign different lines in the Excel to an AIF message. TIMESTAMP is necessary for the HANA Migration Cockpit to assess whether the file is unique, so for every test it has to be changed. Alternatively you can implement some small logic to create new timestamp automatically with every upload.
3) Test
Now we can test by loading the SAP S/4HANA migration cockpit and opening the project
LTMC – Open Migration Project
Within the Migration Project open Migration Object
LTMC – Select Migration Object
Download EXCEL template to local desktop.
LTMC – Download Template
Open downloaded file with Excel and provide some data. Leave Central data empty.
LTMC – Header
LTMC – Org Data
LTMC – Telephone
LTMC – Address
Save the file and upload it back into Migration Cockpit.
LTMC – Upload
After upload activate the file and hit the button “Start Transfer”
LTMC – Activate
Now in the migration wizard just go through the steps by clicking “Next” (Simulate import can be skipped)
As a result we see that the Migration Cockpit has sent 2 messages to AIF:
LTMC – Result
We can also see the messages in transaction /AIF/ERR:
AIF – Monitor
Now let´s check if we can see the Business Partners in the Transaction BP:
Both Business Partners got created:
BP – Test1
BP – Test2
With the information shown above you have seen an example of how to create an own migration object and use it to upload data into an own interface using SAP S/4HANA migration cockpit and SAP Application Interface Framework without doing comprehensive coding.
If you have any questions about SAP Application Interface Framework also refer to our Q&A.