简体   繁体   中英

Allow free text in ALV Grid cell with dropdown

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
).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM