Home > ABAP, Interface > BDC – Batch Data Communication

BDC – Batch Data Communication

April 14th, 2010 Leave a comment Go to comments

BDC is an abbreviation for Batch Data Communication. It is a common data transportation method and is especially useful in large data communication scenario. There are two methods to run BDC program. One is using statement ‘Call Transaction’ directly. In this method, the screen is simulated directly but difficult for error processing. The other method is to create a BDC session. Actual data transportation is executed when  running this BDC session. I will explain the two methods further.

The BAPI can also be used for data transfer as an alternative.

Call Transaction

With Call Transaction statement, the system process the data more quickly than BDC session. Before using this statement, you need to populate the BDC internal table with screen recording data and transactional data. External data does not have to be deposited in a session for later processing. Instead, the entire batch input process takes place inline in your program.

Syntax:

CALL TRANSACTION
 USING
 MODE
 UPDATE


A – Display all. All screens and the data that goes in them appear when you run your program.
E – Display errors only. All screens are processed invisibly, regardless of whether there are errors or not. Control returns to your program as soon as transaction processing is finished.
N – No display. The transaction goes into display mode as soon as an error in one of the screens is detected. You can then correct the error.

The update mode can be one of the followings:

S – Synchronous
A – Asynchronous
L – Local update

After the called transaction is processed, the message can be collected into an internal table. The internal table must have the structure of BDCMSGCOLL.

Generate BDC Session

n this method, program creates a batch input session with all transactional data. The session can be viewed, scheduled and processed using tcode SM35 later. It also provides a built-in error handling.

In order to transfer data to a batch input session, SAP provides a set of API for this purpose. The function modules BDC_OPEN, BDC_INSERT, BDC_OPEN_GROUP, BDC_CLOSE_GROUP and BDC_CLOSE are used to generate sessions.

After the session is generated, you can run it using tcode SM35. You can also create corresponding variants for program RSBDCSUB and schedule it using background job.

Code Snippets

Below code is to create a BDC internal table and call transaction TFCA with N mode. After the transaction is processed, the messages is collected and written to ABAP list.

DATA: BEGIN OF BDCDATA OCCURS 100.
  INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDCDATA.
 
DATA: BEGIN OF MESSTAB OCCURS 10.
  INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF MESSTAB.
 
BDCDATA-PROGRAM = 'SAPMTFCA'.
BDCDATA-DYNPRO = '0100'.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
 
CLEAR BDCDATA.
BDCDATA-FNAM = 'SFLIGHT-CARRID'.
BDCDATA-FVAL = 'XX'.
APPEND BDCDATA.
 
BDCDATA-FNAM = 'SFLIGHT-CONNID'.
BDCDATA-FVAL = '0400'.
APPEND BDCDATA.
 
CALL TRANSACTION 'TFCA' USING BDCDATA MODE 'N'
MESSAGES INTO MESSTAB.
 
LOOP AT MESSTAB.
  WRITE: / MESSTAB-TCODE,
    MESSTAB-DYNAME,
    MESSTAB-DYNUMB,
    MESSTAB-MSGTYP,
    MESSTAB-MSGSPRA,
    MESSTAB-MSGID,
    MESSTAB-MSGNR.
ENDLOOP.

The following link gives a BDC example using batch session method. Please check it out.

http://www.sap-img.com/ab001.htm

Reference

http://help.sap.com/saphelp_sm32/helpdata/EN/fa/09715a543b11d1898e0000e8322d00/content.htm

  1. Md
    July 28th, 2010 at 13:52 | #1

    very useful info.

    thanks

  1. No trackbacks yet.