Sunteți pe pagina 1din 18

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
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 Use in “CALL Use in “CALL DIALOG”


Session TRANSACTION” statement
(BDC Program) statement

Dec-2008 Data Interfaces | 3


Differences in Batch Input
Methods
When is the SAP How are errors
database updated? handled?

Automatically by the
Create batch During the processing of
system during the
input session the batch input session
processing of the batch
input session
(BDC Program):

During the execution of Must be handled in the


CALL TRANSACTION: the batch input program batch input program
CALL DIALOG:

Dec-2008 Data Interfaces | 4


Example - Change Vendors
To illustrate the “CALL TRANSACTION” and “CALL DIALOG”
methods, we will use the example to change vendors coming
from a sequential file.

Vendor TEST1 Vendor TEST2

Company Code Company Code

X Address X Address

Name Computers, Inc. Name Computer Land

Street 123 Main St. Street 10 Walnut St.

City Philadelphia City Boston

Dec-2008 Data Interfaces | 5


“CALL TRANSACTION USING”
Statement
CALL TRANSACTION <transaction code>
USING <bdc internal table>
MODE <display mode>
UPDATE <update mode>
MESSAGES INTO <msg int. table>.

<display mode> <update mode>


A: display all S: synchronous
E: display errors only A: asynchronous
N: no display

Dec-2008 Data Interfaces | 6


“CALL TRANSACTION USING”
Statement (Contd.)
CALL TRANSACTION <transaction code>
USING <bdc internal table>
MODE <display mode>
UPDATE <update mode>
MESSAGES INTO <msg int. table>.

<display mode> <update mode>


A: display all S: synchronous
E: display errors only A: asynchronous
N: no display L: local update

Dec-2008 Data Interfaces | 7


Example #1 - Declaration Section
REPORT YDI00007.

Step #1 DATA: BDC_TAB TYPE STANDARD TABLE OF BDCDATA


INITIAL SIZE 6,
WA_BDC_TAB TYPE BDCDATA.
INFILE(20) VALUE ‘./bc180_file4’.

Step #2 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 **


Dec-2008 Data Interfaces | 8
Example #1 - Main Program
START-OF-SELECTION.
Step #3 OPEN DATASET INFILE
FOR INPUT IN TEXT MODE.
DO.
Step #4 READ DATASET INFILE INTO INREC.
IF SY-SUBRC <> 0.
Step #5 EXIT.
ENDIF.
Step #6 PERFORM FILL_BDC_TAB.
CALL TRANSACTION ‘FK02’
Step #7 USING BDC_TAB
MODE DISPMODE
UPDATE UPDAMODE.
Step #8 IF SY-SUBRC <> 0.
WRITE: / ‘Error’.
ENDIF.
ENDDO.
Step #9 CLOSE DATASET INFILE.

** This program is continued on the next slide **


Dec-2008 Data Interfaces | 9
Example #1 - Main Program (Contd.)
START-OF-SELECTION.
Step #3 OPEN DATASET INFILE
FOR INPUT IN TEXT MODE.
DO.
Step #4 READ DATASET INFILE INTO INREC.
IF SY-SUBRC <> 0.
Step #5 EXIT.
ENDIF.
Step #6 PERFORM FILL_BDC_TAB.
CALL TRANSACTION ‘FK02’
Step #7 USING BDC_TAB
MODE DISPMODE
UPDATE UPDAMODE.
Step #8 IF SY-SUBRC <> 0.
WRITE: / ‘Error’.
ENDIF.
ENDDO.
Step #9 CLOSE DATASET INFILE.

** This program is continued on the next slide **


Dec-2008 Data Interfaces | 10
Example #1 - Subroutines
FORM FILL_BDC_TAB. FORM POPULATE_BDC_TAB USING
FLAG TYPE C
REFRESH BDC_TAB. VAR1 TYPE C
VAR2 TYPE C.
PERFORM POPULATE_BDC_TAB CLEAR WA_BDC_TAB.
USING: IF FLAG = ‘1’.
WA_BDC_TAB-PROGRAM = VAR1.
‘1’ ‘SAPMF02K’ ‘0106’, WA_BDC_TAB-DYNPRO = VAR2.
‘ ’ ‘RF02K-LIFNR’ INREC- WA_BDC_TAB-DYNBEGIN = ‘X’.
VENDNUM, ELSE.
‘ ’ ‘RF02K-D0110’ ‘X’, WA_BDC_TAB-FNAM = VAR1.
WA_BDC_TAB-FVAL = VAR2.
‘1’ ‘SAPMF02K’ ‘0110’, ENDIF.
‘ ’ ‘LFA1-STRAS’ INREC-STREET, APPEND WA_BDC_TAB TO
‘ ’ ‘BDC_OKCODE’ ‘=UPDA’. BDC_TAB.

ENDFORM. ENDFORM.

Notice that the vendor number and street values are coming from the
file’s records read into the “INREC” structure.
Dec-2008 Data Interfaces | 11
Error Handling

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.

Dec-2008 Data Interfaces | 12


BDC Program Flow
Declare BDC Table Fill BDC Table

Create & Record Program Collect Transaction Information

Batch Input Sessions

Process Batch Input Methods

Call Transaction

Dec-2008 Data Interfaces | 13


Synchronous versus Asynchronous
DO. DO.
... ...
PERFORM FILL_BDC_TAB. PERFORM FILL_BDC_TAB.
CALL TRANSACTION ‘FK02’ CALL TRANSACTION ‘FK02’
USING BDC_TAB USING BDC_TAB
MODE ‘N’ MODE ‘N’
UPDATE ‘S’. UPDATE ‘A’.
IF SY-SUBRC <> 0. IF SY-SUBRC <> 0.
WRITE: / ‘Error’. WRITE: / ‘Transaction error’.
ENDIF. ENDIF.
ENDDO. ENDDO.

With synchronous updating, we can With asynchronous updating, we


check SY-SUBRC to determine the can check SY-SUBRC to determine
success of the transaction and the the success of the transaction only,
actual update to the database. not the actual update to the
database.

Dec-2008 Data Interfaces | 14


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

S-ar putea să vă placă și