Thursday, November 22, 2007

Defining Input Help

If a field in an executable program is defined with reference to an ABAP Dictionary field for which
possible entries help is defined, the values from the ABAP Dictionary help are automatically
displayed when the user calls the F4 help for that field. To create possible values help for input
fields that have no Dictionary reference, or to override the help normally linked to the field, you
can create an event block for the event

AT SELECTION-SCREEN ON VALUE-REQUEST FOR
The event is triggered when the user calls the F4 help for the field . If no corresponding
event block has been defined, the possible values help from the ABAP Dictionary is displayed, or
none at all if the field has no Dictionary reference. If a corresponding event block exists, it takes
precedence over the default possible values help mechanism. It is then up to the programmer to
ensure that an appropriate list of values is displayed, and that the user can choose a value from
it.
You cannot declare the event block AT SELECTION-SCREEN ON VALUE-REQUEST for input
fields on the selection screen that are declared within a logical database. You cannot override
the possible values help mechanism of a logical database within the program. You can define
separate help within the logical database program using the VALUE-REQUEST option in the
PARAMETERS and SELECT-OPTIONS statements.
REPORT SELECTION_SCREEN_F4_DEMO.
PARAMETERS: P_CARR_1 TYPE SPFLI-CARRID,
P_CARR_2 TYPE SPFLI-CARRID.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_CARR_2.
CALL SCREEN 100 STARTING AT 10 5
ENDING AT 50 10.
MODULE VALUE_LIST OUTPUT.
SUPPRESS DIALOG.
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
SET PF-STATUS SPACE.
NEW-PAGE NO-TITLE.
WRITE 'Star Alliance' COLOR COL_HEADING.
ULINE.
P_CARR_2 = 'AC '.
WRITE: / P_CARR_2 COLOR COL_KEY, 'Air Canada'.
HIDE P_CARR_2.
P_CARR_2 = 'LH '.
WRITE: / P_CARR_2 COLOR COL_KEY, 'Lufthansa'.
HIDE P_CARR_2.
P_CARR_2 = 'SAS'.
WRITE: / P_CARR_2 COLOR COL_KEY, 'SAS'.
HIDE P_CARR_2.
P_CARR_2 = 'THA'.
4 WRITE: / P_CARR_2 COLOR COL_KEY, 'Thai International'.
HIDE P_CARR_2.
P_CARR_2 = 'UA '.
WRITE: / P_CARR_2 COLOR COL_KEY, 'United Airlines'.
HIDE P_CARR_2.
CLEAR P_CARR_2.
ENDMODULE.
AT LINE-SELECTION.
CHECK NOT P_CARR_2 IS INITIAL.
LEAVE TO SCREEN 0.

This program defines a selection screen with two parameters, both of which refer to
the column CARRID in the database table SPFLI. The possible entries help from the
ABAP Dictionary is used for P_CARR_1, and a separate possible entries help is
programmed for P_CARR_2. Screen 100 is used for the possible entries help. The
dialog module VALUE_LIST is started in its PBO event. The actual screen mask is
not used, and there are no dialog modules used in the PAI.

PROCESS BEFORE OUTPUT.
MODULE VALUE_LIST.
PROCESS AFTER INPUT.

The dialog module VALUE_LIST suppresses the dialog of screen 100 and switches
to list processing. The list contains values for the parameter P_CARR_2. These
values are also placed in the HIDE area. When the user selects a line from the value
list, the AT LINE-SELECTION event is triggered, and the selected value is
transferred from the HIDE area into the field P_CARR_2. If the user selects a valid
line, the system switches directly from the event block AT LINE-SELECTION back to
the selection screen, and fills the corresponding input field.

No comments:

Blog Archive