Return to BIG Manual

Step-Loop definition for Batch Input / BAPI-table definition

It is necessary to define a step-loop when there are tables in the screen in which data should be completed for the current record being processed. For example if in a transaction you should complete an employee's personal data, and in a certain moment it is requested to enter employee children's names, you should define a step-loop that will take children's data from another file (or record if single-file) thus being the employee number the field that will relate them. BAPI-tables works the same way. However, BAPI-tables are already defined when you select a BAPI (fields in red shows the beginning of a BAPI-table). This is an example of two files, the main file and the step-loop or BAPI-table file:

Main file:

Employee's number

Employee's name

Address

  Age

...

Step-loop or BAPI-table file:

Employee's number

Child's name Child's age

...

In the second file the employee's number will be repeated as many times as the number of children the employee has.

Based on this concept, it is possible to create programs that handle several step-loops or BAPI-tables, each of them will take data from different files/tables or different records within a file (if single-file). Records will be related with the main file/table/record by one or more fields called foreign key (in this case the foreign key is the employee's number).

If you are planning to take data from single-file, it is not always necessary to define a foreign key. It is only necessary when records are not sorted parent1/son1/son1/parent2/son2/.... These examples shows when a foreign key is necessary:

Single-file, records are sorted, foreign key is not necessary:

Record1: '001', employee's number(5),employee's name(), address(), age()

Record2: '002', child's name(), age()

00100001John Smith+++++++++++++Address++++++++++++++++++++++++++35...
002John Smith Jr++++++++++++5...
002Ann Smith+++++++++++++++2...
00100002Paul Martin+++++++++++++Address++++++++++++++++++++++++++38...
002Nicole Martin++++++++++++2...

 

Single-file, records are not sorted, foreign key is necessary:

Record1: '001', employee's number(5),employee's name(), address(), age()

Record2: '002', employee's number(5), child's name(), age() <<< The foreign key here is the employee's number

00200001Ann Smith+++++++++++++++2...
00100002Paul Martin+++++++++++++Address++++++++++++++++++++++++++38...
00200002Nicole Martin++++++++++++2...
00200001John Smith Jr++++++++++++5...

00100001John Smith+++++++++++++Address++++++++++++++++++++++++++35...

Before starting define whether you need to have a foreign key or not. If the source are multiple files, foreign key is obligatory,

Only for step-loops (Batch Input):

Typically there are two methods to enter data using step-loop: with "New Position" code or otherwise sending page down code. Both methods are supported in BIG, but not all transactions offer the possibility of "New Position". If you want to know if the transaction supports "New Position", click "Edit" and if it is supported there should be a submenu with "New Position".

Edit/New Position:

The advantage of this method is that Batch Input will run independently from computer's resolution, because only the positions one and two will be used for the input.

Page Down:

This method fills all the existing positions on the screen, pages down and repeats the process. Due to different screen resolutions, the number of positions may vary and the batch input fail (except for the case Batch Input runs using standard dynpro size with 1024*768 resolution). If you use this method you should count the number of positions the screen handles and enter that data in BIG.

It is advisable to use "New Position" when available.

Steps to define a step-loop:

Import or manually enter transaction/s. If you import data make sure that step-loop fields appear only once and that they contain the brackets that will indicate that those fields belong to a step-loop. If you enter them manually you must add the brackets to the step-loop fields (it is not necessary that they contain the subindex number).

This step-loop is wrong:

SAPLKMA1

0300

BDC_OKCODE

...

SGTXT

...

KNAME(1)

...

KNAME(2)

<-This field was already defined

BDC_OKCODE

...

This step-loop is correct:

SAPLKMA1

0300

BDC_OKCODE

...

SGTXT

...

KNAME(1)

...

BDC_OKCODE

...

Define the method to be used to load the step-loop (New Position/Page Down).

Double-click on the first of the step-loop fields of a given screen . Another screen will appear that will ask you the data to generate the step-loop (if this does not happen it is sure brackets are missing or otherwise a step-loop is already defined for such screen on another field). A screen supports only a step-loop that may be defined on any field containing a subindex.

The definition screen of the step-loop will request the method to be used for the entry of data, the file/table name from which data will be taken (it may be empty if all the data is taken from a file and "File as parameter" has been selected), an optional file/table description, the foreign key, the following available position to enter data after page-down or after sending "New Position" code (most of the transactions will leave position two available), and finally for the case of using the "Page Down" method, you should enter the number of positions per screen.

How to enter the OKCODE used for New Position/Page down?

The OKCODE for paging down/new position are not always the same; that is why besides providing BIG with the method you want to use, you should bring the OKCODE necessary to perform the action. For the case of a dynpro containing a step-loop, the action of page-down or new position will use the first OKCODE found in the screen definition, and the second OKCODE found will be used to leave the screen, save, or to continue to the next screen. 

This is the only case in which a screen requires two OK_CODEs; if a second OKCODE is not provided, none OKCODE will be sent to SAP and the latter will assume the OKCODE "/00" (Enter).

 The following is an example with normal and step-loops fields:

SAPLKMA1

0300

BDC_OKCODE

'=P+'

SGTXT

NORMAL1

KNAME(1)

DATA_STEP1

KTEXT(1) DATA_STEP2

BDC_OKCODE

'/00'

Only when any of the fields containing a subindex have a defined step-loop, KNAME and KTEXT will be converted in step-loop fields (on the other hand they are treated as normal fields and only the first position will be loaded).

Assuming the existence of a step-loop definition in the KNAME field, the first OKCODE will be the one used for paging down or obtaining a new position within the step-loop. The SGTXT field will be loaded only once -with the data obtained from NORMAL1 field of the main file/table-, and the data for KNAME and KTEXT will be loaded from a step-loop file. After filling the step-loop data, the program will continue to the next screen due to the OKCODE '/00'.

Once necessary step-loop definitions for Batch Input are ready, you should print the BIG report in order to see the structures of necessary input files/tables.

BAPI-tables only:

BAPI-tables are already predefined. If you are going to take data from a single-file with variable records, records are sorted "parent1/son1/son1/parent2/son2/son2" and files are parameters, you can skip this part.

If you are taking data from multiple files, or from a single file in which records are not sorted, then you should define the foreign key. After filling FILE SPECIFICATION (see Step to follow for BAPI-based program generation), double-click on red fields (the beginning of a BAPI-table), a screen will appear in which you will be able to select the foreign-key. If your source are not files as parameter, or your source are tables, you should also define the name of the source in this screen that appears.

It is recommended to print the BIG report in order to see the structures of necessary input files/tables.