BDC PROGRAM STRUCTURE
There are 5 parts in a BDC program .Each part is executed one after another.
1) Selection screen is used with a parameter to input the text file of TYPE RLGRAP-FILENAME
. Various function modules like KD_GET_FILENAME_ON_F4 can be used to read the file name
at runtime or the filename can be defaulted by using DEAULT clause in the parameter statement.
2) Open the text file for input.If file fails to open (SY-SUBRC NE 0) then
stop the program with a error message.
OPEN DATASET filename FOR INPUT IN TEXT
MODE is used to open the file.
3)Loop through the dataset using a loop statement like DO .. ENDDO with an
EXIT statemenyt if no next record exists.
and filling the work structure which will hold the data for a single transaction
in each loop pass.
Filling the BDC TABLE of TYPE BDCDATA in the loop for every
record(equivalent to transaction) in the data set.
Submit the internal table containing bdc data for each
and every transaction (internal table of TYPE BDCDATA is submitted for each transaction until all the records in the dataset
are read) using
CALL TRANSACTION 'tr' USING I_bdcdata MODE 'N' UDATE 'S' .
READ DATASET file INTO W_bdcdata
IF SY-SUBRC NE 0.
4) Error handling when submission via CALL TRANSACTION fails ,either by using the internal table to
be filled by the system messages which is of TYPE BDCMSGCOLS and can be specified in CALL TRANSACTION
statement with the addition MESSAGES INTO .
Or error handling by sending the mail to a
Or for each and every transaction that fails create a
single BDC SESSION by using BDC_OPEN_GROUP function module
and submitting the intenal bdc data table to it.
and every error a report should display them
all at the end of the program so that the transacton in error can be identified.
The approach of opening a BDC SESSION is often used with an error report when an error occurs
as all the transaction in error can be seen and executed in the session manager .
5)Clean up actions.
Here clean up actions are performed like closing the dataset with CLOSE
DATASET command ,closing any error
session if they were created using CLOSE_GROUP function module.and displaying the report
To fill the bdc data table we should have all the information associated with the screens used in the
and all the fields in those screens that will be filled by the CALL TRANSACTION statement.We can use BDC SESSION
RECORDER or Transaction Recorder(Transaction SHDB) to get the information on the screens and the fields. The
which is required to fill the internal table of TYPE BDCDATA is
Information on Field Name and Field Type can be used to create the structure that will be used to read records from the
data set .
While filling the Field value in BDCDATA table care should be taken for special fields like 'BDC_CURSOR',' BDC_OKCODE'
Structure of BDCDATA table
Name of program
DYNPRO Number of screen
DYNBEGIN If New screen begins value
FNAM Field Name
Structure of BDCMSGCOLL
MSGV1 1st placeholder
2nd Place Holder
NSGV3 3rd Placce Holder
4th Place Holder
To see all the messages stored by the system in the BDCMSGCOLS table we can use LOOP
AT .ENDLOOP command.