BDC 6

Posted by Krishh Webworld | 6:08 PM | | 0 comments »

(13) PROGRAMMING TECHNIQUES :

ENTERING DATA AND EXECUTING

FUNCTIONS:

a)Sample Code: Filling the BDCDATA Structure
b)Identifying a Screen
c)Entering a Value in a Field
d)Executing a Function
e)Entering Values in Loop Fields
f)Positioning the Cursor
g)Ending a Transaction

a)Sample Code: Filling the BDCDATA Structure:

The following form routine shows how the BDCDATA structure should be filled. 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.

Special techniques, such as placing the cursor, are not shown in this example.

Example:

Assume in this example that the BDCDATA structure has been declared as BDCDAT in the ABAP/4 program:

FORM Fill-BDC-Table
REFRESH BDCDAT

" Start new DYNPRO
CLEAR BDCDAT
MOVE: TO BDCDAT-PROGRAM.
TO BDCDAT-DYNPRO.
'X' TO BDCDAT-DYNBEGIN.
APPEND BDCDAT.

" Enter fields and values for DYNPRO
CLEAR BDCDAT.
MOVE: TO BDCDAT-FNAM.
TO BDCDAT-FVAL.
APPEND BDCDAT.
CLEAR BDCDAT.
MOVE: TO BDCDAT-FNAM.
TO BDCDAT-FVAL.
APPEND BDCDAT.
...
...
" Start next DYNPRO
CLEAR BDCDAT.
MOVE: TO BDCDAT-PROGRAM.
TO BDCDAT-DYNPRO.
'X' TO BDCDAT-DYNBEGIN.
APPEND BDCDAT.
ENDFORM.


b) Identifying a Screen:

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:

Example:

BDCDATA-PROGRAM = 'sapms38m'.
BDCDATA-DYNPRO = '0100'.
BDCDATA-DYNBEGIN = 'x'.
APPEND BDCDATA.





c) Entering a Value in a Field:

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:

Example:

BDCDATA-FNAM = 'RS38M-FUNC_EDIT'.
BDCDATA-FVAL = 'x'.
APPEND BDCDATA.



d)Executing a Function:

You can execute a function in a transaction by entering the function code or function key number in the command field of an SAP session. You use the FNAM and FVAL fields to enter this information, just as you would for normal screen fields.

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 F11. A function key number must be prefixed with the / (slash) character:

Example:

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.

Example:

BDCDATA-FNAM = 'BDC_OKCODE'.
BDCDATA-FVAL = '=UPDA'.




e)Entering Values in Loop Fields

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 :

Example:

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.



f)Positioning the Cursor:

To position the cursor on a particular field, you must use the special cursor field:

Example:

BDCDATA-FNAM = 'BDC_CURSOR'.
BDCDATA-FVAL = 'fieldx'.

To position the cursor on a loop field, you must use again an index:

Example:

BDCDATA-FNAM = 'BDC_CURSOR'.
BDCDATA-FVAL = 'fieldy(5)'.




g)Ending a Transaction:

You can successfully complete processing of a transaction in batch input in either of two ways:

leave the transaction and return to the SAP main menu.
trigger an update of the database.


Ending a Transaction

Example:

Returning to the SAP main menu: From the text input screen in the ABAP/4 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/4 editor
BDCDATA-DYNPRO = '0100'.
BDCDATA-DYNBEGIN = 'X'.

BDCDATA-FNAM = 'BDC_OKCODE'.
BDCDATA-FVAL = '/15'. "Quit function key

0 comments

Archives

Subscribe Now: Feed Icon