If you want to write data to a batch input session or to process the data using CALL TRANSACTION USINGor 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 SAP System and the actions that are necessary to process the data. You can think of the table as storing the script that the SAP system is to follow in processing batch input data.
The graphic below shows how to declare the internal table <bdc_tab> in your ABAP program and the fields contained in the structure BDCDATA.
...
1. Declare internal table <bdc_tab>.
2. Initialize the internal table before you call each new transaction.
3.
At
the beginning of each new screen, you must maintain the module pool name
<program>, the screen number <dynpro> and a flag:
<bdc_tab>-PROGRAM =
<program>.
<bdc_tab>-DYNPRO = <dynpro>.
<bdc_tab>-DYNBEGIN = 'X'.
APPEND <bdc_tab>.
4.
For each field to which you want to assign values,
insert an entry in the internal table. Specify the technical field name
<fnam> and the field content <fval>:
<bdc_tab>-FNAM =
<fnam>.
<bdc_tab>-FVAL = <fval>.
APPEND <bdc_tab>.
If the field is in a step
loop or a table control, you must also specify the lines in which the input is
to be entered. The field name extension displays the line number:
<bdc_tab>-FNAM =
'fieldx(5)'.
5.
If
you want to position the cursor on a particular field, enter the cursor
position by filling field FNAM with the value BDC_CURSOR, and transferring into the field FVAL the technical name <tname> of the field where the cursor should be:
<bdc_tab>-FNAM =
'BDC_CURSOR'.
<bdc_tab>-FVAL = <tname>.
APPEND <bdc_tab>.
If you want to position
the cursor on a field in a step loop or table control, you must also specify
the lines in which the input is to be entered. The field name extension
displays the line number:
<bdc_tab>-FVAL =
'fieldx(5)'.
6.
Now specify which action is to be executed in this
screen. You must determine the triggered function code <fcode> and assign this with the field FVAL. Note that the character '/' should always be placed before the function
key number. The character '=' must be placed before all other function
codes.
Assign value BDC_OKCODE to the field FNAM:
<bdc_tab>-FNAM =
‘BDC_OKCODE’.
<bdc_tab>-FVAL = <fcode>.
APPEND <bdc_tab>.
7. Execute steps 3 to 6 for each additional screen in the transaction.
8.
After the last screen in the transaction, internal
table <bdc_tab> is filled with all of the values required.
You can now use this table to create an entry in a batch input session or to
call the commands CALL
TRANSACTION or
CALL
DIALOG.
The transaction to which a BDCDATA structure refers is identified separately.
If your program writes data to a batch input session, then the transaction is
specified in the call to the BDC_INSERT function module. This function module
writes a BDCDATA structure out to the session. If your program processes data
with CALL TRANSACTION USING, then the transaction is specified directly in
this statement.
The following table shows what the contents of a BDCDATA structure might look like. This BDCDATA structure would add a line to a report in Transaction SE38, the ABAP Editor:
BDCDATA Structure for Adding a Line to a Report (Transaction SE38)
PROGRAM |
DYNPRO |
DYNBEGIN |
FNAM |
FVAL |
SAPMS38M |
0100 |
X |
|
|
|
|
|
RS38M-PROGRAMM |
<Name> |
|
|
|
RS38M-FUNC_EDIT |
X |
|
|
|
BDC_OKCODE |
=CHAP (Change function code) |
SAPMSEDT |
2310 |
X |
|
|
|
|
|
RSTXP-TDLINECOM(1) |
B- |
SAPMSEDT |
2310 |
X |
|
|
|
|
|
BDC_CURSOR |
RSTXP-TDLINECOM(1) |
|
|
|
RSTXP-TDLINE(1) |
BDC Test Text |
|
|
|
BDC_OKCODE |
/11 (Save function key) |
SAPMSEDT |
2310 |
X |
|
|
|
|
|
BDC_OKCODE |
/3 (Back function key) |
SAPMS38M |
0100 |
X |
|
|
|
|
|
BDC_OKCODE |
/15 (Quit function key) |