December 1999 609
Input Help in Dialog Modules
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 <f> 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, 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:
• F4IF_FIELD_VALUE_REQUEST
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 [Page 602] 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.
• F4IF_INT_TABLE_VALUE_REQUEST
This function module displays a value list that you created in an ABAP program. The 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
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 LIKE SY-REPID, DYNNUM LIKE 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.
Input Help in Dialog Modules
December 1999 611
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 itself. It has the following layout:
Cancel Airline Flight number
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.
Input Help in Dialog Modules