Table of Contents
In SAP environment, suppose you need to upload a data from an external source like an excel sheet. You have a program for the upload already in the system. You will therefore, visit the program or transaction, and then simply open the file location, upload the file, check for errors and that’s it.
Therefore, these will be the steps that you will follow for a file upload. Suppose, you have Ten Thousand files to be uploaded via the same program. Wouldn’t it be a tedious job? SAP knew it, and hence created something called SAP BDC, which records your upload steps and automatically replicate it for next sets or batches of data. In this article, we will learn everything about SAP BDC with simple examples.
What is BDC – Batch Data Communication in SAP ABAP?
SAP BDC stands for Batch Data Communication. It was renamed by SAP to Batch Input, about 20 years ago. Still, the famous name i.e. BDC is used to refer it.
In terms of definition, Batch Input or BDC are the sets of methods provided by SAP to transfer/migrate data from other SAP or Non SAP Systems.
Why we need BDC?
We need Batch Input of BDC for the following reasons:
1. Data conversion or migration from Non SAP systems (e.g. csv, excel, text) to SAP Systems (e.g. SAP Table). It mostly happen for a new development (Master Data Migration) and SAP Upgradation.
2. Automate daily tasks of a user. If the daily task of user is to upload data from a 3rd party to SAP System via T-Code.
SAP BDC Design
If you are asked to upload a set of data into database, in single table, you would quickly create a report, with file uploader, and use SQL to push that data into required table. But, if you are asked to upload hundred columns of data into tons of tables, based upon various conditions, based upon a T-Code, then it will be a tedious job.
BDC solves our problem, by cutting our second task. Our part is to just push the excel until the transaction screen, and the rest is taken care.
In below image, the usual case would be that you will open a t-code, enter required input and click save. In case of BDC, it creates recording of your upload process and give you the code of the recording. Using the provided code, you can create a program to upload excel and pass the data to that BDC recoded code, and the rest is taken care automatically.
SAP BDC Technical Details
Every time you record your screen, a few fields are auto generated (called BDCDATA) as below:
- Program Name (PROGRAM): The name of program for the transaction
- Screen Number (DYNPRO): The screen number is auto generated
- Field Name (s) [FNAM]: The field name for which value was provided. In case of multiple field, it will be repeated
- Field Value (s) [FVAL]: For all the above fields, the entered value is recorded here
- OK Code [BDC_OKCODE]: The event that occurred during recording. Either you pressed Enter or Clicked a button, the code for the same will be captured here
- DYNBEGIN: This indicates that the new screen has started
- BDC_CURSOR: It saves the current position of the cursor
A common example based upon above structure is shown below:
You do not have to understand the above code, just check the field names discussed before and how they appear in the BDCDATA generated. You can even check the structure “BDCDATA” in SE11. Also, you can check another SE11 structure BDCMSGCOLL which is used for Collecting messages in the SAP System.
Note: The recording by SHDB that we will discuss later is a client dependent process, and it has to be saved as a local file in desktop and has to be uploaded the same in to other systems.
SAP BDC Transaction Codes (Tcode)
The following T-Codes are used with respect to BDC or Batch Input:
|SM35||It is used to run Batch Input Sessions|
|SHDB||It is used to record a BDC (Batch Input) Session|
|BDCUPDATE||It is used to check updates in Batch Input|
Apart from these, you can find all other relevant T-Codes here.
Methods of Batch Input or Types of BDC Call
Now, we have a basic idea of BDC and its terminologies. Now, we will learn how to start with a BDC process. There are two different ways of doing the same. These are:
1. Call Transaction Method
2. Classical Batch Input Method or BDC Session Method
We have discussed each individually in a different article (click them) and created respective programs.
Error handling in SAP BDC
There are many reasons due to which your BDC might fail; we will discuss a few issues and errors that are very generic to BDC.
Important Guidelines for SAP BDC
Following are the important guidelines in terms of SAP BDC:
- BDC works by executing t-codes using data uploaded, hence all the data and logic validations are not done in BDC programs but are done in individual t-codes (the reports running behind those t-codes).
- BDC is suitable for very large amount of data.
- BDC should be tested in mode A and E, and should be deployed in production in mode N.
- For different screens you must update the DYNPRO number, else the program will fail.
- Every time you press enter or click, it is recorded in the BDCDATA. You should write code for every event in your BDC Program.
Why BDC is not recommended
BSC is closely associated with screens and t-codes. Every new release of a product in SAP, there might be chance of enhancing the screen; hence making the old BDC becomes non-applicable. Hence, BDC is not recommended for longer run.
Alternative to SAP BDC
The alternative to SAP BDC is SAP BAPI. There are several BAPIs that can replace the data transfer of a particular transaction. Even SAP recommends using BDC only in case there are no BAPIs for a t-code.