SAP ABAP BDC: What is Batch Data Communication?

โšก Smart Summary

SAP ABAP BDC (Batch Data Communication) transfers legacy data into R/3 by driving standard transactions automatically. This page explains batch input sessions, the classical and call transaction methods, the BDCDATA structure, the BDC_OPEN_GROUP workflow, and the batch input recorder.

  • ๐Ÿ”„ Core Purpose: BDC feeds datasets into the screens of a transaction automatically, running every screen and business validation as a user would.
  • ๐Ÿงพ Batch Input Session: A session groups transaction calls with their input data and is stored in the database until it is executed.
  • ๐Ÿ› ๏ธ Two Methods: Classical batch input uses BDC_OPEN_GROUP, BDC_INSERT, and BDC_CLOSE_GROUP, while the call transaction method uses CALL TRANSACTION USING.
  • โš–๏ธ Method Choice: Classical batch input is synchronous with a log, and call transaction is faster, asynchronous, and handles a single transaction.
  • ๐Ÿ—‚๏ธ BDCDATA Structure: The fields PROGRAM, DYNPRO, DYNBEGIN, FNAM, and FVAL describe the screen, the field, and the value for each step.
  • โบ๏ธ Recorder: The batch input recorder captures a manual transaction and generates a session or a ready made BDC program that runs later in SM35.

SAP ABAP BDC Batch Data Communication

Introduction to Batch input

Batch input is typically used to transfer data from non-R/3 systems to R/3 systems or to transfer data between R/3 systems.

It is a data transfer technique that allows you to transfer datasets automatically to screens belonging to transactions, and thus to an SAP system. Batch input is controlled by a batch input session.

Batch input session

Groups a series of transaction calls together with input data and user actions . A batch input session can be used to execute a dialog transaction in batch input, where some or all the screens are processed by the session. Batch input sessions are stored in the database as database tables and can be used within a program as internal tables when accessing transactions.

Points to note

  • BDI works by carrying out normal SAP transactions just as a user would but it execute the transaction automatically.All the screen validations and business logic validation will be done while using Batch Data Input.
  • It is suitable for entering large amount of data.
  • No manual interaction is required

Methods of Batch Input

SAP provide two basic methods for transferring legacy data in to the R/3 System.

  1. Classical Batch Input method.
  2. Call Transaction Method.

Classical Batch Input method

In this method an ABAP/4 program reads the external data to the SAP System and stores in a batch input session.

After creating the session, you can run the session to execute the SAP transaction in it.

This method uses the function modules BDC_ OPEN, BDC_INSERT and BDC_CLOSE

Batch Input Session can be process in 3 ways

  1. In the foreground
  2. In the background
  3. During processing, with error display

You should process batch input sessions in the foreground or using the error display if you want to test the data transfer.

If you want to execute the data transfer or test its performance, you should process the sessions in the background.

Points to note about Classical Batch Input method

  • Synchronous processing
  • Transfer data for multiple transactions.
  • Synchronous database update.
  • A batch input process log is generated for each session.
  • Session cannot be generated in parallel.

Call Transaction Method.

In this method ABAP/4 program uses CALL TRANSACTION USING statement to run an SAP transaction.

Entire batch input process takes place online in the program

Call Transaction Method

Points to Note:

  • Faster processing of data
  • Asynchronous processing
  • Transfer data for a single transaction.
  • No batch input processing log is generated.

Classical Batch Input vs Call Transaction

The two methods reach the same transaction but differ in speed, logging, and error handling. The table below shows when each one is the right choice.

Criteria Classical Batch Input Call Transaction
Technique BDC_OPEN_GROUP, BDC_INSERT, BDC_CLOSE_GROUP CALL TRANSACTION USING
Processing Synchronous, run later from SM35 Runs online, in the program
Transactions Many transactions in one session A single transaction per call
Log A process log per session is generated automatically No log, the program collects the messages
Speed Slower, but robust and restartable Faster
Best for Large, one time legacy loads that must be auditable Interactive or high speed transfers of one document

With the methods compared, the next section lays out the overall procedure a project follows.

Batch Input Procedures

Batch Input Procedures

You will typically observe the following sequence of steps to develop Batch Input for your organization

  1. Analysis of the legacy data. Determine how the data to be transferred is to be mapped in to the SAP Structure. Also take note of necessary data type or data length conversions.
  2. Generate SAP data structures for using in export programs.
  3. Export the data in to a sequential file. Note that character format is required by predefined SAP batch input programs.
  4. If the SAP supplied BDC programs are not used, code your own batch input program. Choose an appropriate batch input method according to the situation.
  5. Process the data and add it to the SAP System.
  6. Analyze the process log. For the CALL TRANSACTION method, where no proper log is created, use the messages collected by your program.
  7. From the results of the process analysis, correct and reprocess the erroneous data.

Writing BDC program

You may observe the following process to write your BDC program

  1. Analyze the transaction(s) to process batch input data.
  2. Decide on the batch input method to use.
  3. Read data from a sequential file
  4. Perform data conversion or error checking.
  5. Storing the data in the batch input structure,BDCDATA.
  6. Generate a batch input session for classical batch input,or process the data directly with CALL TRANSACTION USING statement.

Batch Input Data Structure

Declaration of batch input data structure

DATA : BEGIN OF < bdc table>

OCCURS <occurs parameters>.

INCLUDE STRUCTURE BDCDATA.

DATA:END OF <bdc table>.
Field name Type Length Description
PROGRAM CHAR 8 Module pool
DYNPRO NUMC 4 Dynpro number
DYNBEGIN CHAR 1 Starting a dynpro
FNAM CHAR 35 Field name
FVAL CHAR 80 Field value

The order of fields within the data for a particular screen is not of any significance

Points to Note

  • While populating the BDC Data make sure that you take into consideration the user settings. This is specially relevant for filling fields which involves numbers ( Like quantity, amount ). It is the user setting which decides on what is the grouping character for numbers E.g.: A number fifty thousand can be written as 50,000.00 or 50.000,00 based on the user setting.
  • Condense the FVAL field for amount and quantity fields so that they are left aligned.
  • Note that all the fields that you are populating through BDC should be treated as character type fields while populating the BDC Data table.
  • In some screens when you are populating values in a table control using BDC you have to note how many number of rows are present on a default size of the screen and code for as many rows. If you have to populate more rows then you have to code for “Page down” functionality as you would do when you are populating the table control manually.
  • Number of lines that would appear in the above scenario will differ based on the screen size that the user uses. So always code for standard screen size and make your BDC work always in standard screen size irrespective of what the user keeps his screen size as.

Creating Batch Input Session

  1. Open the batch input session session using function module BDC_OPEN_GROUP.
  2. For each transaction in the session:
  3. Fill the BDCDATA with values for all screens and fields processed in the transaction.
  4. Transfer the transaction to the session with BDC_INSERT.
  5. Close the batch input session with BDC_CLOSE_GROUP

Example: BDC using Call Transaction

The program below shows the call transaction method end to end. It builds the BDCDATA table for two screens of a transaction and runs it in mode N (no display) with an error table so that failures can be reported.

REPORT z_bdc_call_transaction.

DATA: lt_bdcdata TYPE STANDARD TABLE OF bdcdata,
      ls_bdcdata TYPE bdcdata,
      lt_messages TYPE STANDARD TABLE OF bdcmsgcoll.

* Helper that appends one BDCDATA line
FORM bdc_field USING p_fnam p_fval.
  CLEAR ls_bdcdata.
  ls_bdcdata-fnam = p_fnam.
  ls_bdcdata-fval = p_fval.
  APPEND ls_bdcdata TO lt_bdcdata.
ENDFORM.

* Screen 1: start the dynpro, then fill the fields
CLEAR ls_bdcdata.
ls_bdcdata-program  = 'SAPMV45A'.
ls_bdcdata-dynpro   = '0101'.
ls_bdcdata-dynbegin = 'X'.
APPEND ls_bdcdata TO lt_bdcdata.

PERFORM bdc_field USING 'VBAK-AUART' 'OR'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.

* Run the transaction: mode N = no display, update S = synchronous
CALL TRANSACTION 'VA01'
  USING         lt_bdcdata
  MODE          'N'
  UPDATE        'S'
  MESSAGES INTO lt_messages.

IF sy-subrc <> 0.
  * Read lt_messages to report the errors that occurred
ENDIF.

๐Ÿ’ก Tip: The MODE parameter controls the display: A shows all screens, E stops only on an error, and N runs silently. Use E during testing and N for the production load.

Batch Input Recorder

Batch input recorder (System > Services > Batch input > Recorder) records transactions which are manually entered and creates a batch input session which can be executed later using SM35.

Batch Input Recorder

  • Begin the batch input recorder by selecting the Recording pushbutton from the batch input initial screen.
  • The recording name is a user defined name and can match the batch input session name which can be created from the recording.
  • Enter a SAP transaction and begin posting the transaction.
  • After you have completed posting a SAP transaction you either choose Get Transaction and Save to end the recording or Next Transaction and post another transaction.
  • Once you have saved the recording you can create a batch input session from the recording and/or generate a batch input program from the recording.
  • The batch input session you created can now be analyzed just like any other batch input session.
  • The program which is generated by the function of the batch input recorder is a powerful tool for the data interface programmer. It provides a solid base which can then be altered according to customer requirements.

โš ๏ธ Warning: A recording captures the screen sequence exactly as it happened, so a screen that only appears for certain data, such as an incompletion popup, is not recorded. Always test the generated program with data that triggers every optional screen.

FAQs

BDC_OKCODE carries the function code that a user would trigger with a button or a key, such as /00 for Enter or =SAVE for Save. It tells the screen which action to perform after the fields are filled.

SM35 is the batch input monitor. It lists the sessions created by classical batch input, runs them in the foreground or background, and shows the process log so that failed transactions can be analysed and reprocessed.

BDC is still used where no BAPI exists, because it reuses the screen validations of a transaction. LSMW wraps BDC, recordings, and BAPIs in one migration tool, and a BAPI is preferred when a stable API is available.

Yes. AI assistants in ABAP development tools take a recording or a screen list and draft the BDCDATA population, the CALL TRANSACTION block, and the message handling. The developer maps the source file and tests the load.

AI tools profile the legacy file, flag missing mandatory fields and format mismatches before the load, and summarise the batch input log afterwards so the erroneous records can be corrected and reprocessed faster.

Summarize this post with: