Call Transaction Method
Dec-2008 Data Interfaces |
Objectives
• The participants will be able to:– Describe the Call Transaction Method for Batch
Input.– Differentiate the different batch input methods.
Dec-2008 Data Interfaces | 2
Overview
Dec-2008 Data Interfaces | 3
PROGRAM DYNPRO DYNBEGIN FNAM FVAL
SAPMF02K 0106 X RF02K-LIFNR TEST1
RF02K-D0110 X
SAPMF02K 0110 X
LFA1-STRAS 123 Main St.
BDC_OKCODE =UPDA
BDC Table
Create Batch Input Session
(BDC Program)
Create Batch Input Session
(BDC Program)
Use in “CALL TRANSACTION”
statement
Use in “CALL TRANSACTION”
statement
Use in “CALL DIALOG” statement
Use in “CALL DIALOG” statement
Differences in Batch Input Methods
Dec-2008 Data Interfaces | 4
When is the SAP database updated?
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:
During the execution of the batch input program
Must be handled in the batch input program
Example - Change Vendors
Dec-2008 Data Interfaces | 5
Name
Street
Computers, Inc.
123 Main St.
City Philadelphia
Vendor
Company Code
TEST1
AddressX
Vendor
Company Code
TEST2
AddressX
Name
Street
Computer Land
10 Walnut St.
City Boston
To illustrate the “CALL TRANSACTION” and “CALL DIALOG” methods, we will use the example to change vendors coming
from a sequential file.
“CALL TRANSACTION USING” Statement
Dec-2008 Data Interfaces | 6
CALL TRANSACTION <transaction code>
USING <bdc internal table>
MODE <display mode>
UPDATE <update mode>
MESSAGES INTO <msg int. table>.
<display mode>
A: display all
E: display errors only
N: no display
<update mode>
S: synchronous
A: asynchronous
“CALL TRANSACTION USING” Statement (Contd.)
Dec-2008 Data Interfaces | 7
CALL TRANSACTION <transaction code>
USING <bdc internal table>
MODE <display mode>
UPDATE <update mode>
MESSAGES INTO <msg int. table>.
<display mode>
A: display all
E: display errors only
N: no display
<update mode>
S: synchronous
A: asynchronous
L: local update
Example #1 - Declaration Section
Dec-2008 Data Interfaces | 8
REPORT YDI00007.
DATA: BDC_TAB TYPE STANDARD TABLE OF BDCDATA INITIAL SIZE 6,
WA_BDC_TAB TYPE BDCDATA.
INFILE(20) VALUE ‘./bc180_file4’.
DATA: BEGIN OF INREC,
VENDNUM TYPE LIFNR,
STREET TYPE STRAS_GP,
END OF INREC.
PARAMETERS: DISPMODE DEFAULT ‘A’,
UPDAMODE DEFAULT ‘S’.
** This program is continued on the next slide **
Step #1
Step #2
Example #1 - Main Program
Dec-2008 Data Interfaces | 9
START-OF-SELECTION.OPEN DATASET INFILE
FOR INPUT IN TEXT MODE.DO.
READ DATASET INFILE INTO INREC.IF SY-SUBRC <> 0.
EXIT. ENDIF.
PERFORM FILL_BDC_TAB.CALL TRANSACTION ‘FK02’
USING BDC_TABMODE DISPMODEUPDATE UPDAMODE.
IF SY-SUBRC <> 0.WRITE: / ‘Error’.
ENDIF.ENDDO.CLOSE DATASET INFILE.
** This program is continued on the next slide **
Step #3
Step #4
Step #5
Step #6
Step #7
Step #8
Step #9
Example #1 - Main Program (Contd.)
Dec-2008 Data Interfaces | 10
START-OF-SELECTION.OPEN DATASET INFILE
FOR INPUT IN TEXT MODE.DO.
READ DATASET INFILE INTO INREC.IF SY-SUBRC <> 0.
EXIT. ENDIF.
PERFORM FILL_BDC_TAB.CALL TRANSACTION ‘FK02’
USING BDC_TABMODE DISPMODEUPDATE UPDAMODE.
IF SY-SUBRC <> 0.WRITE: / ‘Error’.
ENDIF.ENDDO.CLOSE DATASET INFILE.
** This program is continued on the next slide **
Step #3
Step #4
Step #5
Step #6
Step #7
Step #8
Step #9
Example #1 - Subroutines
Dec-2008 Data Interfaces | 11
FORM FILL_BDC_TAB.
REFRESH BDC_TAB.
PERFORM POPULATE_BDC_TABUSING:
‘1’ ‘SAPMF02K’ ‘0106’,‘ ’ ‘RF02K-LIFNR’ INREC-
VENDNUM,‘ ’ ‘RF02K-D0110’ ‘X’,
‘1’ ‘SAPMF02K’ ‘0110’,‘ ’ ‘LFA1-STRAS’ INREC-STREET,‘ ’ ‘BDC_OKCODE’ ‘=UPDA’.
ENDFORM.
FORM POPULATE_BDC_TAB USINGFLAG TYPE C
VAR1 TYPE C VAR2 TYPE C.
CLEAR WA_BDC_TAB.IF FLAG = ‘1’.
WA_BDC_TAB-PROGRAM = VAR1.WA_BDC_TAB-DYNPRO = VAR2.WA_BDC_TAB-DYNBEGIN = ‘X’.
ELSE.WA_BDC_TAB-FNAM = VAR1.WA_BDC_TAB-FVAL = VAR2.ENDIF.
APPEND WA_BDC_TAB TO BDC_TAB.
ENDFORM.
Notice that the vendor number and street values are coming from the file’s records read into the “INREC” structure.
Error Handling
Dec-2008 Data Interfaces | 12
Write an error report.
Send the record(s) in error to an error file.
Create a batch input session with the record(s) in error.
BDC Program Flow
Dec-2008 Data Interfaces | 13
Declare BDC Table Fill BDC Table
Collect Transaction InformationCreate & Record Program
Process Batch Input Methods
Batch Input Sessions
Call Transaction
Synchronous versus Asynchronous
Dec-2008 Data Interfaces | 14
DO.. . .PERFORM FILL_BDC_TAB.CALL TRANSACTION ‘FK02’
USING BDC_TABMODE ‘N’UPDATE ‘S’.
IF SY-SUBRC <> 0.WRITE: / ‘Error’.
ENDIF.ENDDO.
DO.. . .PERFORM FILL_BDC_TAB.CALL TRANSACTION ‘FK02’
USING BDC_TABMODE ‘N’UPDATE ‘A’.
IF SY-SUBRC <> 0.WRITE: / ‘Transaction error’.
ENDIF.ENDDO.
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.
Demonstration
• Creation of a custom BDC program and changing customer address with transaction XD02 (Change Customer) using the Call transaction method.
Dec-2008 Data Interfaces | 15
Practice
• Creation of a custom BDC program and changing customer address with transaction XD02 (Change Customer) using the Call transaction method.
Dec-2008 Data Interfaces | 16
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.
Dec-2008 Data Interfaces | 17
Questions
• What are the different batch input methods present in SAP for data upload?
• What is the difference between synchronous and asynchronous update?
Dec-2008 Data Interfaces | 18
Top Related