Register Login

BDC (Batch data communication): Data Transfer

Updated May 18, 2018

Introduction to Batch Data Communication (BDC)

The early SAP versions of R/3, SAP has been providing batch interfacing techniques. Among these techniques, Batch Data Communication (BDC) is not bi-directional; it is an integration tool in its typical form. It can only be used for uploading data into R/3. BDC works through an ABAP program and works on the principle of simulating user input for transactional screen.

Batch data communication (BDC) is an instruction set that SAP can follow to execute a transaction without user intervention. The instructions dictate the sequence in which a transaction's screens are processed and which fields should be populated with data on which screens. All of the elements of an SAP transaction that are exposed to an online user have identifications that can be used in a BDC.

The purpose of the Batch Data Communication is to transfer data. The BDC can transfer data from one SAP System to another SAP System or can transfer data from non-SAP System to SAP System too. To transfer data BDC uses normal transaction codes. Two methods are provided to BDC to do this work.
SAP has provided two different types of methods for BDC to do its work. Among these, the first one is called the classical method or session method. Through this method the data can be read by the BDC program from a sequential dataset file. This sequential dataset file is stored in batch-input session. In order to .run the transaction in this session, what one needs is to execute the session. For this, follow these few steps: you can start and subsequently monitor the session firstly from – System - Service - Batch Input or have the session run in the background. In this method to generate the required session, you have to use the function module BDC_OPEN GROUP, BDC _INSERT and BDC _CLOSE.

In the second method the BDC has to use the ABAP statement CALL TRANSACTION USING statement to run a transaction. In the second method, unlike in the first type, you do not need BDC to create a session.

Related: Difference Between BAPI and BDC

Data Transfer

During the process of data transfer, data is transferred into the SAP R/3 System. This transfer is from an external system to SAP R/3 system. Whenever you transfer data from an external system into an R/3 System, you can use data transfer because it is installed and regularly transfers data from an external system into an R/3 System.
With the help of BDC, you can transfer the required data from a non-SAP system to an SAP system. For this kind of data transfer you are required to write an ABAP program. This ABAP program would help to export the concerned data to a sequential dataset file. The data in this file has to be stored. This should be stored in a format, which is acceptable to SAP batch input program. But, to transfer data from a SAP system to another SAP system, you can take the aid of RFC or CPI-C.
SAP application supports the data transfer of numerous SAP business objects. The said data transfer program specifies the data format definition, which is necessary to import the data into the R/3 System. There are three methods available for transferring data:

Direct Input: In this method the SAP function modules execute the consistency checks. However, there are other means of checking with the help of screens. The Direct Input Method has considerable performance advantages.

Call Transaction: In this method you can check the data consistency with the help of screen logic.

Batch Input Session: In this method data consistency is checked with the help of screen logic.

Direct Input Method

Among the methods of data transfer through BDC, direct input method is the one that is used, especially in case of transferring large amount of data. In order to enhance the batch input procedure, the system offers you with the direct input technique.

There is a distinction between the batch input technique and this technique. Unlike batch input technique, this technique does not create sessions. Instead, it stores the data directly. Moreover, it does not process screens. The data has to be entered directly into the corresponding database tables. The system calls a number of function modules which execute necessary checks, if any required. In the case of errors, the direct input technique has a facility to restart the entire mechanism. However, if you want to restart the entire mechanism in case you faced an error, then direct input programs must be executed in the background only. One has to use program RBMVSHOW or Transaction BMV0 to maintain and start these programs.

Call Transaction Method

Call Transaction method is another method used for Data Transfer. In this type of method your program will use the ABAP statement CALL TRANSACTION USING in order to run a SAP transaction. In this type external data need not be deposited in a session for being processed later on. Instead, the entire batch input process takes place inline in your program.

Here, the data transfer program must convert the data that has to be transferred into the SAP system. This is as per requirement by the SAP data structure or the transaction which is using it. It is to be remembered that a conversion of the data types may be necessary at different times during the process.

Suppose there is a data type mismatch then you have to convert the data types to type C. In this regard the data transfer program should be capable of exporting the data in SAP format to the sequential file. At the time of uploading the data into the SAP system, the BDC program reads the data from the above mentioned sequential file.

Batch Input Session Method

This is the third method for data transfer. If you use the batch input method to transfer data, then you should remember that an ABAP program has to read the external data which is to be entered in the R/3 System. Subsequently, it stores the concerned data a "batch input session." The batch Input session records the actions which are required in the process of transferring data into the system. This can be done by using normal SAP transactions.

As soon as the program generates the said session, you will be able to run the session in order to execute the SAP transactions in it. Moreover, you can start the session, and at the same time, can monitor a session with the help of batch input management function. For this you have to choose:

System - Services - Batch input. Moreover, you can have the session run in the background processing.

Writing a Data Transfer Program

If you want to write a data transfer program, you have to follow the steps mentioned below. Firstly, you will analyze the structure of the existing data. Subsequently, your job is to specify the conversions, which are essential to fill the SAP data structures. Secondly, you have to generate the SAP data structure. In case the program is written in ABAP, you will require only the required tables in the concerned program with the help of TABLES statement. Thirdly, you will have to initialize the SAP data structure.

Fourthly, fill the structure with data, performing any conversions and error checking that are required. Finally, you will write the sequential file. In the SAP system this sequential file is typically required for making the data available to the batch input program.

Batch Input Method

Batch input method is a type of data transfer method. It is used for bulk data transfer; it is one of the primary ways by which data can transferred into the R/3 System. This method is not for near real-time data transfers.
There are various typical uses of batch input. One of the ways includes the one-time import of data. This import of data is from a legacy system into a newly installed R/3 System. In addition to it, another typical use is for periodic (i.e. hourly, daily..., and so on) transfers of data. These transfers are from external systems or legacy systems which are still in use into R/3 system where all enterprise data is consolidated.

The R/3 applications deliver different programs for batch input, which are ready to be used. However, in some cases a customer has to write his or her own batch input program. This is required in order to convert the concerned data from a legacy System or from a proprietary format into an R/3 data format.

The process flows for a batch input are discussed below.

Data Transfer Decision-Making: It is with a decision to transfer data from an external source into R/3 that the process of batch input begins. It is probable that the external source may be a legacy system that is being replaced. A one-time bulk data transfer is foreseen in this regard. Alternatively, the external source may be an external system that is to remain in use. In this case, a regularly recurring bulk data transfer is foreseen.

Setting up Batch-Input for Data Transfers: If R/3 standard one-time or regular data transfers are required, then by means of customizing settings in the R/3 Customizing System in SAP ASAP set up will occur. You must set up custom batch input procedures by hand, which means the system administrator must schedule the data conversion program that creates the batch input session. The system administrator and the batch input programmer must determine the following: how frequently data is made available from the external system, how frequently the conversion program should run, and whether the conversion program runs in R/3 (ABAP program) or in a host system (external program).

Processing Batch Input Sessions: When a batch input session is processed, then the actual transfer of data into R/3 takes place. Little attention is required in processing of batch input sessions by the system administrator. Usually, the starting of batch input sessions is automated by the system administrator. If necessary, the administrators can also start batch input session explicitly from transaction SM35.

Checking Batch Input Sessions: For a system administrator the routine activity is to check daily or more frequently in transaction SM35 whether all batch input sessions have been completed successfully. It is the schedule for running batch input sessions on which the schedule for checking sessions depends upon. For doing this check the R/3 System provides easy-to-use batch input management tools.

Analyzing Errors: It is the duty of the system administrator to analyze the problem if one or more transactions in a session end in errors. Usually, the assistance of the affected data entry specialist or department for this analysis will be needed by the system administrator. In the situation where the problem was caused by incorrect data conversion or incorrect generation of the batch input session then the programmer who wrote the data conversion program may also need to be involved.

Error Handling in Batch Input Method

It is found that most problems usually fall into one of the following two categories discussed below.
In this case either required data is missing from the batch-input session or invalid data has been included in the session. Errors in the data conversion program or the presence of unexpected types of data or incorrect data in the legacy database are the possible external causes of this type of problem. Within R/3, the causes for this type of problem include incorrect or incomplete customizing in an application. For example, a legacy data type may not have been foreseen in the check table entries made in application customizing.
This case mainly includes technical/programming problems. The data is entered by a batch input session by running R/3 transactions non-interactively. Therefore, a typical technical or programming problem is the incorrect identification of one of the data fields in a transaction. Thus, the conversion program may not fill a required data field or may have provided invalid values.

A SAMPLE PROGRAM TO RUN BDC

This sample program is for abap developer only who has the knowledge of se51(dialog programming) abd how to built transparent table(ddic table)

(a) Go to se11 design a transparent table to match the consistiency with the dialog program you made , like data type and length, this table is made to store information of various employees.

Dictionary Maitain Table

(b) Design a dialog screen in which there is the information about employee, employee id, employee name, employee address, employee city any thing you like.

Go to se51 design the screen and abap report and layout ,give a transaction name to the dialog screen you have just made.

PROGRAM z_________
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*

TABLES z_______.
data ok_code(4) type c.
data wa like zxyz.
*DATA WA LIKE LINE OF Z_your table name WITH HEADER LINE.
data:

EMP_ID(012) type c,
EMP_NAME(012) type c,
EMP_ADDRESS(012) type c,
EMP_CITY(012) type c.
*----------------------------------------------------------------------*
* MODULE STATUS_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'CURRENT WINDOW'.
SET PF-STATUS 'XYZ'.
* SET TITLEBAR 'dialog programing'.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.

case ok_code.
when 'SAVE'.
wa-emp_id = emp_id.
wa-emp_name = emp_name.
wa-emp_address = emp_address.
wa-emp_city = emp_city.
insert into z_______ values wa.

When 'B1' . “back button

SET screen 0.
leave SCREEN .

when 'RSET'. To reset the field
clear z____-emp_id. Z_____ your table name
ddic table
clear z_______-emp_name.
clear z_______-emp_address.
clear z_______-emp_city.

endcase.

(c) Now write a bdc input program:
(i) go transcation shdb and enter the name of your transaction you design before.
(ii) click new recording and give a name for the recording click ok.
You will see your screen which you design before, now input the value you want to store in the data base, have patience while inputting your cursor movent is recording after inputting the field values click the push button(save ), then press F3 or back button .

BDC Input Program

click back button below window will be visible click save and then press back button.

Transaction Recorder

press back button and u will see the screen shown below select the recording and click program and enter the program name ,executable program, correct format like tab separated .
sample file:

Transaction Recorder Recording Overview

BDC input program is shown do not change the program, press f8 or execute, enter the session name and enter the name of the file present at the application server make sure the the file is made in correct format like tab separated.

Sample Doc

Batch input report program

report Z______ no standard page heading line-size 255. include bdcrecx1.

parameters: dataset(132) lower case.
*** DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
*
* If it is nessesary to change the data section use the rules:
* 1.) Each definition of a field exists of two lines
* 2.) The first line shows exactly the comment
* '* data element: ' followed with the data element
* which describes the field.
* If you don't have a data element use the
* comment without a data element name
* 3.) The second line shows the fieldname of the
* structure, the fieldname must consist of
* a fieldname and optional the character '_' and
* three numbers and the field length in brackets
* 4.) Each field must be type C.
*
*** Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record,
* data element: EMP_ID_001(012),
* data element: EMP_NAME_002(012),
* data element: EMP_ADDRESS_003(012),
* data element: EMP_CITY_004(012),
* data element: EMP_ID_005(012),
* data element: EMP_NAME_006(012),
* data element: EMP_ADDRESS_007(012),
* data element: EMP_CITY_008(012),

end of record.

*** End generated data section ***

start-of-selection.

perform open_dataset using dataset.
perform open_group.
do.
read dataset dataset into record.
if sy-subrc <> 0. exit. endif.

perform bdc_dynpro using 'Z____' '0100'.
perform bdc_field using 'BDC_CURSOR''EMP_CITY'.
perform bdc_field using 'BDC_OKCODE''=SAVE'.
perform bdc_field using 'EMP_ID' record-EMP_ID_001.
perform bdc_field using 'EMP_NAME' record-EMP_NAME_002.
perform bdc_field using 'EMP_ADDRESS' record-EMP_ADDRESS_003.
perform bdc_field using 'EMP_CITY' record-EMP_CITY_004.
perform bdc_dynpro using 'Z______' '0100'.
perform bdc_field using 'BDC_CURSOR''EMP_ID'.
perform bdc_field using 'BDC_OKCODE' '=B1'.
perform bdc_field using 'EMP_ID' record-EMP_ID_005.
perform bdc_field using 'EMP_NAME' record-EMP_NAME_006.
perform bdc_field using 'EMP_ADDRESS'record-EMP_ADDRESS_007.
perform bdc_field using 'EMP_CITY' record-EMP_CITY_008.
perform bdc_transaction using 'ZRA20'.

enddo.

perform close_group.
perform close_dataset using dataset.

Press f8,shown new screen below

ty

Either go for session method or call transaction method

If genetate session is choose then press f8 message will come , if successful then go to SM35 process the session by choosing it using either background mode or forground mode.
If call transaction is used then records r tranfered ,no need of going to sm35 data has been tranfered the moment you click F8.
Explore the information on bdcdata a internal table use by sap internally Structure of data internal table bdcdata.

Structure of Interna lTable

and two sub routines BDC_FIELD and BDC_DYNPRO how to fill BDCDATA internal table using two subroutines mention above and how to concatenate the fields in BDC_FIELD and BDC_DYNPRO

Conclusion

One can make use of BDC to transfer data from a SAP to SAP system. In addition, it can transfer data from a non SAP system to SAP system too. I have discussed the various methods of BDC and the error handling in the respective methods.

Read here for More SAP ABAP Tutorials


 Download attached file.

You must be Logged in to download this file

×