Show TOC

Dropdown BoxesLocate this document in the navigation structure

Use

As well as input help, which appears in separate dialog boxes, you can also define input/output fields as dropdown boxes. A dropdown box offers the user a predefined set of input values from which to choose. It is not possible to type a entry into a dropdown box, instead, the user must use one of the values from the list. When the user chooses a value, the PAI event can be triggered simultaneously. If you use a dropdown box for a field, you cannot at the same time use the input help button.

List boxes are currently the only type of dropdown box supported. A list box is a value list containing a single text column of up to 80 characters. Internally, each text field has a key of up to 40 characters. When the user chooses a line, the contents of the text field are placed in the input field on the screen, and the contents of the key are placed in the screen field. The contents and length of the input/output field and the screen field are not necessarily the same.

To make an input/output field into a list box, you must set the value L or LISTBOX in the Dropdown attribute in the Screen Painter. The visLg attribute determines the output width of the list box and the field. You can assign a function code to a list box field. In this case, the PAI event is triggered as soon as the user chooses a value from the list, and the function code is placed in the sy-ucomm and OK_CODE fields. If you do not assign a function code, the PAI event must be triggered in the usual way -that is, when the user chooses a pushbutton or an element from the GUI status.

If you have assigned a list box to an input/output field, you can use the Value list attribute of the screen element to determine how the value list should be compiled. There are two options:

  • Value list from input help ( recommended)

    If you do not enter anything in the value list attribute, the text field uses the first column displayed in the input help assigned to the screen field. The input help can be defined in the ABAP Dictionary, the screen, or a POV dialog module. It should be laid out in two columns. The key is automatically filled.

  • Value list from PBO modules ( not recommended).

    If you enter A in the value list attribute, you must fill the value list yourself before the screen is sent (for example, in the PBO event) using the function module VRM_SET_VALUES. When you do this, you must pass an internal table with the type VRM_VALUES to the import parameter VALUES of the function module. VRM_VALUES belongs to the type group VRM. The line type is a structure consisting of the two text fields KEY (length 40) and TEXT (length 80). In the table, you can combine possible user entries from the KEY field with any texts from the TEXT component. You specify the corresponding input/output field in the import parameter ID.

Examples

Dropdown box with a value list from input help ( recommended)

          


          
*&---------------------------------------------------------------*
          
*& Report DEMO_DROPDOWN_LIST_BOX *
          
*&---------------------------------------------------------------*
          
REPORT demo_dropdown_list_box.
          
*&---------------------------------------------------------------*
          
*& Global Declarations *
          
*&---------------------------------------------------------------*
          
* Screen Interfaces
          
TABLES sdyn_conn.
          
DATA ok_code TYPE sy-ucomm.
          
* Global data
          
TYPES: BEGIN OF type_carrid,
          
carrid type spfli-carrid,
          
carrname type scarr-carrname,
          
END OF type_carrid.
          
DATA itab_carrid TYPE STANDARD TABLE
          
OF type_carrid WITH HEADER LINE.
          
*&---------------------------------------------------------------*
          
*& Processing Blocks called by the Runtime Environment *
          
*&---------------------------------------------------------------*
          
* Event Block START-OF-SELECTION
          
START-OF-SELECTION.
          
CALL SCREEN 100.
          
* Dialog Module PBO
          
MODULE status_0100 OUTPUT.
          
SET PF-STATUS 'SCREEN_100'.
          
ENDMODULE.
          
* Dialog Modules PAI
          
MODULE cancel INPUT.
          
LEAVE PROGRAM.
          
ENDMODULE.
          
*
          
MODULE user_command_0100 INPUT.
          
CASE ok_code.
          
WHEN 'SELECTED'.
          
MESSAGE i888(sabapdocu) WITH sdyn_conn-carrid.
          
ENDCASE.
          
ENDMODULE.
          
* Dialog Module POV
          
MODULE create_dropdown_box INPUT.
          
SELECT carrid carrname
          
FROM scarr
          
INTO CORRESPONDING FIELDS OF TABLE itab_carrid.
          
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
          
EXPORTING
          
retfield = 'CARRID'
          
value_org = 'S'
          
TABLES
          
value_tab = itab_carrid
          
EXCEPTIONS
          
parameter_error = 1
          
no_values_found = 2
          
OTHERS = 3.
          
IF sy-subrc <> 0.
          
...
          
ENDIF.
          
ENDMODULE.
          


          


            

The next screen (statically defined) for screen 100 is 100. The only input field on the screen is the component SDYN_CONN-CARRID. Its Dropdown attribute is set to L, and it has the output length 20. The Value list attribute is empty, and it has the function code SELECTED. The function codes of the buttons EXECUTE and CANCEL. CANCEL are defined in the GUI status as having the function type E.

The screen flow logic is as follows:

          


          


          
PROCESS BEFORE OUTPUT.
          
MODULE status_0100.
          
PROCESS AFTER INPUT.
          
MODULE cancel AT EXIT-COMMAND.
          
MODULE user_command_0100.
          
PROCESS ON VALUE-REQUEST.
          
FIELD sdyn_conn-carrid MODULE create_dropdown_box.
          


            

Users cannot enter any values into the screen fields. When they choose the input field on screen 100, the system displays a list box. The Value list attribute is empty, so the system launches the input mechanism. In this case, the event block PROCESS ON VALUE-REQUEST is created in the screen flow logic. This event block overrides all other mechanisms. A two-column internal table is filled in the appropriate dialog module and passed to the input help using the F4IF_INT_TABLE_VALUE_REQUEST function module. The system inserts the two columns of the table into the list box.

When the user chooses a line in the list box, the PAI event is triggered using the function code SELECTED and the value in the first column of the internal table is copied to the input field.

Dropdown box with a value list from the PBO module for screen 200 ( not recommended)

          


          


          
REPORT demo_dynpro_dropdown_listbox.
          
TYPE-POOLS vrm.
          
DATA: name TYPE vrm_id,
          
list TYPE vrm_values,
          
value LIKE LINE OF list.
          
DATA: wa_spfli TYPE spfli,
          
ok_code TYPE sy-ucomm,
          
save_ok TYPE sy-ucomm.
          
TABLES demof4help.
          
name = 'DEMOF4HELP-CONNID'.
          
CALL SCREEN 100.
          
MODULE cancel INPUT.
          
LEAVE PROGRAM.
          
ENDMODULE.
          
MODULE init_listbox OUTPUT.
          
CLEAR demof4help-connid.
          
SELECT connid cityfrom cityto deptime
          
FROM spfli
          
INTO CORRESPONDING FIELDS OF wa_spfli
          
WHERE carrid = demof4help-carrier2.
          
value-key = wa_spfli-connid.
          
WRITE wa_spfli-deptime TO value-text USING EDIT MASK '__:__:__'.
          
CONCATENATE value-text
          
wa_spfli-cityfrom
          
wa_spfli-cityto
          
INTO value-text SEPARATED BY space.
          
APPEND value TO list.
          
ENDSELECT.
          
CALL FUNCTION 'VRM_SET_VALUES'
          
EXPORTING
          
id = name
          
values = list.
          
ENDMODULE.
          
MODULE user_command_100.
          
save_ok = ok_code.
          
CLEAR ok_code.
          
IF save_ok = 'CARRIER' AND NOT demof4help-carrier2 IS INITIAL.
          
LEAVE TO SCREEN 200.
          
ELSE.
          
SET SCREEN 100.
          
ENDIF.
          
ENDMODULE.
          
MODULE user_command_200.
          
save_ok = ok_code.
          
CLEAR ok_code.
          
IF save_ok = 'SELECTED'.
          
MESSAGE i888(sabapdocu) WITH text-001 demof4help-carrier2
          
demof4help-connid.
          
ENDIF.
          
ENDMODULE.
          


            

The next screen (statically defined) for screen 100 is 200. It has the following layout:

The component CARRIER2 of the ABAP Dictionary structure DEMOF4HELP is assigned to the input field. Its Dropdown attribute is set to L, and it has the output length 15. The Value list attribute is empty, and it has the function code CARRIER. The pushbutton has the function code CANCEL with function type E.

The screen flow logic is as follows:

          


          


          
PROCESS BEFORE OUTPUT.
          
PROCESS AFTER INPUT.
          
MODULE cancel AT EXIT-COMMAND.
          
MODULE user_command_100.
          


            

The next screen (statically defined) for screen 200 is 100. It has the following layout:

The component CONNID of the ABAP Dictionary structure DEMOF4HELP is assigned to the input field. Its Dropdown attribute is set to L, and it has the output length 30. The Value list attribute is set to A, and it has the function code SELECTED. The pushbutton has the function code CANCEL with function type E.

The screen flow logic is as follows:

          


          


          
PROCESS BEFORE OUTPUT.
          
MODULE init_listbox.
          
PROCESS AFTER INPUT.
          
MODULE cancel AT EXIT-COMMAND.
          
MODULE user_command_200.
          


            

The user cannot type any values into the screen fields. When he or she chooses the input field on screen 100, a value list appears in the list box, compiled from the input help for the field DEMOF4HELP-CARRIER2. This is the search help H_SCARR, which is assigned to the check table SCARR. The value list contains the names of the airlines. When the user chooses an entry, the screen field is filled with the airline code, and the PAI event is triggered. The module user_command_100 checks the OK_CODE field and calls screen 200.

In the PBO event of screen 200, an internal table list is filled with values from the database table SPFLI. The key component is filled with the flight numbers, and other relevant information is placed in the text field. The list table is then passed to the function module VRM_SET_VALUES. When the user chooses the input field on screen 200, the text column of the internal table is displayed in the list box. When the user chooses an entry, the screen field is filled with the corresponding entry from the key column, and the PAI event is triggered. The module user_command_200 checks and processes the OK_CODE field.