Using CALL TRANSACTION USING For Data Transfer: The MODE Parameter
Using CALL TRANSACTION USING For Data Transfer: The MODE Parameter
Using CALL TRANSACTION USING For Data Transfer: The MODE Parameter
Processing batch input data with CALL TRANSACTION USING is the faster of the two recommended
data transfer methods. In this method, legacy data is processed inline in your data transfer program.
For more information, see choosing a data transfer method.
Syntax:
CALL TRANSACTION <tcode>
USING <bdc_tab>
MODE <mode>
UPDATE <update>
<tcode> : Transaction code
<bdc_tab> : Internal table of structure BDCDATA.
<mode> : Display mode:
A Display all
E Display errors only
N No display
<update> : Update mode:
S Synchronous
A Asynchronous
L Local update
A program that uses CALL TRANSACTION USING to process legacy data should execute the following
steps:
1. Prepare a BDCDATA structure for the transaction that you wish to run.
2. With a CALL TRANSACTION USING statement, call the transaction and prepare the BDCDATA
structure. For example:
CALL TRANSACTION 'TFCA' USING BDCDATA
MODE 'A'
UPDATE 'S'.
MESSAGES INTO MESSTAB.
IF SY-SUBRC <> 0.
<Error_handling>.
ENDIF.
The MODE Parameter
You can use the MODE parameter to specify whether data transfer processing should be displayed as it
happens. You can choose between three modes:
A Display all. All screens and the data that goes in them appear when you run your program.
N No display. All screens are processed invisibly, regardless of whether there are errors or not. Control
returns to your program as soon as transaction processing is finished.
E Display errors only. The transaction goes into display mode as soon as an error in one of the screens is
detected. You can then correct the error.
The display modes are the same as those that are available for processing batch input sessions.
The UPDATE Parameter
You use the UPDATE parameter to specify how updates produced by a transaction should be processed.
You can select between these modes:
A Asynchronous updating. In this mode, the called transaction does not wait for any updates it produces
to be completed. It simply passes the updates to the SAP update service. Asynchronous processing
therefore usually results in faster execution of your data transfer program.
Asynchronous processing is NOT recommended for processing any larger amount of data. This is
because the called transaction receives no completion message from the update module in
asynchronous updating. The calling data transfer program, in turn, cannot determine whether a called
transaction ended with a successful update of the database or not.
If you use asynchronous updating, then you will need to use the update management facility
(Transaction SM12) to check whether updates have been terminated abnormally during session
processing. Error analysis and recovery is less convenient than with synchronous updating.
S Synchronous updating. In this mode, the called transaction waits for any updates that it produces to be
completed. Execution is slower than with asynchronous updating because called transactions wait for
updating to be completed. However, the called transaction is able to return any update error message that
occurs to your program. It is much easier for you to analyze and recover from errors.
L Local updating. If you update data locally, the update of the database will not be processed in a
separate process, but in the process of the calling program. (See the ABAP keyword documentation on
SET UPDATE TASK LOCAL for more information.)
The MESSAGES Parameter
The MESSAGES specification indicates that all system messages issued during a CALL TRANSACTION
USING are written into the internal table <MESSTAB> . The internal table must have the structure
BDCMSGCOLL .
You can record the messages issued by Transaction TFCA in table MESSTAB with the following
coding:
(This example uses a flight connection that does not exist to trigger an error in the transaction.)
DATA: BEGIN OF BDCDATA OCCURS 100.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDCDATA.
DATA: BEGIN OF MESSTAB OCCURS 10.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF MESSTAB.
BDCDATA-PROGRAM = 'SAPMTFCA'.
BDCDATA-DYNPRO = '0100'.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
CLEAR BDCDATA.
BDCDATA-FNAM = 'SFLIGHT-CARRID'.
BDCDATA-FVAL = 'XX'.
APPEND BDCDATA.
BDCDATA-FNAM = 'SFLIGHT-CONNID'.
BDCDATA-FVAL = '0400'.
APPEND BDCDATA.
CALL TRANSACTION 'TFCA' USING BDCDATA MODE 'N'
MESSAGES INTO MESSTAB.
LOOP AT MESSTAB.
WRITE: / MESSTAB-TCODE,
MESSTAB-DYNAME,
MESSTAB-DYNUMB,
MESSTAB-MSGTYP,
MESSTAB-MSGSPRA,
MESSTAB-MSGID,
MESSTAB-MSGNR.
ENDLOOP.
The following figures show the return codes from CALL TRANSACTION USING and the system
fields that contain message information from the called transaction. As the return code chart
shows, return codes above 1000 are reserved for data transfer. If you use the MESSAGES INTO
<table> option, then you do not need to query the system fields shown below; their contents are
automatically written into the message table. You can loop over the message table to write out
any messages that were entered into it.
Return codes:
Value Explanation
0 Successful
<=1000 Error in dialog program
> 1000 Batch input error
System fields:
Name: Explanation:
SY-MSGID Message-ID
SY-MSGTY Message type (E,I,W,S,A,X)
SY-MSGNO Message number
SY-MSGV1 Message variable 1
SY-MSGV2 Message variable 2
SY-MSGV3 Message variable 3
SY-MSGV4 Message variable 4
Error Analysis and Restart Capability
Unlike batch input methods using sessions, CALL TRANSACTION USING processing does not provide
any special handling for incorrect transactions. There is no restart capability for transactions that contain
errors or produce update failures.
You can handle incorrect transactions by using update mode S (synchronous updating) and checking the
return code from CALL TRANSACTION USING. If the return code is anything other than 0, then you
should do the following:
write out or save the message table
use the BDCDATA table that you generated for the CALL TRANSACTION USING to generate a
batch input session for the faulty transaction. You can then analyze the faulty transaction and
correct the error using the tools provided in the batch input management facility.
Process flow
If you have generated a batch input program, the following function modules are automatically assigned
the correct values.
If you want to write your own program, proceed as follows:
2. Generate the batch input session using function module BDC OPEN GROUP.
3. The proceed as follows for each transaction that the session contains:
a. In the BDCDATA structure, enter the value for all screens and fields that must be
processed in the transaction.
b. Use BDC INSERT to transfer the transaction and the BDCDATA structure to the session.
4. Close the batch input session with BDC CLOSE GROUP
4. Start to process the generated session.
Process flow
7. Declare internal table <bdc_tab> .
8. Initialize the internal table before you call each new transaction.
9. At the beginning of each new screen, you must maintain the module pool name <program> , the
screen number <dynpro> and a flag:
<bdc_tab>-FNAM = <fnam>.
<bdc_tab>-FVAL = <fval>.
APPEND <bdc_tab>.
If the field is in a step loop or a table control, you must also specify the lines in which the input is
to be entered. The field name extension displays the line number:
<bdc_tab>-FNAM = 'fieldx(5)'.
11. If you want to position the cursor on a particular field, enter the cursor position by filling field FNAM
with the value BDC_CURSOR, and transferring into the field FVAL the technical name <tname> of
the field where the cursor should be:
<bdc_tab>-FNAM = 'BDC_CURSOR'.
<bdc_tab>-FVAL = <tname>.
APPEND <bdc_tab>.
If you want to position the cursor on a field in a step loop or table control, you must also specify
the lines in which the input is to be entered. The field name extension displays the line number:
<bdc_tab>-FVAL = 'fieldx(5)'.
12. Now specify which action is to be executed in this screen. You must determine the triggered
function code <fcode> and assign this with the field FVAL . Note that the character ' / ' should
always be placed before the function key number. The character ' = ' must be placed before all
other function codes.
Assign value BDC_OKCODE to the field FNAM :
<bdc_tab>-FNAM = ‘BDC_OKCODE’.
<bdc_tab>-FVAL = <fcode>.
APPEND <bdc_tab>.
13. Execute steps 3 to 6 for each additional screen in the transaction.
8. After the last screen in the transaction, internal table <bdc_tab> is filled with all of the values
required. You can now use this table to create an entry in a batch input session or to call the
commands CALL TRANSACTION or CALL DIALOG .
The transaction to which a BDCDATA structure refers is identified separately. If your program
writes data to a batch input session, then the transaction is specified in the call to the
BDC_INSERT function module. This function module writes a BDCDATA structure out to the
session. If your program processes data with CALL TRANSACTION USING, then the transaction
is specified directly in this statement.
The following table shows what the contents of a BDCDATA structure might look like. This
BDCDATA structure would add a line to a report in Transaction SE38, the ABAP Editor:
BDCDATA Structure for Adding a Line to a Report (Transaction SE38)
PROGRAM DYNPRO DYNBEGIN FNAM FVAL
SAPMS38M 0100 X
RS38M-PROGRAMM <Name>
RS38M-FUNC_EDIT X
BDC_OKCODE =CHAP (Change
function code)
SAPMSEDT 2310 X
RSTXP-TDLINECOM(1) B-
SAPMSEDT 2310 X
BDC_CURSOR RSTXP-
TDLINECOM(1)
RSTXP-TDLINE(1) BDC Test Text
BDC_OKCODE /11 (Save function
key)
SAPMSEDT 2310 X
BDC_OKCODE /3 (Back function
key)
SAPMS38M 0100 X
BDC_OKCODE /15 (Quit function
key)
Direct Input
To enhance the batch input procedure, the system offers the direct input technique, especially for
transferring large amounts of data. In contrast to batch input, this technique does not create sessions, but
stores the data directly. It does not process screens. To enter the data into the corresponding database
tables directly, the system calls a number of function modules that execute any necessary checks. In case
of errors, the direct input technique provides a restart mechanism. However, to be able to activate the
restart mechanism, direct input programs must be executed in the background only. To maintain and start
these programs, use program RBMVSHOW or Transaction BMV0.
Program Application
RFBIBL00 FI
RMDATIND MM
RVAFSS00 SD
RAALTD11 AM
RKEVEXT0 CO-PA
Working with Step Loops
Step loops are considerably less flexible than their replacement, table controls.
Step Loops
You can group screen elements together into a step loop. A step loop is a repeated series of loop blocks.
A loop block consists of one or more loop lines of graphical screen elements. You can define a loop block
as fixed or variable.
In a fixed loop, the lower limit of the loop area always remains as originally defined. For a variable loop,
the number of repetitions is adjusted dynamically in the screen program to suit the size of the current
window. In order to be able to react to the variable loop size, the system always places the current
number of loop blocks in the system field SY-LOOPC. If the screen includes several loop blocks, you can
define only one of these as variable.
When you execute a screen with several loop blocks, the online processor runs through this "screen
table" line by line.
Do not use the steploop method to format lists. Use a report program instead.
The step loop procedures in the alphanumeric display are different. For further
information, see Creating and Editing Steploops in Alphanumeric Mode.
Creating a Steploop
To edit a loop block as a complete unit, click on the loop's border handles. By choosing Edit
Grouping Steploop, you can manipulate the block using functions such as Define, Variable or
Fix, or Undefine.
To remove an element from a block, click on the element and choose Delete. If you delete all the
elements, the block is deleted as well.
To dissolve a loop block, select it and choose Edit Steploop Undefine. The individual
elements then become normal screen elements again.
To define a steploop as fixed or variable, select a steploop and choose Edit Grouping
Steploop Fix or Variable. Recall that a variable loop is adjusted dynamically with the screen
size and a fixed loop is not.
When you have completed the definition procedure, see the ABAP User’s Guide for information on
programming steploops.
Converting a Step Loop
You can convert a steploop into a table control. When converting a steploop, you have to decide whether
to include headings in the conversion or not.
Select a steploop without including its headings and choose Edit Convert Table Control. The system
creates a table control that is exactly the size initially occupied by the original steploop.
The first row of the table control (used for column headings) remains empty. Multiple-line steploops are
linked to one table row. If the row is too long to fit into the visible area, you must scroll the table to view
the row. The system calculates the table's column widths from the space between the elements in the
original steploop.
Select a steploop together with its headings as a group and choose Edit Convert Table Control.
The system creates the table and fills the heading row with the headings from the steploop. The headings
are inserted according to the sequence of the steploop columns and not according to their names.
The system adjusts the table control height to include the former headings.
To edit a step loop, you must be in the Change Loop Definition screen. To edit an existing loop block,
place the cursor on the block and choose Loop. The following functions are available for editing a step loop:
function Explanation
End line of loop Defines the length of the loop area. The system automatically repeats the block
within the defined area.
Variable loop Defines a variable loop. With a variable loop, the system adjusts the number of
repetitions dynamically in the screen program to suit the size of the current window.
If the screen includes several loop blocks, you can define only one of these as
variable.
The maximum number of lines is 200. In order to be able to react to the variable
loop size, the system always places the current number of loop blocks in the
system field SY-LOOPC.
With a fixed loop, the lower limit of the loop area always remains as originally
defined.
Dissolve Dissolves the loop by placing its fields in the screen.
Move loop Moves the loop to a new location.
You can make changes only in the definition block. Changes in the definition block automatically affect the
repetition blocks. In the actual definition block, you can change the attributes of elements as usual. You
can also define new elements or delete elements. However, you cannot insert or delete lines within the
loop block.
If you choose either Edit Select or Edit Temporary storage Copy to temp.storage, you can work in
the same way as for fields not in a loop. However, you can select only elements in the loop definition
block. The selected block cannot exceed the loop limits.
You can copy elements from outside to the loop block or vice versa. In both cases, the system adapts the
element attributes accordingly. When you copy to a loop block, the elements are automatically added to
the corresponding repetition elements. When you copy from a loop block, the same repetition elements
are deleted.