Call Transaction MethodDescribe the Call Transaction Method for
Batch Input.
Differentiate the different batch input methods.
Data Interfaces |
SAPMF02K 0106 X
BDC_OKCODE =UPDA
Data Interfaces |
In a batch input program, the contents of the BDC table can be used
three ways to perform the data transfer to the SAP system:
Use the BDC table to create a batch input session.
In this case, the batch input program is often called a BDC
program.
Use the BDC table in a “CALL TRANSACTION USING” statement.
Use the BDC table in a “CALL DIALOG” statement (outdated).
In chapter 5, we covered the first method – creating a batch input
session with the contents of the BDC table.
In this chapter, we will cover the batch input method – using the
BDC table in the “CALL TRANSACTION USING”.
When you perform batch input, you will generally be deciding
between the first two methods – creating a batch input session or
using the “CALL TRANSACTION USING” statement.
IBM Global Business Services
How are errors handled?
Create batch
input session
(BDC Program):
During the processing of the batch input session
Automatically by the system during the processing of the batch
input session
CALL TRANSACTION:
CALL DIALOG:
Data Interfaces |
Two questions illustrate the main differences between creating a
batch input session and using the “CALL TRANSACTION/DIALOG”:
When is the SAP database updated?
How are errors handled?
When is the SAP database updated?
If you create a batch input session in a BDC program, the SAP
database is updated during the processing of the batch input
session, not the execution of the BDC program.
If you use the “CALL TRANSACTION” or “CALL DIALOG” statement, the
SAP database is updated during the execution of the batch input
program. In other words, the timing issue we covered in the
previous chapter is not an issue with these two alternatives
because the database is updated during the execution of the batch
input program.
How are errors handled?
If you create a batch input session in a BDC program, errors are
handled automatically by the system during the processing of the
batch input session. Errors are recorded in a log and with the
batch input session error is kept.
If you use the “CALL TRANSACTION” or “CALL DIALOG” statement,
errors are not handled automatically by the system. Errors must be
handled in the batch input program.
IBM Global Business Services
City
Boston
To illustrate the “CALL TRANSACTION” and “CALL DIALOG” methods, we
will use the example to change vendors coming from a sequential
file.
Example - Change Vendors
Data Interfaces |
To illustrate the “CALL TRANSACTION” and “CALL DIALOG” methods, we
will use the example to change vendors coming from a sequential
file on the application server.
In chapter 5, we used this example to create a batch input session.
In this chapter, we will first use this example with the “CALL
TRANSACTION” method. Then, we will use it with the “CALL DIALOG”
method.
IBM Global Business Services
“CALL TRANSACTION USING” Statement
<update mode>
S: synchronous
A: asynchronous
Data Interfaces |
The “CALL TRANSACTION” statement executes an online program. When
this transaction is completed, processing returns to the “calling”
program. To perform batch input with the “CALL TRANSACTION”
statement, the “USING” addition is required to send the contents of
the BDC table to the transaction:
CALL TRANSACTION <transaction code>
The <bdc table> must be declared “LIKE BDCDATA”.
The only required addition for batch input is “USING”. The other
additions are only valid in conjunction with the “USING”
addition.
The <display mode> determines how the transaction will be
processed: ‘A’ (display all), ‘E’ (display errors only), or ‘N’ (no
display). The default is ‘A’.
IBM Global Business Services
<display mode>
Data Interfaces |
The <update mode> determines how database update will occur:
‘S’ (synchronous) or ‘A’ (asynchronous) or L (local update). The
default is ‘A’.
Synchronous updating indicates that an update is completed for the
transaction before processing returns to the “calling”
program.
Asynchronous updating indicates that processing returns to the
“calling” program immediately after the transaction is completed,
even before the update is completed.
Local update indicates that updates of the called program are
executed in such a way as if the SET UPDATE TASK LOCAL statement
had been executed in it.
System messages issued during the transaction can be stored in the
<msg int. table>. This internal table must be declared “LIKE
BDCMSGCOLL”.
IBM Global Business Services
DATA: BDC_TAB TYPE STANDARD TABLE OF BDCDATA INITIAL SIZE 6,
WA_BDC_TAB TYPE BDCDATA.
INFILE(20) VALUE ‘./bc180_file4’.
Step #1
Step #2
Data Interfaces |
To perform batch input using the “CALL TRANSACTION USING” statement
with multiple records from a sequential file on the application
server, perform the following steps in a batch input program:
Step #1: Create the BDC table.
This internal table must be declared “TYPE BDCDATA”.
Step #2: Define the structure in which the file’s records will be
read.
This structure should match the structure of the
file’s records.
The sequential file we are reading has the same format as the one
from chapter 5 (see page 12 of chapter 5). It is structured in
lines, so we will open it “IN TEXT MODE”.
These steps are continued on the next page.
IBM Global Business Services
DO.
IF SY-SUBRC <> 0.
Step #3
Step #4
Step #5
Step #6
Step #7
Step #8
Step #9
Data Interfaces |
Steps to perform batch input using the “CALL TRANSACTION USING”
statement (continued from previous page):
Step #3: Open the file “FOR INPUT”.
Step #4: Read a record from the file into the structure.
To read the complete file, you must code the “READ DATASET”
statement in a DO loop.
Step #5: Code a way out (EXIT) of the DO loop.
If SY-SUBRC is not 0, the end of the file has already been
reached.
Step #6: Fill the BDC table with the appropriate data for the
transaction (see next page).
This step will be executed for each record in the sequential
file.
Step #7: Insert a transaction’s data (from the BDC table) into the
transaction directly by using the “CALL TRANSACTION USING”
statement.
This step will be executed for each record in the sequential
file.
The display mode determines how this transaction is processed
(i.e., will you see the transaction’s screens or not).
IBM Global Business Services
DO.
IF SY-SUBRC <> 0.
** This program is continued on the next slide **
Step #3
Step #4
Step #5
Step #6
Step #7
Step #8
Step #9
Data Interfaces |
Step #8: Check SY-SUBRC to determine if an error occurred during
the transaction (SY-SUBRC <> 0).
The system does not automatically handle these errors like it does
during the processing of a batch input session. You must handle
these errors in the program (see page 8).
Step #9: Close the file.
IBM Global Business Services
Example #1 - Subroutines
Notice that the vendor number and street values are coming from the
file’s records read into the “INREC” structure.
Data Interfaces |
The two subroutines above are used to fill the BDC table. These two
subroutines are executed just before the BDC table’s contents are
passed to the transaction with the “CALL TRANSACTION USING”
statement.
IBM Global Business Services
Create a batch input session with the record(s) in error.
Data Interfaces |
With the “CALL TRANSACTION USING” statement (and the “CALL DIALOG”
statement), errors are not handled automatically by the system.
Therefore, you must handle these errors in the batch input
program.
After a “CALL TRANSACTION USING” statement (or a “CALL DIALOG”
statement), the value of SY-SUBRC indicates the success or
failure
of the transaction:
If SY-SUBRC is zero, the transaction (or dialog module) was
successful.
If SY-SUBRC is not zero, the transaction (or dialog module)
was
not successful.
Write an error report.
Create a batch input session with the record(s) in error.
This list of error handling methods is not complete. The exact
method chosen will depend on your specific requirements. Also,
these methods can be combined (i.e., you can create an error report
and send the records in error to an error file).
IBM Global Business Services
Synchronous versus Asynchronous
With synchronous updating, we can check SY-SUBRC to determine the
success of the transaction and the actual update to the
database.
With asynchronous updating, we can check SY-SUBRC to determine the
success of the transaction only, not the actual update to the
database.
Data Interfaces |
In the “CALL TRANSACTION USING” statement, you can specify the
update mode as synchronous or asynchronous. To restate the
difference:
Synchronous updating indicates that an update is completed for the
transaction before processing returns to the “calling”
program.
Asynchronous updating indicates that processing returns to the
“calling” program immediately after the transaction is completed,
even before the update is completed.
The difference in these update modes creates a trade-off between
the execution speed and the meaning of the return code.
With respect to the execution speed:
Synchronous updating is slower than asynchronous updating because
processing does not return to the “calling” program until the
update is complete.
Remember that the update mode when processing batch input sessions
is always synchronous.
With respect to the meaning of the return code:
The return code (SY-SUBRC) after synchronous updating indicates the
success or failure of the actual update. The return code after
asynchronous updating only indicates the success or failure of the
transaction, not the update.
IBM Global Business Services
Demonstration
Creation of a custom BDC program and changing customer address with
transaction XD02 (Change Customer) using the Call transaction
method.
Data Interfaces |
Practice
Creation of a custom BDC program and changing customer address with
transaction XD02 (Change Customer) using the Call transaction
method.
Data Interfaces |
Summary
If you use the “CALL TRANSACTION” or “CALL DIALOG” statement,
errors are not handled automatically by the system. Errors must be
handled in the batch input program.
The “CALL TRANSACTION” statement executes an online program. When
this transaction is completed, processing returns to the “calling”
program.
Data Interfaces |
Questions
What are the different batch input methods present in SAP for data
upload?
What is the difference between synchronous and asynchronous
update?
Data Interfaces |