ERPClimb logoERPClimb

Code examples · Modern ABAP · Intermediate

Classic BDC: fill a transaction with CALL TRANSACTION USING and list the messages

The problem

A small data load has to enter values into an SAP transaction that has no BAPI.

How we solve it

  1. 1Build BDCDATAscreens and fields
  2. 2RunCALL TRANSACTION
  3. 3Read messagesBDCMSGCOLL

The result

One line per message that the transaction produced.

Overview drawn by ERPClimb from this example. The steps are the same as in the code below.

1. The requirement

A small data load has to enter values into an SAP transaction that has no BAPI. The program must run the transaction in the background, report success or failure for each record, and not stop at the first error.

2. How we design it

Batch input replays what a user would type. The table BDCDATA holds the steps: one line per screen (program name, screen number, DYNBEGIN = X) and one line per field (field name and value). The function code BDC_OKCODE presses a button. CALL TRANSACTION USING runs it, MODE N hides the screens, UPDATE S waits for the database update, and MESSAGES INTO collects every message in a table of type BDCMSGCOLL.

Why we decided it this way

  1. 1Two small helper routinesOne adds a screen line, one adds a field line. The recorded steps stay short and readable.
  2. 2UPDATE 'S' (synchronous)The program knows whether the update really worked before it moves to the next record.
  3. 3Read the message table, not only sy-subrcsy-subrc tells you that something went wrong. The message table tells you what.

Before you start

  • Transaction SHDB to record a real transaction and see the program names, screen numbers and field names.
  • Authorisation for the transaction that you call. Batch input does not bypass authority checks.

3. The code, step by step

Step 1 of 3: Build the BDCDATA table

The steps of the transaction as table rows.

ABAP · Report · ZR_BDC_CALL (part 1)
" One routine for a screen, one for a field
REPORT zr_bdc_call.

DATA: gt_bdc TYPE STANDARD TABLE OF bdcdata,
      gt_msg TYPE STANDARD TABLE OF bdcmsgcoll.

FORM bdc_screen USING iv_program TYPE bdcdata-program
                      iv_dynpro  TYPE bdcdata-dynpro.
  APPEND VALUE #( program = iv_program dynpro = iv_dynpro dynbegin = 'X' ) TO gt_bdc.
ENDFORM.

FORM bdc_field USING iv_fnam TYPE bdcdata-fnam
                     iv_fval TYPE any.
  APPEND VALUE #( fnam = iv_fnam fval = iv_fval ) TO gt_bdc.
ENDFORM.
" The recorded steps
START-OF-SELECTION.
  PERFORM bdc_screen USING 'SAPMTFCA' '0100'.
  PERFORM bdc_field  USING 'SFLIGHT-CARRID' 'XX'.
  PERFORM bdc_field  USING 'SFLIGHT-CONNID' '0400'.
  PERFORM bdc_field  USING 'BDC_OKCODE' '/00'.
Part by part (plain text)
  1. One routine for a screen, one for a field. bdc_screen adds the line that starts a screen: program, screen number and DYNBEGIN = X. bdc_field adds a field name and its value. Both write into the global table gt_bdc.
  2. The recorded steps. These lines are what SHDB shows for the first screen of TFCA: the program SAPMTFCA, screen 0100, and values for two fields. BDC_OKCODE with /00 acts like pressing Enter. The values are examples.

Open in the portal

The SAP objects named in this code are linked in the code above and listed here. Each opens its page in the SAP Library.

4. The final outcome

One line per message that the transaction produced.

What you should see

S 00 344 Entry saved (or) E 00 058 Flight XX 0400 does not exist

Try it and check the result

  • Change MODE 'N' to MODE 'A' and run: you see every screen and where the values land.
  • Replace the connection number with a wrong value: the message list shows an error line.
  • Record your own transaction in SHDB, use the recording's generated code as a starting point and compare it with these helper routines.

Common mistakes

  • Recordings break when the screen changes: another release, a different user setting, or a table control with a different number of lines. Re-record after upgrades.
  • Use BAPIs, IDocs or released APIs instead of BDC where they exist. BDC is a last resort because it depends on screens.
  • Run it in a loop, one CALL TRANSACTION per record, and clear the BDC and message tables between records so one error does not mix into the next.
  • Always give the user running the job the authorisations of the transaction. Batch input does not skip authority checks.

Keep learning

Checking status: Reviewed line by line against SAP documentation. Not executed on a live system. Reviewed 2026-11-26. Release: Any ABAP system. The recording uses the demo transaction TFCA (program SAPMTFCA, screen 0100) taken from SAP's own documentation. For your own transaction record the screens in SHDB and copy the values.

Original ERPClimb teaching code with illustrative names. Not taken from a customer system. Syntax can differ by release; check the references below and activate in a sandbox first. ERPClimb is independent of SAP SE.