Allow free text in ALV Grid cell with dropdown

4.8k views Asked by At

I have set a dropdown list for an ALV Grid cell. The dropdow works fine, but it allows to enter values from the dropdown value list only. Is it possible to allow free text entry in the cell?

My ABAP code is:

Creating a value list:

DATA: lt_dropdown TYPE lvc_t_dral,
      ls_dropdown TYPE lvc_s_dral.
data: ls_taba TYPE dd07v,
      lt_taba TYPE STANDARD TABLE OF dd07v,
      lt_tabb TYPE STANDARD TABLE OF dd07v.

CALL FUNCTION 'DD_DOMA_GET'
  EXPORTING
    DOMAIN_NAME         = 'ZBC_TRADE_NETWORK'
    LANGU               = SY-LANGU
    WITHTEXT            = 'X'
 TABLES
    DD07V_TAB_A         = lt_taba
    DD07V_TAB_N         = lt_tabb
 EXCEPTIONS
    ILLEGAL_VALUE       = 1
    OP_FAILURE          = 2
    OTHERS              = 3
        .

 IF SY-SUBRC <> 0.
   return.
 ENDIF.

loop at lt_taba into ls_taba.
  ls_dropdown-handle = '1'.
  ls_dropdown-int_value = ls_taba-domvalue_l.
  ls_dropdown-value = ls_taba-ddtext.
  APPEND ls_dropdown TO lt_dropdown.
endloop.

*method to display the dropdown in ALV
CALL METHOD go_grid->set_drop_down_table
  EXPORTING
    IT_DROP_DOWN_ALIAS = lt_dropdown.

Fill the field catalogue:

data: ls_fcat type lvc_s_fcat,
      lt_fcat type lvc_t_fcat.

field-symbols: <lfs_fcat> type ls_fcat.

call function 'LVC_FIELDCATALOG_MERGE'
    exporting
      i_structure_name = gc_struct_name
    changing
      ct_fieldcat      = lt_fcat
    exceptions
      others           = 1.

loop at lt_fcat assigning <lfs_fcat>.
  case <lfs_fcat>-fieldname.  
    when 'NETWORK'.
      <lfs_fcat>-drdn_hndl = '1'.
      <lfs_fcat>-drdn_alias = 'X'.
      <lfs_fcat>-edit = abap_on.
  endcase.
endloop.

Set ALV grid for display

go_grid->set_table_for_first_display(
  exporting
    i_save               = lf_save
    i_default            = lf_default
    is_variant           = ls_vari
    is_layout            = ls_layo
    it_toolbar_excluding = lt_excl
  changing
    it_outtab            = <lfs_t_data>
   it_fieldcatalog       = lt_fcat
  exceptions
    others               = 1
).
1

There are 1 answers

0
vwegert On BEST ANSWER

No. A drop-down field implies a fixed value set. If you want to have both a value catalog and a text editing facility, use a value help (F4 help) to implement the catalog access.