Skip to Content

How to Add Dropdown in Table UI element

Hi all,

         Can anyone give the code how to add dropdown in table ui element.

Thanks,

Raghunadh Kodali.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    May 01, 2012 at 05:57 AM

    Hi Raghu,

    Check the tutorial will able to understand...

    Drop Down in ALV table:

    http://www.saptechnical.com/Tutorials/WebDynproABAP/ALV/Index.htm

    http://www.sapdev.co.uk/sap-webapps/sap-webdynpro/table-dropdown.htm

    Drop Down in Normal Table:

    http://scn.sap.com/thread/1105370

    Regards,

    Farooq

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Raghu,

      Make use below code :


      method WDDOINIT .
        DATA:
      lo_node_cskt TYPE REF TO if_wd_context_node,
      lo_el_cskt TYPE REF TO if_wd_context_element,
      ls_cskt TYPE wd_this->element_cskt,
      lt_cskt TYPE wd_this->elements_cskt,
      lo_cmp_usage TYPE REF TO if_wd_component_usage,
      lv_value TYPE REF TO cl_salv_wd_config_table,
      lr_column TYPE REF TO cl_salv_wd_column,
      lr_drdn TYPE REF TO cl_salv_wd_uie_dropdown_by_idx,
      ls_value_set TYPE wdr_context_attr_value,
      lv_tabix TYPE sy-tabix,
      lv_count(2) TYPE c,
      lo_interfacecontroller TYPE REF TO iwci_salv_wd_table.

      * Navigate from <CONTEXT> to <CSKT> via lead selection:
      lo_node_cskt = wd_context->get_child_node( name = wd_this->wdctx_cskt ).

      * get element via lead selection
      lo_el_cskt = lo_node_cskt->get_element( ).

      * Get Data:
      SELECT kokrs kostl datbi ktext FROM cskt INTO CORRESPONDING FIELDS OF TABLE lt_cskt up to 10 rows .

      lv_count = 0.

      * Populate value set
      LOOP AT lt_cskt INTO ls_cskt.
      lv_tabix = sy-tabix.
      CLEAR ls_cskt-ktext.
      DO 3 TIMES.
      lv_count = lv_count + 1.
      CONCATENATE 'TEST' lv_count INTO ls_value_set-text.
      CONCATENATE 'TEST' lv_count INTO ls_value_set-value.
      if lv_tabix = 2.
      if sy-index = 2.
      EXIT.
      endif.
      endif.
      APPEND ls_value_set TO ls_cskt-valueset.
      ENDDO.

      MODIFY lt_cskt FROM ls_cskt INDEX lv_tabix TRANSPORTING ktext valueset.
      ENDLOOP.

      * Bind data
      lo_node_cskt->bind_table( lt_cskt ).

      * Instantiate ALV
      lo_cmp_usage = wd_this->wd_cpuse_alv( ).
      IF lo_cmp_usage->has_active_component( ) IS INITIAL.
      lo_cmp_usage->create_component( ).
      ENDIF.

      lo_interfacecontroller = wd_this->wd_cpifc_alv( ).

      * Bind Data to Interface Controller Node
      lo_interfacecontroller->set_data(
      r_node_data = lo_node_cskt
      ).

      * Get ALV reference table
      lv_value = lo_interfacecontroller->get_model( ).

      * Make KTEXT column as drop down
      CALL METHOD lv_value->if_salv_wd_column_settings~get_column
      EXPORTING
      id = 'KTEXT'
      RECEIVING
      value = lr_column.

      * Create Object for Drop down
      CREATE OBJECT lr_drdn
      EXPORTING
      selected_key_fieldname = 'KTEXT'.

      CALL METHOD lr_drdn->set_valueset_fieldname
      EXPORTING
      value = 'VALUESET'.
      CALL METHOD lr_drdn->set_type
      EXPORTING
      value = IF_SALV_WD_C_UIE_DRDN_BY_INDEX=>TYPE_KEY_CONVERT_TO_VALUE.

      CALL METHOD lr_column->set_cell_editor
      EXPORTING
      value = lr_drdn.

      CALL METHOD lv_value->if_salv_wd_table_settings~set_read_only
      EXPORTING
      value = abap_false.
      endmethod.

      Regards,

      Farooq

  • May 02, 2012 at 06:30 AM

    After adding the dropdown there is an event called ON_ALV_TOOLBAR which triggers upon any action on ALV toolbar. Make use of that for the event handling purpose.

    Add comment
    10|10000 characters needed characters exceeded