Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
fernando_martin
Participant
0 Kudos
564

How to load purchase orders in S/4HANA with Winshuttle

 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.

 

 

Build load file for Winshuttle Studio purchase order load – single document

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:

Picture1.png

and also tables.

Picture2.png

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.

Main_excel.JPG

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.

Picture4.png

 

 

Build load file for Winshuttle Studio purchase order load – mass migration

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.

Picture5.png

Item sheet:

Picture6.png

Schedule lines:

Picture7.png

Pricing conditions:

Picture8.png

This follows similar logic to the load template provided by SAP for data migration cockpit.

You can add additional sheets for purchasing texts, accounting, …

 

Create the script with Winshuttle Studio v12.x

There are different methods to create an script or a query. We chose the direct input in which BAPIs or RFC can be used.

Picture9.png

Picture10.png

You need to logon to SAP in order to import the RFC structure

Picture11.png

Choose RFC and fill the field:

Picture12.png

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.

Picture13.png

 

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”

Picture14.png

 

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).

Picture15.png

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.

 

Add VBA code to Excel to run scripts and other actions

 

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.

Picture16.png

Picture17.png

Run the script with Winshuttle Studio to create purchase orders

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.

Picture18.png

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.

Picture19.png

 

Download data for dropdown lists

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.

WS_Query.JPG

We will set the selection criteria based on excel values in cells or with a selection screen.

WS_Query2.JPG

We can map the fields to the Excel columns where data is downloaded.

WS_Query3.JPG

 

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.

Alternatives

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.

 

Summary

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.

Labels in this area