Help Center>Step-by-Step Guides Help

ME21N: 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.



  1. Start Winshuttle Transaction from the desktop shortcut or from the Windows Start menu.
  2. Click New.

    file tab new button

  3. Enter transaction code ME21N in the Transaction Code box, and then click Go.

    type me21n and click go

    An SAP Log On screen appears.

  4. Click the SAP system that you want to use, and then click OK.
  5. Enter the appropriate user data in the SAP Logon window, and then click the OK button.

    sap logon box

    Note: If you want to change SAP systems, click the System button and choose a different system.

  6. Choose Batch Input Mode.

    recording properties box

    Note: 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 Central mode).

  7. Enter any additional properties in the appropriate fields.
  8. To prevent people from editing the script, check the Lock TRANSACTION script box. This will password-­protect the script, preventing anyone from changing it.
  9. Click Next.

    You will now be launched into the ME21N transaction.

    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.

  10. Enter the Vendor and Document Date, and then press Enter.

    create purchase order screen

  11. Enter the header data.

    header data fields on create purchase order screen

    Important: The next step might be different from the manual entry process.

  12. Press Enter to continue.
  13. Enter the required fields for a line item.

    line item data entry

    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.

  14. Press Enter.

    Pressing Enter activates the Filter icon on the toolbar below the Item section.

    filter icon

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

    define filter criteria box with item selected

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

    item in the filter criteria list

    Note: The next step might differ between SAP versions.

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

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

    determine values for filter criteria box

  19. 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 crated in the Transaction Mapper screen.

    screen with empty item grid

  20. In the first row of the Items section, enter data in the required fields for the next Purchase Order item.
  21. Press Enter.

    Again, the data will disappear from the grid because the filter is active.

  22. Click Save to save the Purchase Order. This ends the recording, and you are brought back to Transaction.


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 and in order. Because of the complexity of this transaction, we will choose the Create Mapping option instead.

  1. Click the Create Mapping link in the middle pane.

    link to open mapper

    The Mapper opens and displays the Expert tab.

    • Mapper Row number: This is just a reference number.
    • Enable flag: only enabled Mapper rows will be executed by Transaction.
    • Screen / Screen Number: Technical screen information from the recorded transaction.
    • Field Description: The label associated with the SAP technical field name.
    • Field Name: The SAP technical field name.
    • Mapping Type: 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 values to or from the assigned data source.
    • Notes: Free­format notes to provide useful information to runners of the Transaction script.
  2. In the Data Source Preview section, you will see a preview screen of the selected data source.

    To change the Data Source, click the Change Source Type link at the top. This displays a drop­down box to switch to Microsoft Access. The Preview section will change to reflect the choice.

    change data type link

    In this case, we will use Excel.

  3. 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 SAP.

    Map the Header data first. In this example:

    • Drag column B up and drop it onto row 5.
    • Drag column C up to row 9.
    • Drag column D up to row 10.
    • Drag column E up to row 11

    header data mapped

    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 21.
    • Drag column G up to row 22.
    • Drag column H up to row 23.

    map first line item

  4. 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. When you receive a pop-up warning message, click No to keep the existing mapping.

    warning message click no

    • Drag column F up to row 40.
    • Drag column G up to row 41.
    • Drag column H up to row 42.
  5. 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 rows 37 through 42. Then click the Loop button at the top left of the screen.

    selected rows in mapper

  6. The Do While Properties box opens with default values, which can be overridden:
    • The start and end row refer to the rows in the Mapper that contain the loop (the highlighted rows—in this case, 37 through 42).
    • The MS Excel ID Column box displays the column in the spreadsheet that will contain the Header and Detail (line item data) identifiers.
    • The Header ID and Line Item ID displays the values that will identify the Header (H) and Line Item (D) rows.

    do while properties box

  7. Click the OK button 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 screen 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.

    loop indicator in mapper

  8. The next step is to save the script file (.TxR) and the Excel preview file (.xlsx). Click the Back arrow button at the top on the File menu.
  9. Transaction prompts you to save the Excel preview file.


    prompt to save preview file

    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.

    Note: If you want to use an existing Excel file that already has the data set up, you can skip saving the preview file and save the script file by clicking the Save button on the File menu.

  10. Click Yes, and then enter the Excel file name.
  11. Transaction prompts you to save the script.

    prompt to save script file

  12. Click Yes, and then enter the script’s name.

Add the data

Transaction loads the Run pane.

If necessary, you can navigate back to the Mapper by clicking the Update Mapping link on the Map pane.

link to open mapper and update mapping

  1. Click the Write Headers button to update the header columns in the Excel Spreadsheet. Then click OK.
  2. Click the Excel icon to the right of the Select Data File box. This will open the mapped Excel file that is listed in the Selected Data File box.

    Note: Transaction will automatically assign the Log column to the next available column after the last mapped column (in this case, column I).

    excel icon in run pane

  3. Type the data in the columns (i.e., the data for creating new purchase orders), and then save the Excel file.

    data in excel sheet

    After you enter the data into the Excel spreadsheet, you can run the script.


Back at the Transaction Run pane, you can specify a start and end row, specify the Excel sheet that contains the data, and change the Log column

  1. 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.
  2. In the SAP Logon window, if necessary, click the System button to select the appropriate SAP system.
  3. Enter the appropriate user data, and then click OK.

The purchase orders are now created based on the data in the spreadsheet, and the purchase order numbers are returned in the Log column.

log column after run