Help Center>Studio (Connect)

Create a script from a BAPI

The trick to creating a script, or template, from a BAPI is knowing all of the BAPI's requirements. In Winshuttle Studio, you can check the Documentation panel to see the details.

Note: BAPI-based scripts cannot be mapped in Access data files. Be sure to use an Excel data source file.

This topic walks you step-by-step through the basic end-to-end process of creating a Transaction script file based on a BAPI.

Choose a creation method and log on to SAP

  1. Click the File tab, and then click New.
  2. Click Direct.
  3. Under Choose a Creation Method, click Create from BAPI.
  4. On the Winshuttle Studio logon screen, do one of the following:
    • Click the SAP system box and then click the SAP system you want to log onto.
    • Click Advanced SAP Logon. In the SAP Logon box, choose your SAP system, and then type your client number, user name, and password.

    Tip: To save your credentials for future sessions, check the Save as auto logon credentials box and type a name for the credentials in the Auto logon name box. The next time you log on to SAP from Studio, you will see your Auto logon name in the SAP system box and your other credentials. All you have to do is click the logon button.

  5. Click OK.
  6. In the Data type box, choose the type of data file you want to use—an Excel worksheet or an Access database.
  7. If you want to use an existing data file for your script, click the folder icon next to the Data file box and browse to the file you want to use.

    Note: If the data file contains any PivotTables, 3-D charts, or custom XML, the file will open in read-only mode. To keep PivotTables and other elements in the file, open it in Excel and run it in Background Mode. If you click Enable Editing, those elements will be removed from the file.

  8. Click Create Script.

Choose the BAPI, tables and fields

  1. In the Search/BAPI panel, choose BAPI or RFM.

    BAPI-search-BAPI

  2. Type the name or part of the name and wildcard characters—for example, *ACC_GL*—and then click Search.
  3. Click the BAPI or RFM that you want to use, and then click Create From Selected BAPI.
  4. If the BAPI requires a commit code, check the Commit required box.

    If the BAPI is an HR BAPI, check the Enqueue required box. The Enqueue box locks the personnel record so that updates can be made. After the HR update BAPI runs, the Enqueue lock is removed and the record is released.

  5. In the list, click a table that you want to use, and then in the workspace, click the check boxes for the fields that you want to use.

    In the right-hand panel, next to the table or structure name, Studio shows you how many fields are selected.

  6. After you select the tables and fields that you want to use, click the Expert View tab.

    Note: If this is not the BAPI you were looking for, you can click Search and look for a different BAPI. But when you add the new BAPI, Studio v11 will remove the previous BAPI and any field selections or mapping.

Map the fields

Winshuttle Studio automatically adds loops in the Mapper and selects padding for some data types.

To change the padding, be sure you are in Expert View. Then click the row to select it, click the Type & Length value, and click the padding option you want.

To map the fields, do one of the following:

  • Select a cell in the Data Set panel and drag it to a field in the Mapper. Repeat for each field that you want to include in the script.
  • Click Auto Map.

Map duplicate fields

Avoid data errors by mapping duplicate fields that are in different tables to the same column in your data file.

  1. In Expert View, click the column for the first instance of the field in the Data Set panel.
  2. Drag it to the duplicate instance of the field in the Mapper.

Both instances of the field will be mapped to the same column in the data file.

Change the loops

If you have related data across multiple tables—for example, the fields for a line item—you can replace the separate loops with one longer loop.

  1. Delete the second loop by selecting the row, right-clicking, and then clicking Delete.
  2. Click the remaining loop, and then change the row number in the through box to the last row that you want to include in the loop.
  3. Repeat steps 1 and 2 for any additional tables and fields that need to be part of the line item.

Specify required fields

When you run a BAPI script, some fields are required by SAP. To find out which fields are required, check the documentation for the table in the Documentation panel.

You can ensure that the data is required by clicking the field and then clicking the Required Field button (*) in the Value column. Or you can check the Data required box in the Properties panel.

Create a lookup list

BAPIs do not use SAP Lookup values, but you can create a list by using allowed values.

  1. Click the field to select it.
  2. Click Allowed Values.

    allowed values button in the mapper

  3. In the Allowed Values box, click Operator and choose an operator.
  4. Fill in the values or build the list.

Download data from SAP

You can use BAPIs to download data from SAP. Change the map direction to Download from SAP.

Run the script

After mapping SAP fields in the Mapper to the columns in the data file, you enter the data and run the script. Each row of data in the data file is uploaded to or downloaded from SAP.

The Run tab displays details about the script and data file that are being used. You can add a comment about why the script is being run in the Run reason box.

  1. Click the Run tab.
  2. Enter the data that you want to post.

    Important: BAPIs have some data formatting restrictions:
    The date format must match the date format that is specified in the regional settings on your computer, or it must be yyyymmdd.
    For some fields, the case format must be uppercase, or SAP will not be able to locate the item.

  3. Click Check Data to confirm that formatting is correct.
  4. Do one or both of the following:
    • Click Validate to check each row in the worksheet.
    • Click Simulate to check each record, or transaction, in the worksheet (this is available only for systems that have Winshuttle Function Module installed).
  5. Click Run, or click the arrow on the Run button and click one of the Run options.

If errors occur while the script is running, Studio continues to upload data for any remaining records. In Excel, any success and error messages returned from SAP are logged into the log result column, with one log per record.

Fix errors

  1. Correct the values.
  2. Click the arrow on the Run button, and then click Run Only Error Rows.

Studio uploads only the corrected records.

Run options

These options can be set by the script developer or by a script runner.

  • Run Specified Range: To upload only some of the rows in your data file. Use the Start Row and End Row boxes to specify the range.
  • Run First 5 Transactions: To run the first five rows in the data file to test the data before you start a large run.
  • Run Only Error Rows: To process rows after you have fixed the data in them.
  • Run Only Unprocessed Rows: To run rows that have been added or were not processed because the run stopped. This option can be set by the person running the script.

These options can be set only by the script developer.

  • Require Run Reason: To open the Run Reason box when the script is run. Winshuttle Studio adds some basic information about the script, but the person who starts the run can provide more details.
  • Run Only Unprocessed: To run rows that have been added or were not processed because the run stopped. This check box can be selected only by the script developer.
  • Upload Delay (ms): To add a slight processing delay (in milliseconds) between each row for transactions that require a delay for commit code processing.