ME21N step by step: Creating a purchase order
This document describes how you can use Winshuttle Transaction to create a purchase order in the SAP Business Suite from data in Microsoft Excel using the SAP transaction ME21N.
Steps
Record
- Start Winshuttle Studio from the desktop shortcut or from the Windows Start menu.
- Click New.
- Click Transaction, and then click Create from Recording.
- Choose the SAP system that you want to use, enter the appropriate user data, and then click Log On to SAP.
If you do not see the SAP system that you want, click Advanced SAP Logon, click Add System, provide the system information, and click OK.
- In the Transaction code box, type ME21N.
- Leave the recording mode as Standard. If you do not see Standard, click Change and then click Batch Input Mode.
Note: For most transactions, the default mode is Standard, and the Winshuttle Function Module (WFM) selects the optimum mode for the t-code that is being recorded. If the WFM is not installed, Batch Mode will work for ME21N, and Non-Batch Input Mode Without Controls will work for most transactions. Non-Batch modes are necessary for downloading information from SAP transactions, or for Finance or HR transactions in which there are Dynamic Actions executing or user parameter values being used; otherwise, if you do not have access to Non-Batch modes, you can try recording in Batch Mode. The difference between Without SAP Controls and With SAP Controls is just a matter of what tools are on the transaction screens. For more information, see the Recording modes topic (Connect mode or Foundation mode).
- Click Start Recording
The ME21N transaction starts.
Note: The screens might appear slightly different in the recording mode because we are using a background mode. The screens might also vary according to the way that your SAP system has been configured.
- Enter the Vendor and Document Date, and then press Enter.
- Enter the header data.
Important: The next step might be different from the manual entry process.
- Press Enter to continue.
- Enter the required fields for a line item.
If necessary, you can enter data into the Item Details section for the selected item, and it will be recorded by Transaction.
In this example, however, we will enter data only in the Items grid.
- Press Enter.
Pressing Enter activates the Filter icon on the toolbar below the Item section.
- Click the Filter icon to clear the item grid so that data can be entered in the first row of the grid. This builds a repeatable process for running the Transaction script recording.
Clicking the Filter icon opens the Define filter criteria box.
- Select the Item column from the Column Set, and then click the left-pointing triangle.
This moves the Item column to the Filter criteria selection.
Note: The next step might differ between SAP versions.
- To provide Filter criteria, click the Filter icon in the Define filter criteria box.
If the box does not contain a filter icon, click the green checkmark to provide filter criteria.
- In the Determine values for filter criteria box, enter a value in the item field that will always result in no matches.
For example, it is highly unlikely (and technically impossible) to have more than 999 items in a purchase order. Entering a value of 99999 into this field ensures that the Items grid section is emptied between records and items can be entered into the first row of the grid. This is key to recording and running an ME21N Transaction script.
- Click the green checkmark to continue.
Notice that the Items grid section is now empty. We can continue to enter another item into this grid section, so that a pattern will be created in the Transaction Mapper screen.
- In the first row of the Items section, enter data in the required fields for the next Purchase Order item.
- Press Enter.
Again, the data will disappear from the grid because the filter is active.
- Click Save to save the Purchase Order. This also ends the recording.
After Studio finishes compiling the script, it will take you to the Map tab.
Map
It is now time to create the mapping for this transaction. Mapping a script is just a matter of connecting SAP fields to fields in your data file. Transaction provides a Mapper to facilitate this process.
Auto Mapping will map the entire script to an Excel spreadsheet in the order that they appear in the Mapper. Because of the complexity of this transaction, we will map the fields manually instead.
The screenshot below shows the Basic View tab of the Mapper.
In each row of the Mapper, you will see:
- Mapper row number: This is just a reference number.
- Enable flag: only enabled Mapper rows will be executed by Transaction.
- Field Description: The label associated with the SAP technical field name.
- Field Name: The SAP technical field name.
- Field Type & Length: For example, String or Decimal, and the padding options.
- Mapping direction: Fixed Value, Excel to SAP, SAP to Excel (or, if mapping to Access: Access to SAP, SAP to Access).
- Value: Values assigned to the SAP field; either fixed values or mapped locations in the associated data source.
Note: The Properties pane is also displayed, but it is not shown below.
In the Data Set panel, you will see a preview screen of the selected data source type.
To change the data source type, click the drop-down menu under the Data Set tab and choose the data source type that you want.
The preview will change to reflect the choice. In this case, we will use Excel.
- To map the script to the data source, you will drag in the direction that the data will move. For this script, you are uploading data from Excel to SAP, so you will drag from Excel to the Mapper.
Map the Header data first. In this example:
- Drag column B up and drop it onto row 2.
- Drag column C up to row 3.
- Drag column D up to row 4.
- Drag column E up to row 5.
Because the filter icon does not become active until the first line item is entered, that first line item will be part of the Header data.
Map the Line Item data. In this example:
- Drag column F up to row 6.
- Drag column G up to row 7.
- Drag column H up to row 8.
- Continue the mapping process for the next line item.
These will be considered the Detail line items, rather than Header line item.
To keep all of the purchase order line items lined up, map the same columns to the second line item rows in the Mapper.
- Drag column F up to row 10.
- Drag column G up to row 11.
- Drag column H up to row 12.
- Click the Expert View tab.
Expert View displays the fields organized by screens, and you can see the screen name, number, and description.
- To allow the Excel spreadsheet to contain data for multiple purchase orders with a variable number of line items in each purchase order, we will insert a loop around some of the Mapper rows.
In this example, select Mapper row 37, hold down the Shift key, and click row 42.
- Click the Create Loop button.
- The Loop box opens with default values, which you can change:
- The boxes at the top show the start and end rows of the loop in the Mapper (the highlighted rows—in this case, 37 through 42).
- The Loop identifier column box displays the column in the spreadsheet that will contain the Header and Detail (line item data) identifiers.
To map the loop identifier to column A, click the Loop identifier column box, click Show unmapped columns, click A, and then click Go.
- The Text to identify Transaction Header and Text to identify repeating Line Items boxes display the values that will identify the Header (H) and Line Item (D) rows.
- Click OK to insert the loop around the selected Mapper rows.
The Mapper reflects the following changes as a result of inserting the loop:
- The graphical depiction of the Loop around the selected lines indicates which Mapper rows will be contained within the loop.
- The ID column has been identified in the Preview panel and row 2 contains the first Header ID value.
Note: This will appear in the preview file only if you are mapping to a blank file.
Add the data and run the script
- Click the Run tab.
Note: Transaction will automatically assign the Log column to the next available column after the last mapped column (in this case, column I).
- Type the data in the columns (i.e., the data for creating new purchase orders).
The first line item needs to go in the same row as the header data.
You can specify a start and end row, specify the Excel sheet that contains the data, and change the Log column.
- To execute the upload, click the Test button, if you are a Foundation user, or click the Run button if you are not a Foundation user.
Studio prompts you to save the script and data files.
The best practice is to name the Excel spreadsheet the same name as the script unless an Excel spreadsheet will be used for multiple scripts.
After you save the script and data files, the script runs.
The yellow message bar displays a message when the run has finished.
The purchase orders are now created based on the data in the spreadsheet, and the purchase order numbers are returned in the Log column.