Because in the last period there are a lot of questions about how to use this function, I created this document.

Fistly add the function in you program. You have to keep in mind that the function needs to be called in the PAI module. The function template is the one below:

CALL FUNCTION ‘DYNP_VALUES_READ’

  EXPORTING

    dyname                               =

    dynumb                               =

*   TRANSLATE_TO_UPPER                   = ‘ ‘

*   REQUEST                              = ‘ ‘

*   PERFORM_CONVERSION_EXITS             = ‘ ‘

*   PERFORM_INPUT_CONVERSION             = ‘ ‘

*   DETERMINE_LOOP_INDEX                 = ‘ ‘

*   START_SEARCH_IN_CURRENT_SCREEN       = ‘ ‘

*   START_SEARCH_IN_MAIN_SCREEN          = ‘ ‘

*   START_SEARCH_IN_STACKED_SCREEN       = ‘ ‘

*   START_SEARCH_ON_SCR_STACKPOS         = ‘ ‘

*   SEARCH_OWN_SUBSCREENS_FIRST          = ‘ ‘

*   SEARCHPATH_OF_SUBSCREEN_AREAS        = ‘ ‘

  TABLES

    dynpfields                           =

* EXCEPTIONS

*   INVALID_ABAPWORKAREA                 = 1

*   INVALID_DYNPROFIELD                  = 2

*   INVALID_DYNPRONAME                   = 3

*   INVALID_DYNPRONUMMER                 = 4

*   INVALID_REQUEST                      = 5

*   NO_FIELDDESCRIPTION                  = 6

*   INVALID_PARAMETER                    = 7

*   UNDEFIND_ERROR                       = 8

*   DOUBLE_CONVERSION                    = 9

*   STEPL_NOT_FOUND                      = 10

*   OTHERS                               = 11

          .

IF sy-subrc <> 0.

* Implement suitable error handling here

ENDIF.

For this function we need to declare the data for program name, screen number and the table where we want to catch the values.

DATA: gv_program_name TYPE D020S-PROG VALUE ‘PROGRAM_NAME’, “name of the program from where we trigger the function module

            gv_screen_no            TYPE D020S-DNUM VALUE ‘SCREEN_NUMBER’, “number of the screen from where we want to trigger values

            gs_dynpread     TYPE DYNPREAD,

            gt_dynpread            TYPE TABLE OF DYNPREAD.

Let’s take an example. We have a dynpro with 4 fields, a table control for a classroom. The students are maintained with number, first name, last name and date of birth. So we will have the table control with fields below:

no first_name last_name birth_date

We want to catch the data for all fields. One of the usual problems is that developers, do not pass the fieldname to the gt_dynpread table. Do not forget that for each row (excepting 1st row) you have to pass the gs_dynpread-stepl values also. Code below:

clear gs_dynpread.

gs_dynpread-fieldname = ‘NO’.

APPEND gs_dynpread TO gt_dynpread.

clear gs_dynpread.

gs_dynpread-fieldname = ‘FIRST_NAME’.

APPEND gs_dynpread TO gt_dynpread.

clear gs_dynpread.

gs_dynpread-fieldname = ‘LAST_NAME’.

APPEND gs_dynpread TO gt_dynpread.

clear gs_dynpread.

gs_dynpread-fieldname = ‘BIRTH_DATE’.

APPEND gs_dynpread TO gt_dynpread.


Now, we have the table filled, and we can use the function without problems. The whole code below:

DATA: gv_program_name TYPE D020S-PROG VALUE ‘PROGRAM_NAME’, “name of the program from where we trigger the function module

            gv_screen_no            TYPE D020S-DNUM VALUE ‘SCREEN_NUMBER’, “number of the screen from where we want to trigger values

            gs_dynpread     TYPE DYNPREAD,

            gt_dynpread            TYPE TABLE OF DYNPREAD.

clear gs_dynpread.

gs_dynpread-fieldname = ‘NO’.

APPEND gs_dynpread TO gt_dynpread.

clear gs_dynpread.

gs_dynpread-fieldname = ‘FIRST_NAME’.

APPEND gs_dynpread TO gt_dynpread.

clear gs_dynpread.

gs_dynpread-fieldname = ‘LAST_NAME’.

APPEND gs_dynpread TO gt_dynpread.

clear gs_dynpread.

gs_dynpread-fieldname = ‘BIRTH_DATE’.

APPEND gs_dynpread TO gt_dynpread.

CALL FUNCTION ‘DYNP_VALUES_READ’

  EXPORTING

    dyname                               = gv_program_name

    dynumb                               = gv_screen_no

*   TRANSLATE_TO_UPPER                   = ‘ ‘

*   REQUEST                              = ‘ ‘

*   PERFORM_CONVERSION_EXITS             = ‘ ‘

*   PERFORM_INPUT_CONVERSION             = ‘ ‘

*   DETERMINE_LOOP_INDEX                 = ‘ ‘

*   START_SEARCH_IN_CURRENT_SCREEN       = ‘ ‘

*   START_SEARCH_IN_MAIN_SCREEN          = ‘ ‘

*   START_SEARCH_IN_STACKED_SCREEN       = ‘ ‘

*   START_SEARCH_ON_SCR_STACKPOS         = ‘ ‘

*   SEARCH_OWN_SUBSCREENS_FIRST          = ‘ ‘

*   SEARCHPATH_OF_SUBSCREEN_AREAS        = ‘ ‘

  TABLES

    dynpfields                           = gt_dynpread

EXCEPTIONS

   INVALID_ABAPWORKAREA                 = 1

   INVALID_DYNPROFIELD                  = 2

   INVALID_DYNPRONAME                   = 3

   INVALID_DYNPRONUMMER                 = 4

   INVALID_REQUEST                      = 5

   NO_FIELDDESCRIPTION                  = 6

   INVALID_PARAMETER                    = 7

   UNDEFIND_ERROR                       = 8

   DOUBLE_CONVERSION                    = 9

   STEPL_NOT_FOUND                      = 10

   OTHERS                               = 11.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Comments are closed.