How to set the cell of the ALV List as a Dropdown list in SAP ABAP?

It is used to provide a list of values as a Drop down List.

There are three important steps involved in setting the cell as a drop down list.

  1. Filling the internal table lvc_t_dral.
  2. Setting the fields drdn_hndl, drdn_alias of field catalog.
  3. Call the method set_drop_down_table of the ALV object.
  • Filling the internal table lvc_t_dral.

Handle: The field Handle holds the value, which can be used to refer to the value mentioned in the field drdn_hndl of field catalog. Therefore it connects to the field catalog.

Value: It is considered as the Display name. It holds the value to be used in the Drop down list. If the field DRDN_ALIAS of the field catalog is initial, then this value is considered for the Drop down list.

INT_VALUE: It is considered as the Technical name. It also holds the value to be displayed in the Drop down List. If the field DRDN_ALIAS of the field catalog is ‘X’, then the value from the int_value field is used in the Drop down list.

Let us consider the following example:

DATA lt_dral TYPE lvc_t_dral.

DATA ls_dral TYPE lvc_s_dral.

ls_dral-handle = 3.

ls_dral-value = ‘Street1_value’.

ls_dral-int_value = ‘Street1_int_value’.

APPEND ls_dral TO lt_dral.

ls_dral-value = ‘Street2_value’.

ls_dral-int_value = ‘Street2_int_value’.

APPEND ls_dral TO lt_dral.

  • Setting the ‘DRDN’ fields of Field Catalog.

FIELD-SYMBOLS <ls_field_cat> TYPE lvc_s_fcat.

LOOP AT lt_field_cat ASSIGNING <ls_field_cat> WHERE fieldname = ‘CONTACT ADDRESS’.

<ls_field_cat> – drdn_hndl = 3.

<ls_field_cat> – drdn_alias = ‘X’.

ENDLOOP.

              In the above field catalog assignment, the field ‘DRDN_ALIAS’ is set to ‘X’, which means the value of field ‘INT_VALUE’ is considered in the Drop down list. The value of field ‘VALUE’ is ignored. If the field ‘DRDN_ALIAS’ is initial like <ls_field_cat> – drdn_alias = ‘ ‘, Then the value of field ‘VALUE’ is considered in the Drop down list.

  • Passing the internal table values lvc_t_dral to the ALV object.

The method set_drop_down_table of the ALV object is used to set the drop down values (Internal table) to the partical column ‘CONTACT_ADDRESS’ of the ALV List.

CALL METHOD lr_gui_alv_grid -> set_drop_down_table(

              EXPORTING

                            it_drop_down_alias = lt_dral ).

The above method call must happen before the method ‘SET_TABLE_FOR_FIRST_DISPLAY’ is called.