How to Create Dynamic Possible Entries

Posted on Apr. 7, 2010 at 08.11 PM - Kuala Lumpur, Malaysia

I have been ask several times on the technique to create a dynamic possible entries through programming. I prepare this blog to answer this similar question that might come up in the future. Of course this is just one of the technique I love to use. There are some other technique which we don't discuss over here.

1. Get user input from the selection screen by using function module DYNP_VALUES_READ. Don't forget to populate variable lt_dynpfields with the selection screen parameters name.

* read screen values

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = sy-cprog

dynumb = sy-dynnr

* 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 = lt_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.

2. Based on the value retrieve from the function module, populate an internal table which we are going to use as a basis to display the possible entries. In this illustration is to get the payroll period data based on lv_permo and lv_pabrj which we retrieve from step 1.

* get the payroll period

SELECT * INTO TABLE lt_period

FROM t549q

WHERE permo = lv_permo

AND pabrj GE lv_pabrj.

3. Display the possible values by using SAP standard function module F4IF_INT_TABLE_VALUE_REQUEST.

* display possible values

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'IFID'

dynpprog = sy-cprog

dynpnr = sy-dynnr

dynprofield = 'P_IFID'

value_org = 'S'

TABLES

value_tab = gt_ifid.

4. update user selection to the screen CALL FUNCTION 'DYNP_VALUES_UPDATE'. Again, don't forget to populate variable lt_dynpfields with the selection screen parameters name plus values.

* update user selection to the screen

CALL FUNCTION 'DYNP_VALUES_UPDATE'

EXPORTING

dyname = sy-cprog

dynumb = sy-dynnr

TABLES

dynpfields = lt_dynpfields

EXCEPTIONS

invalid_abapworkarea = 1

invalid_dynprofield = 2

invalid_dynproname = 3

invalid_dynpronummer = 4

invalid_request = 5

no_fielddescription = 6

undefind_error = 7

OTHERS = 8.

Life is beautiful! Let's make it meaningful and colorful!