Purpose
This blog explains how to load purchase orders using the Winshuttle Studio with BAPI_PO_CREATE. I will show two cases, one for single document creation and another for mass migration. I will explain how create an script using a the SAP function module and what is the logic to fill the different sheets in the file template for purchase orders.
Transaction ME21N having several items is difficult to use in recordings, so I will use a function module " BAPI_PO_CREATE1 ", which is used to create purchase orders in SAP.
It has import structures:
and also tables.
In case we just need to create one document we can handle it in most cases with just one sheet, which is more user friendly in order to fill the fields and do the upload. We can add buttons with VBA to call different winshuttle scripts and I will explain later. This is particular useful to avoid the user to enter SAP and fill many fields in several sheets.
In order to identify header and items in the Winshuttle script we need to use an identifier, which will be a hidden column with value “H” for header and “P” for item.
For the case of mass migration we will have different sheets in order to fill the BAPI structures so we can enter as many documents as needed.
In Header we fill one line for each PO to be created. We have a column A with an identifier to link all sheets.
Item sheet:
Schedule lines:
Pricing conditions:
This follows similar logic to the load template provided by SAP for data migration cockpit.
You can add additional sheets for purchasing texts, accounting, …
There are different methods to create an script or a query. We chose the direct input in which BAPIs or RFC can be used.
You need to logon to SAP in order to import the RFC structure
Choose RFC and fill the field:
Once selected, we find all tables to fill in the function module with the fields. We need to select those that are relevant for the load, which includes the mandatory tables/fields as also other fields that need to be filled in the load. We will need to check the filed “commit required” so the data is created in SAP.
Mapping for single document/sheet
In order to fill the tables for items, conditions, partner functions, etc. we need to use the header/position identifier. Header will come with text “H” and item with text “P”
Mapping for multisheet/mass migration
If we have a mass migration with multiple sheets we need to have a column ID to link each record in the header with the ones in other sheets. Then we have to add a loop using the identifier (in column A).
We assign the values with the fields in the Excel file. The POHEADER has only one record for each line in the sheet. In table RETURN we assign the log messages sent by the function module.
We can do the same for schedule lines, pricing conditions, partner functions, etc.
We have the chance to use VBA code in order to perform activities in the Excel like filling sheets, clear cells and also call Winshuttle Scripts, so we use a button instead of the Winshuttle Studio Addon menu.
We add different modules with the necessary code in order to run the scripts. We can add information pop-ups, etc.
Before running the script, we can check the data with the winshuttle option in order to detect possible format or value errors as defined in the mapping. When ready, we can load the data online with the Run option or schedule a job.
If we have used VBA code to add button to call the scripts, that will make process more user friendly for the load, clear logs, download data to dropdown lists.
When we run the script, Winshuttle will write the log from table Return into the columns that we assigned. We get a clear message with possible errors or the purchase order number created.
We can download data in other excel sheets in order to use them for display values (materials, plants, … ) with their texts. For this Winshuttle has queries to access and retrieve SAP data from tables.
We will set the selection criteria based on excel values in cells or with a selection screen.
We can map the fields to the Excel columns where data is downloaded.
We can link several queries into one sequence, so all single scripts are executed with just one request. With VBA code we can add functionality to a button.
In S4 HANA we can also use the Migration Cockpit (transaction LTMC). A template for purchase orders can be filled and the load can take place with this tool.
Winshuttle provides a useful solution to load purchase orders getting a detailed log with the errors or document numbers created. The advantages over data migration cockpit are a more flexible file build (only mandatory and relevant fields need to be added) and more detailed log, which is more user friendly. Additionally, if the script is embedded in the Excel file, the user is able to do preload validations or load without using the Winshuttle Studio, which makes the validation & load tasks much easier.
The use of VBA code makes possible to add extra functionality like buttons, call scripts directly, make data import, conversions, data extraction from SAP …
Using Winshuttle helps the user to fill only the relevant fields instead of going through the several screens in ME21N.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 |