BDC Programming

SAP ABAP Interview QuestionsQuestion 10: How do you write a BDC program?

Question 11: What are BDC function modules?

Question 12: What is BDCDATA structure for?

Have you ever wondered that what BDC is? I’ve never thought what BDC stands for! I knew that it is related with batch inputs. Here it is what BDC stands for Batch Data Communication.

If you have generated a batch input program, the following function modules are automatically assigned the correct values.

If you want to write your own program, proceed as follows:

  1. Generate the batch input session using function module BDC_OPEN_GROUP
  2. The proceed as follows for each transaction that session contains:
    • In the BDCDATA structure, enter the value for all screens and fields that must be processed in the transaction.
    • Use BDC_INSERT to transfer the transaction and BDCDATA structure to the session.
  3. Close the batch input session with BDC_CLOSE_GROUP
  4. Start to process the generated session.

BDC_OPEN_GROUP

Use the BDC_OPEN_GROUP function module to create a new session. Once you have created a session, then you can insert batch input data into it with BDC_INSERT.

You cannot reopen a session that already exits and has been closed. If you call BDC_OPEN_GROUP with the name of an existing session, then an additional session with the same name is created.

A batch input program may have only one session open at a time. Before opening a session, make sure that any sessions that program closes any sessions that it previously had opened.

BDC_OPEN_GROUP

BDC_OPEN_GROUP takes the following EXPORTING parameters:

  • CLIENT
    Client in which the session is to be processed. Default: If you don’t provide a value for this parameter, the default is the client under which the bathc input program runs when the session is created.
  • GROUP
    Name of the session that is to be created. May up to 12 characters long. Default: None. You must specify a session name.
  • HOLDDATE
    Lock date. The session is locked and may not be processed until after the date that you specified. Only a system administrator with the LOCK authorization for the authorization object Batch Input Authorizations can unlock and run a session before this date.
  • KEEP
    Retain session after successful processing. Set this option to the value X to have a session kept after it has been successfully processed. A session that is kept remains in the input/output queue until an administrator deleletes it. Sessions that contain errors in transactions are kept even if KEEP is not set. Default: If not set, then sessions that are successfully processed are deleted. Only the batch input log is kept.
  • USER
    Authorizations user for background processing. This is the user name that is used for checking authorizations if a session is started in background processing. The user must be authorized for all of transactions and functions that are to be executed in a session. Otherwise, transactions will be terminated with “no authorization” errors. The user can be of type dialog or background. Dialog users are normal interactive users in the R/3 System. Background users are user master records that are specially defined for providing authorizations for background processing jobs.

BDC_INSERT

Use the BDC_INSERT function module to add a transaction to a batch input session. You specify the transaction that is to be started in the call to BDC_INSERT. You must provide a BDCDATA structure that contains all of the data required to process the transaction completely.

BDC_INSERT

BDC_INSERT takes the following parameters:

  • TCODE
    The code of the transaction that is to be run.
  • POST_LOCAL
    Parameter to update data locally. If POST_LOCAL = “X”, data will be updated locally.
  • DYNPROTAB
    The BDCDATA structure that contains the data that is to be processed by the transaction. DYNPROTAB is a table parameter in the function module.

BDC_CLOSE_GROUP

Use the BDC_CLOSE_GROUP function module to close a session after you have inserted all of your batch input data into it. Once a session is closed, it can be processed.

BDC_CLOSE_GROUP needs no parameters. It automatically closes the session that is currently open in your program. You must close a session before you can open another session from the same program.

BDCDATA Structure

IF you want to write data to a batch input session or to process the data using CALL TRANSACTION USING or CALL DIALOG, you must prepare an internal table <bdc_tab>. This internal table must be structured according to ABAP Dictionary structure BDCDATA. The internal table <bdc_tab> stores the data that is to be entered into R/3 System and the actions that are necessary to process data. You can think of the table as storing the script that the R/3 System is to follow in processing batch input data.

BDCDATA Structure

References:

Tags: , ,

12 Responses to “BDC Programming”

  1. simokhan Says:

    hello,
    I want to know if I can get a structure field value when I’m executing a batch input . I know that I can modify fields value but to get it and insert it in an other variable that’s my question.

  2. Parikshita Pradhan Says:

    Really it is good for a BDC Biginner.pls put this type of article that will help a lot .
    parikshita ,Bangalore

  3. Tuncay Karaca Says:

    Parikshita,

    Thank you for kindly comment. I will hopefully continue to write articles.

  4. Tuncay Karaca Says:

    Simokhan,

    Sorry! I don’t understand your question! Could you elaborate the question?

  5. newops Says:

    Hi Tuncay,

    Would you be able to explain in laymans term what exactly BDC sessions/BDC processing does? How the data in supplied and How it works in the processing of data….

    Thanks in advance.

  6. Deepak Says:

    Hi Tuncay,

    Your articles are very well written, I have been reading you entire blog since past 2 days. Keep up the good work.

  7. Tuncay Karaca Says:

    Deepak,

    Thank you for your nice compliment.

  8. Gaurav Says:

    Hi Tuncay,
    The blog is quite good. I liked your BDC posts very much , in particular.

  9. Tuncay Karaca Says:

    Gaurav,

    Thank you so much for your kindly comment. Hopefully you will find more articles soon.

  10. shinu Says:

    hi
    the material was quite useful.
    thanks

  11. selcuk ozger Says:

    hi Tuncay,
    I wrote program with this functions then this program created a session . But how I can process this session in program with code?

  12. RAVI JAIN Says:

    hi friends,

    I am a mechnaical engineer doing job some where had programming knowledge in c, C++ and ABAP is the certification necessary for making entry into SAP profession, how certification can assit me in career growth

Leave a Reply