Sie sind auf Seite 1von 18

IBM Global Services

Call Transaction Method

Data Interfaces |

Dec-2008

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 |

Dec-2008

2005 IBM Corporation

IBM Global Services

Overview
PROGRAM

DYNPRO

DYNBEGIN

SAPMF02K

0106

SAPMF02K

0110

FNAM

FVAL

RF02K-LIFNR

TEST1

RF02K-D0110

LFA1-STRAS
BDC_OKCODE

123 Main St.


=UPDA

BDC Table

Create Batch Input


Session
(BDC Program)

Data Interfaces |

Use in CALL
TRANSACTION
statement

Use in CALL DIALOG


statement

Dec-2008

2005 IBM Corporation

IBM Global Services

Differences in Batch Input Methods

When is the SAP


database updated?

Create batch
input session

During the processing of


the batch input session

(BDC Program):

CALL TRANSACTION:
CALL DIALOG:

During the execution of


the batch input program

Data Interfaces |

How are errors


handled?

Automatically by the
system during the
processing of the batch
input session

Must be handled in the


batch input program

Dec-2008

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

TEST1

Company Code
X

Address

Name

Computers, Inc.

Vendor

TEST2

Company Code
X

Address

Name

Computer Land

Street 123 Main St.

Street 10 Walnut St.

City

City

Philadelphia

Data Interfaces |

Boston

Dec-2008

2005 IBM Corporation

IBM Global Services

CALL TRANSACTION USING Statement

CALL TRANSACTION <transaction code>


USING

<bdc internal table>

MODE

<display mode>

UPDATE

<update mode>

MESSAGES INTO

<display mode>

<msg int. table>.

<update mode>

A: display all

S: synchronous

E: display errors only

A: asynchronous

N: no display

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

CALL TRANSACTION USING Statement (Contd.)

CALL TRANSACTION <transaction code>


USING

<bdc internal table>

MODE

<display mode>

UPDATE

<update mode>

MESSAGES INTO

<display mode>

<msg int. table>.

<update mode>

A: display all

S: synchronous

E: display errors only

A: asynchronous

N: no display

L: local update

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

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 **


8

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Example #1 - Main Program


Step #3
Step #4
Step #5
Step #6
Step #7

Step #8

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

Data Interfaces |

Dec-2008

2005 IBM Corporation

IBM Global Services

Example #1 - Main Program (Contd.)


Step #3
Step #4
Step #5
Step #6
Step #7

Step #8

Step #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_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 |

Dec-2008

2005 IBM Corporation

IBM Global Services

Example #1 - Subroutines
FORM FILL_BDC_TAB.
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.

ENDFORM.

FORM POPULATE_BDC_TAB USING


FLAG 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
files records read into the INREC structure.

11

Data Interfaces |

Dec-2008

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 |

Dec-2008

2005 IBM Corporation

IBM Global Services

BDC Program Flow


Declare BDC Table

Create & Record Program

Fill BDC Table

Collect Transaction Information

Batch Input Sessions


Process Batch Input Methods
Call Transaction

13

Data Interfaces |

Dec-2008

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.

With synchronous updating, we can


check SY-SUBRC to determine the
success of the transaction and the
actual update to the database.

14

Data Interfaces |

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 asynchronous updating, we


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

Dec-2008

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 |

Dec-2008

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 |

Dec-2008

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 |

Dec-2008

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 |

Dec-2008

2005 IBM Corporation

Das könnte Ihnen auch gefallen