The diagram below shows how to declare the structure in your ABAP program and the fields contained in the structure


This BDCDATA structure can contain data for one transaction at a time.
You first create a BDCDATA structure.
Then fill the structures with data using either create session method or call transaction method. And then create it again for the next transaction.
If your BDC involves more than one transaction, then this process will be in a loop.
Build the structure line by line using MOVE and APPEND statements. Before building each line, reset the header line of the internal table with the CLEAR statement.
The first record for each screen must contain information that identifies the screen: program name, screen name and a start-of-screen indicator.
You record this information in the PROGRAM, DYNPRO, and DYNBEGIN fields of the BDCDATA structure.
This sample BDCDATA starts a screen.
The record specifies the program and screen identifiers.
With BDCDATA-DYNBEGIN, the record shows that batch input data for a new screen is starting:
BDCDATA-PROGRAM ='sapms38m'.
BDCDATA-DYNPRO ='0100'.
BDCDATA-DYNBEGIN ='x'.
APPEND BDCDATA.
After the dynpro-start record, you must add a record for each field that is to receive a value.
You need fill only the FNAM and FVAL fields.
This sample BDCDATA enters a value into a field.
The FNAM field identifies the target field by its table and field names. FVAL specifies the value that is to be entered:
BDCDATA-FNAM ='RS3SM-FUNC_EDIT'.
BDCDATA-FVAL ='x'. APPEND BDCDATA.
The command field is identified by a special name in batch input,
BDC OKCODE.
This name is constant and always identifies the command field.
This sample record would execute the save function.
It uses the function key assignment of save, which is Fl 1.
A function key number must be prefixed with the / (slash) character:
BDCDATA-FNAM = 'BDC OKCODE'.
BDCDATA-FVAL = '/11'.
This sample record also executes save, but uses the function code instead of the function key assignment.
All functions, whether they are displayed in menus or as buttons, are identified by function codes.
A function code must be prefixed with the = character.
BDCDATA-FNAM =`BDC_OKCODE'.
BDCDATA-F VAL ='=UPDA'.
Some screen fields need multiple values, one on each line.
To provide input to one of these loop fields, you must use an explicit line index BDCDATA-FNAM ='fieldx (5)'.
BDCDATA-FVAL ='value'.
The line index (in the example: (5), line 5) indicates in which loop line on the screen values are to appear.
To position the cursor on a particular field, you must use the special cursor field:
BDCDATA-FNAM ='BDC_CURSOR'.
BDCDATA-FVAL ='fieldx'.
To position the cursor on a loop field, you must use again an index: BDCDATA-FNAM ='BDC_CURSOR'.
BDCDATA-FVAL ='feldy(5)'.
After finishing the BDC, to return to the SAP Main Menu, from the text input screen in the ABAP editor,
for example,
the following BDCDATA records are necessary to leave the transaction:
BDCDATA-PROGRAM = `SAPMSEDT'. "Leave text input field BDCDATA-DYNPRO = `2310'.
BDCDATA-DYNBEGIN = `X'.
BDCDATA-FNAM = 'BDC OKCODE'.
BDCDATA-FVAL = `/3' "Back function key BDCDATA-PROGRAM = `SAPMS38M'. "Leave ABAP editor BDCDATA-DYNPRO = `0100'. .BDCDATA-DYNBEGIN = `X'.
BDCDATA-FNAM = `BDC OKCODE'. BDCDATA-FVAL = `/15'. "Quit function key