You are on page 1of 18

IBM Global Services

Call Transaction Method

Data Interfaces | 7.07

March-2005

2005 IBM Corporation

IBM Global Services

Objectives
The participants will be able to:
Describe the Call Transaction Method for Batch Input.
Differentiate the different batch input methods.

Data Interfaces | 7.07

March-2005

2005 IBM Corporation

IBM Global Services

Overview
PROGRAM SAPMF02K DYNPRO 0106 DYNBEGIN X FNAM FVAL

RF02K-LIFNR
RF02K-D0110 SAPMF02K 0110 X LFA1-STRAS BDC_OKCODE BDC Table

TEST1
X 123 Main St. =UPDA

Create Batch Input Session (BDC Program)


3 Data Interfaces | 7.07

Use in CALL TRANSACTION statement

Use in CALL DIALOG statement

March-2005

2005 IBM Corporation

IBM Global Services

Differences in Batch Input Methods

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:

During the execution of the batch input program

Must be handled in the batch input program

CALL DIALOG:

Data Interfaces | 7.07

March-2005

2005 IBM Corporation

IBM Global Services

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 Company Code

TEST1

Vendor Company Code

TEST2

Address

Address

Name

Computers, Inc.

Name

Computer Land

Street 123 Main St.


City
5

Street 10 Walnut St. City Boston


March-2005

Philadelphia
Data Interfaces | 7.07

2005 IBM Corporation

IBM Global Services

CALL TRANSACTION USING Statement

CALL TRANSACTION <transaction code> USING MODE <bdc internal table> <display mode>

UPDATE

<update mode>
<msg int. table>.

MESSAGES INTO

<display mode>
A: display all E: display errors only N: no display
6 Data Interfaces | 7.07

<update mode>
S: synchronous A: asynchronous

March-2005

2005 IBM Corporation

IBM Global Services

CALL TRANSACTION USING Statement (Contd.)

CALL TRANSACTION <transaction code> USING MODE <bdc internal table> <display mode>

UPDATE

<update mode>
<msg int. table>.

MESSAGES INTO

<display mode>
A: display all E: display errors only N: no display
7 Data Interfaces | 7.07

<update mode>
S: synchronous A: asynchronous

March-2005

2005 IBM Corporation

IBM Global Services

Example #1 - Declaration Section


REPORT YDI00007. Step #1

DATA: BDC_TAB LIKE STANDARD TABLE OF BDCDATA INITIAL SIZE 6 WITH HEADER LINE,
INFILE(20) VALUE ./bc180_file4. DATA: BEGIN OF INREC,

Step #2

VENDNUM
END OF INREC. PARAMETERS:

LIKE LFA1-LIFNR,

STREET LIKE LFA1-STRAS,

DISPMODE DEFAULT A, UPDAMODE DEFAULT S.

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


8 Data Interfaces | 7.07 March-2005

2005 IBM Corporation

IBM Global Services

Example #1 - Main Program


Step #3 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_TAB MODE DISPMODE UPDATE UPDAMODE. IF SY-SUBRC <> 0. WRITE: / Error. ENDIF. ENDDO. CLOSE DATASET INFILE. ** This program is continued on the next slide **
9 Data Interfaces | 7.07 March-2005

Step #4 Step #5

Step #6
Step #7

Step #8

Step #9

2005 IBM Corporation

IBM Global Services

Example #1 - Main Program (Contd.)


Step #3 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_TAB MODE DISPMODE UPDATE UPDAMODE. IF SY-SUBRC <> 0. WRITE: / Error. ENDIF. ENDDO. CLOSE DATASET INFILE. ** This program is continued on the next slide **
10 Data Interfaces | 7.07 March-2005

Step #4 Step #5

Step #6
Step #7

Step #8

Step #9

2005 IBM Corporation

IBM Global Services

Example #1 - Subroutines
FORM FILL_BDC_TAB. FORM POPULATE_BDC_TAB USING FLAG TYPE C VAR1 TYPE C VAR2 TYPE C. CLEAR BDC_TAB. IF FLAG = 1. BDC_TAB-PROGRAM = VAR1. BDC_TAB-DYNPRO = VAR2. BDC_TAB-DYNBEGIN = X. ELSE. BDC_TAB-FNAM = VAR1. BDC_TAB-FVAL = VAR2. ENDIF. APPEND BDC_TAB. ENDFORM. ENDFORM. Notice that the vendor number and street values are coming from the files records read into the INREC structure.
11 Data Interfaces | 7.07 March-2005

REFRESH BDC_TAB.
PERFORM POPULATE_BDC_TAB USING: 1 SAPMF02K RF02K-LIFNR VENDNUM, RF02K-D0110 1 SAPMF02K LFA1-STRAS BDC_OKCODE 0106, INRECX, 0110, INREC-STREET, =UPDA.

2005 IBM Corporation

IBM Global Services

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.

12

Data Interfaces | 7.07

March-2005

2005 IBM Corporation

IBM Global Services

BDC Program Flow


Declare BDC Table Fill BDC Table

Create & Record Program

Collect Transaction Information

Batch Input Sessions Process Batch Input Methods Call Transaction


13 Data Interfaces | 7.07 March-2005

2005 IBM Corporation

IBM Global Services

Synchronous versus Asynchronous


DO. ... PERFORM FILL_BDC_TAB. CALL TRANSACTION FK02 USING BDC_TAB MODE N UPDATE S. IF SY-SUBRC <> 0. WRITE: / Error. ENDIF. ENDDO. DO. ... PERFORM FILL_BDC_TAB. CALL TRANSACTION FK02 USING BDC_TAB MODE 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.

14

Data Interfaces | 7.07

March-2005

2005 IBM Corporation

IBM Global Services

Demonstration
Creation of a custom BDC program and changing customer address with transaction XD02 (Change Customer) using the Call transaction method.

15

Data Interfaces | 7.07

March-2005

2005 IBM Corporation

IBM Global Services

Practice
Creation of a custom BDC program and changing customer address with transaction XD02 (Change Customer) using the Call transaction method.

16

Data Interfaces | 7.07

March-2005

2005 IBM Corporation

IBM Global Services

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.

17

Data Interfaces | 7.07

March-2005

2005 IBM Corporation

IBM Global Services

Questions
What are the different batch input methods present in SAP for data upload?

What is the difference between synchronous and asynchronous update?

18

Data Interfaces | 7.07

March-2005

2005 IBM Corporation