Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show possible values of a screen field

Tags:

abap

In standard program screen, for some fields there is a button beside which you can click and search allowed values.

Example (program DEMO_DYNPRO_F4_HELP_DICTIONARY):

input field with its F4 help button

possible values after invoking F4 help

Can I do the same with ABAP, is it an additional feature of select-options or others?

like image 541
kk luo Avatar asked Jan 18 '26 12:01

kk luo


1 Answers

This little button at the right of the screen field tells you that there's a F4 help. Either you click this button or you place your cursor in the field and press F4 (hence the name), and the list of possible values is displayed and you may select one value.

There are many ways to determine what the F4 help should display. The list below shows how the ABAP runtime decides what to do when the F4 help is invoked, and that should be sufficient for you to get further information on the Web (source: SAP Library "Hierarchy of the Search Help Call").

The SAP Library used to provide the following diagram (also available here) what the system calls when the user displays the list of values of a given field, that I detail below :

Copyright SAP Library - Hierarchy of the Search Help Call

Note that it concerns all types of screens of the Dynpro technology, and Selection Screens are part of it but there's an additional layer to understand.

So I first give a general explanation of the F4 help for all types of screens of the Dynpro technology, followed by a chapter dedicated to the Selection Screens.

What happens when the F4 help is invoked:

  1. If some ABAP code is explicitly assigned to the screen field (PROCESS ON VALUE-REQUEST), this code is called.
    • In the event block PROCESS ON VALUE-REQUEST of the Screen Flow Logic, use FIELD <screenfieldname> MODULE <modulename>.
    • Define the ABAP code inside your program, inside MODULE <modulename> and ENDMODULE statements.
    • You may implement any screen solution to display the possible values. A frequent solution is to call the function module F4IF_INT_TABLE_VALUE_REQUEST.
  2. Else if the screen field is explicitly assigned a Search Help (*), this Search Help is invoked.
  3. Else if the screen field is assigned a name which corresponds to a DDIC component (e.g. the field name SFLIGHT-CARRID corresponds to the column CARRID of the DDIC table SFLIGHT) and at the same time the screen field attribute "DD field" is checked:
    1. If a Search Help is assigned to the DDIC component, this Search Help is invoked.
    2. Else if the DDIC component has a foreign key (which refers to a table known as the Check Table):
      • If the Check Table is linked to a Search Help, this Search Help is invoked.
      • Else if the Check Table is assigned a Text Table, the check table is shown with the texts from the text table.
      • Else the Check Table is shown.
    3. Else if the Data Element of the DDIC column is assigned a Search Help, this Search Help is invoked.
    4. Else if the Data Element of the DDIC column refers a Domain which has some fixed values, those values are shown with their respective texts.
  4. Else if the screen field has the type DATS (date field), the Calendar Help is shown.
  5. Else if the screen field has the type TIMS (time field), the Clock Help is shown.
  6. Else nothing happens.

(*) A Search Help is a repository object which simplifies the development for handling the classic F4 helps. It refers to a database table or view, indicates what are the possible input and returned columns, the additional selection criteria, the displayed columns, etc. It's maintained via the transaction code SE11.

Please look at those demo programs in your ABAP system :

  • DEMO_DYNPRO_F4_HELP_DICTIONARY : Demonstration for F4 Help from ABAP Dictionary on Dynpros
  • DEMO_DYNPRO_F4_HELP_DYNPRO : Demonstration for F4 Help on Dynpros
  • DEMO_DYNPRO_F4_HELP_MODULE : Demonstration for F4 Help from Dialog Modules

Selection screens

The Selection screens are general screens whose layout and flow logic are described via ABAP statements and a corresponding general screen is generated at compile time, while the general screens are designed graphically via the Screen Painter.

There are the following ABAP statements for handling the F4 help in a selection screen (but the ABAP runtime behaves the same as above when the F4 help is invoked):

  • To handle the F4 help of a selection screen field via ABAP code, the ABAP statement AT SELECTION-SCREEN ON VALUE-REQUEST FOR <screen field name> must be used.
  • It's possible to assign a Search Help to a selection screen field by adding the words MATCHCODE OBJECT <searchhelpname> to the ABAP statements PARAMETERS and SELECT-OPTIONS.

Note that a selection screen should not be changed manually because it's re-generated every time the program is activated, and that the screen fields have always the "DD Field" attribute deactivated so the ABAP runtime won't access the search helps defined in the DDIC.

Example:

The following selection screen statements:

PARAMETERS p_file TYPE string.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  MESSAGE 'instead, display your F4 dialog' TYPE 'I'.

generate both a selection screen (layout and flow logic):

PROCESS ON VALUE-REQUEST.
  FIELD P_FILE MODULE %_P_FILE_VAL.

and some ABAP code inside the program which is hidden to the developer:

MODULE %_P_FILE_VAL INPUT.
  MESSAGE 'instead, display your F4 dialog' TYPE 'I'.
ENDMODULE.
like image 58
3 revsSandra Rossi Avatar answered Jan 21 '26 08:01

3 revsSandra Rossi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!