ABAP Keyword Documentation → ABAP - Reference → User Dialogs → Screens → Screen and Screen Elements → Screen Elements - Examples
Screens, List Box with Value List from Input Help
The example shows the recommended way to enable a dropdown list box.
Other versions: 7.31 | 7.40 | 7.54
Source Code
<span class="blue">*&---------------------------------------------------------------------*</span>
<span class="blue">*& Report DEMO_DROPDOWN_LIST_BOX *</span>
<span class="blue">*&---------------------------------------------------------------------*</span>
REPORT demo_dropdown_list_box.
<span class="blue">* Dynpro Interfaces</span>
TABLES sdyn_conn.
DATA ok_code TYPE sy-ucomm.
<span class="blue">* Local class definition</span>
CLASS dynpro_utilities DEFINITION.
PUBLIC SECTION.
CLASS-METHODS value_help.
ENDCLASS.
<span class="blue">* Local class implementation</span>
CLASS dynpro_utilities IMPLEMENTATION.
METHOD value_help.
TYPES: BEGIN OF carrid_line,
carrid TYPE spfli-carrid,
carrname TYPE scarr-carrname,
END OF carrid_line.
DATA carrid_list TYPE STANDARD TABLE OF carrid_line.
SELECT carrid carrname
FROM scarr
INTO CORRESPONDING FIELDS OF TABLE carrid_list.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CARRID'
value_org = 'S'
TABLES
value_tab = carrid_list
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
...
ENDIF.
ENDMETHOD.
ENDCLASS.
<span class="blue">* Event Blocks and Dialog Modules</span>
START-OF-SELECTION.
CALL SCREEN 100.
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
ENDMODULE.
MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'SELECTED'.
MESSAGE i888(sabapdemos) WITH sdyn_conn-carrid.
ENDCASE.
ENDMODULE.
MODULE create_dropdown_box INPUT.
dynpro_utilities=>value_help( ).
ENDMODULE.
Description
The static screen number of screen 100 is 100. The screen contains a single input field, the component SDYN_CONN-CARRID. Its attribute dropdown is "Listbox", the output length is 20, the attribute value list is empty, and it has been assigned function code SELECTED. The functions BACK, EXIT, and CANCEL are defined in the GUI status with the function type E. The screen flow logic is as follows:
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.
The user is not allowed to enter values in the screen field. If the user chooses the input field on screen 100, a list box is displayed. Since the attribute value list is empty, the input help mechanism is started. In this case, the event block PROCESS ON VALUE-REQUEST has been defined in the screen flow logic which overrides all other mechanisms. The system fills a two-column internal table in the corresponding dialog module and passes it to the input help using the function module F4IF_INT_TABLE_VALUE_REQUEST. The system then reads the second column of this table into the list box.
If the user chooses a row from the list box, the event PAI is triggered with the function code SELECTED, and the value in the first column of the internal table is copied to the input field.