You can call dialog modules in the POV event using the event keyword PROCESS ON VALUE-REQUEST.
PROCESS ON VALUE-REQUEST. ... FIELD f MODULE mod. ...
After the PROCESS ON VALUE-REQUEST statement, you can only use the MODULE statement together with the FIELD statement. When the user chooses F4 for a field f, the system calls the module mod belonging to the FIELD statement. If there is more than one FIELD statement for the same field f, only the first is executed. The module mod is defined in the ABAP program like a normal PAI module. However, the contents of the screen field f are not available in the module, since it is not transported by the FIELD statement during the PROCESS ON HELP-REQUEST event. You can now program your own value lists in the module. However, this procedure is only recommended if it really is not possible to use a search help. Defining search helps is much easier than PROCESS ON VALUE-REQUEST, since the system takes over some of the standard operations, such as getting field contents from the screen. It also ensures that the F4 help has a uniform look and feel throughout the system. Furthermore, it means that you do not have to reassign input help to fields on each screen.
Despite the introduction of search helps (and search help exits), there are still cases in which you need to use parts of the standard F4 functions directly. In this case, there are some standard function modules that you can use in the POV event. They support search helps, as well as all other kinds of input help, and are responsible for data transport between the screen and the input help. These all have the prefix F4IF_. The most important are:
Calls the input help of the ABAP Dictionary dynamically. You can pass the component names of a structure or database table of the ABAP Dictionary to the function module in the import parameters TABNAME and FIELDNAME. The function module starts the ABAP Dictionary input help for this component. All of the relevant screen fields are read. If you specify the import parameters DYNPPROG, DYNPNR, and DYNPROFIELD, the user's selection is returned to the corresponding field on the screen. If you specify the table parameter RETURN_TAB, the selection is returned into the table instead.
This function module displays a value list that you created in an ABAP program. The self-programmed value list is passed to the function module as the table parameter VALUE_TAB. If you specify the import parameters DYNPPROG, DYNPNR, and DYNPROFIELD, the user's selection is returned to the corresponding field on the screen. If you specify the table parameter RETURN_TAB, the selection is returned into the table instead.
There are also two function modules - DYNP_VALUES_READ and DYNP_VALUES_UPDATE - that can read the values of screen fields and return values to them during the POV event. For further information, refer to the relevant function module documentation.
Input help in dialog modules
REPORT demo_dynpro_f4_help_module. TYPES: BEGIN OF values, carrid TYPE spfli-carrid, connid TYPE spfli-connid, END OF values. DATA: carrier(3) TYPE c, connection(4) TYPE c. DATA: progname TYPE sy-repid, dynnum TYPE sy-dynnr, dynpro_values TYPE TABLE OF dynpread, field_value LIKE LINE OF dynpro_values, values_tab TYPE TABLE OF values. CALL SCREEN 100. MODULE init OUTPUT. progname = sy-repid. dynnum = sy-dynnr. CLEAR: field_value, dynpro_values. field_value-fieldname = 'CARRIER'. APPEND field_value TO dynpro_values. ENDMODULE. MODULE cancel INPUT. LEAVE PROGRAM. ENDMODULE. MODULE value_carrier INPUT. CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST' EXPORTING tabname = 'DEMOF4HELP' fieldname = 'CARRIER1' dynpprog = progname dynpnr = dynnum dynprofield = 'CARRIER'. ENDMODULE. MODULE value_connection INPUT. CALL FUNCTION 'DYNP_VALUES_READ' EXPORTING dyname = progname dynumb = dynnum translate_to_upper = 'X' TABLES dynpfields = dynpro_values. READ TABLE dynpro_values INDEX 1 INTO field_value. SELECT carrid connid FROM spfli INTO CORRESPONDING FIELDS OF TABLE values_tab WHERE carrid = field_value-fieldvalue. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'CONNID' dynpprog = progname dynpnr = dynnum dynprofield = 'CONNECTION' value_org = 'S' TABLES value_tab = values_tab. ENDMODULE.
The next screen (statically defined) for screen 100 is 100. It has the following layout:
The input fields have been adopted from the program fields carrier and connection. The pushbutton has the function code CANCEL with function type E.
The screen flow logic is as follows:
PROCESS BEFORE OUTPUT. MODULE init. PROCESS AFTER INPUT. MODULE cancel AT EXIT-COMMAND. PROCESS ON VALUE-REQUEST. FIELD carrier MODULE value_carrier. FIELD connection MODULE value_connection.
When the user chooses input help for the individual fields, the following is displayed:
For the Airline field, the POV module VALUE_CARRIER is called. The function module F4IF_FIELD_VALUE_REQUEST displays the input help for the component CARRIER1 of the structure DEMOF4HELP from the ABAP Dictionary, namely the search help DEMOF4DE. The user's selection is returned to the screen field carrier.
For the Flight number field, the POV module value_connection is called. The function module DYNP_VALUE_READ transports the value of the screen field carrier into the program. The program then reads the corresponding values from the database table SPFLI into the internal table values_tab using a SELECT statement, and passes the internal table to F4IF_INT_TABLE_VALUE_REQUEST. This displays the internal table as input help, and places the user's selection into the screen field connection.