Help Center>Studio v11 (LMS)

Advanced looping

The way that you record line items depends on the transaction code. Find details for the t-code that you are recording in the step-by-step guides or on the Winshuttle Support site.

Multiple-line transactions

Some SAP transactions require multiple rows of data to be processed at the same time—for example, FB50, F-65, ME21, VA01, CS01, CA01, and FB70.

For many of these transactions, SAP separates the data into two parts:

  • A header section: The header contains data that remains constant for the entire transaction, such as a date.
  • One or more line item or detail sections: Each line item section typically contains reiterative data, which is entered in a grid-like area of the SAP transaction, such as journal entry line items.

    Tip: It's good to record two line items, so that you can see the repeatable pattern. Some t-codes, such as ME21N, require two line items, because the Filter function is not available until you complete the first line item.

After you record the script, including the line items, you create a loop around the line items. Then you set up your data file for the loop.

data layout for data and loop id column

The value in the Loop ID column tells Transaction whether the data in the row is part of the header section or a line of details.

Step-by-step instructions for adding basic loops are in Add a loop in Excel and Add a loop in Access.

Indexed loops

An indexed loop is useful when there is no position, search, or filter option in an SAP grid.

The index loop will imitate a scrolling action until it finds a blank row in the grid, ensuring that entries do not overwrite existing data. This is particularly helpful when there is no action in SAP that could be used in a normal loop.

Notes:
Indexed loops can be inserted only in scripts that were recorded in GUI Scripting mode.

You can't use an indexed loop to perform a find or select action. Instead, you can use an Index Field condition on a regular loop.

To use an indexed loop, you must specify an index field. Studio v11 will base the indexed loop on that column in the grid.

  1. When you're setting up the loop in the Loop box, check Index Based Loop.
  2. Choose a field in the Index Field box.

    index loop check box index field drop down menu

When the script runs, Studio will look for a row where that field does not contain a value in SAP and then upload the data to that row.

Multiple loops

Important: For best results when you use multiple loops in Transaction to upload data, do the following:
While recording the transaction, enter more than one line item in the transaction to create a visible pattern of repetition in the Mapper. After you add the loops, disable the extra item's rows from the Mapper.
If you use the same identifier column for different loops, use different identifier values for each loop—for example, D1 for the first loop and D2 for the second loop. You can use the same identifier if the loops refer to different identifier columns.

If the transaction includes separate sets of line items that are at the same level, you can create multiple loops at the same level in the same sheet. Because some rows will contain information for both loops, you will have a separate loop ID column for each loop, with a different loop identifier value for each loop.

Note: No indentation is needed for loops that are at the same level.

For example, here are the values in the Loop ID columns for a script that includes three loops at the same level.

header in first row line item identifier in each column

Nested loops

Important: The data for nested loops should be in the same order as the loops appear in the Mapper. For nested loops, the data must be indented in the data file even if you are using a separate identifier column.

Map nested loops

Studio v11 Transaction does not automatically map scripts that contain additional line-item data.

To map the script, click a column in the Excel data file and drag it to the field in the Mapper. Repeat for each field that you want to map. Or click Auto Map.

auto map command in sheet headers group

Prepare your workbook for running nested loops

When you upload nested loops, the header data and the details or line-item data in your Excel workbook must be placed on different rows. It looks similar to a simple loop, but you have extra rows for the nested loop.

Loop data layout for column-based mapping

data entered in different rows for nested loops

H - Header row 
D - multiple line items for loop 1 
D1- multiple line items for loop 2 
D
D1 
D1 

Copying and cutting rows with loops and conditions

You can copy or cut rows that contain loops and conditions. You must select all parts of the loop or condition to edit it. You cannot paste a loop or a condition into a log column.

Loop data on multiple sheets

To create a clearer presentation of data when multiple loops are present in a script, you can place the data for different loops on different Excel data sheets.

  • Master sheet: The Excel sheet containing the header data corresponding to the loop applied
  • Loop identifier column: The column on the header sheet that contains the join key
  • Line item sheet: The Excel sheet containing the line item data corresponding to the loop applied
  • Loop identifier column: The column on the line item sheet that contains the join key

You can assign the join key to any column that appears on all of the sheets.

Map multiple-sheet loops

  1. On the Map tab, in the Data Set panel, add as many new sheets as you need.
  2. Click the first sheet. In the Mapper, select the items for the first loop.
  3. Click the Create Loop button.

    Tip: Define all loops that are at the same level before you define any nested loops.

  4. For Loop type, click Multiple sheet loop.
  5. Select the appropriate sheets for the header and line items, and specify the corresponding join key columns.

    Important: When a script file is published, the published sheet must contain the same sheet names that are in the script.

  6. Map the fields to their respective Excel worksheets.
  7. If the data source is changed, the preview reverts to Untitled. Either add the sheets manually or open a sheet that contains the appropriate names.
  8. Save the data file preview before you close Studio, or data sheets might be deleted.

Invalid mapping

  • You cannot map a loop to a column that is not part of that loop.
  • You cannot validate when multiple sheets are present.
  • If conditions are validated as sheets are processed.
  • You can use only column-based mapping.
  • Extended logs are not available. Only regular logs are written to the header sheet.