Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Issue in value set Drop down for ALV in Webdynpro with Index

Hi Experts,

We are unable to get the Drop down values in the ALV Table as shown below.

Code:

   DATA lo_nd_table TYPE REF TO if_wd_context_node.

    DATA lt_table TYPE wd_this->elements_table.

   DATA ls_table TYPE wd_this->element_table.

   DATA: lr_input TYPE REF TO cl_salv_wd_uie_input_field,

         lr_column TYPE REF TO cl_salv_wd_column,

         lt_node_info TYPE wdr_context_attr_info_map,

         ls_node_info TYPE wdr_context_attribute_info,

         lr_dropdown TYPE REF TO cl_salv_wd_uie_dropdown_by_idx,

         lr_info TYPE REF TO if_wd_context_node_info.

   DATA:lt_columns TYPE salv_wd_t_column_ref,

         ls_columns TYPE salv_wd_s_column_ref,

         lv_tabix TYPE sy-tabix,

         lv_count TYPE c.

   DATA: ls_valueset TYPE wdr_context_attr_value,

         lt_valueset TYPE wdr_context_attr_value_list.

   TYPES:BEGIN OF ty_name,

   name TYPE string,

   END OF ty_name.

   DATA: lt_name TYPE TABLE OF ty_name,

   ls_name TYPE ty_name.

*   navigate from <CONTEXT> to <TABLE> via lead selection

   lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).

   SELECT * FROM zemp_table INTO CORRESPONDING FIELDS OF TABLE lt_table UP TO 10 ROWS.

   LOOP AT lt_table INTO ls_table.

     lv_tabix = sy-tabix.

     CLEAR: ls_table-leave_values.

     DO 1 TIMES.

       lv_count = lv_count + 1.

       CONCATENATE 'Open' lv_count INTO ls_valueset-value.

       CONCATENATE 'Open' lv_count INTO ls_valueset-text.

       APPEND ls_valueset TO ls_table-leave_values.

       CLEAR ls_valueset.

       CONCATENATE 'Approved' lv_count INTO ls_valueset-value.

       CONCATENATE 'Approved' lv_count INTO ls_valueset-text.

       APPEND ls_valueset TO ls_table-leave_values.

       CLEAR ls_valueset.

       CONCATENATE 'Rejected' lv_count INTO ls_valueset-value.

       CONCATENATE 'Rejected' lv_count INTO ls_valueset-text.

       APPEND ls_valueset TO ls_table-leave_values.

       CLEAR ls_valueset.

     ENDDO.

     MODIFY lt_table FROM ls_table INDEX lv_tabix TRANSPORTING leave_status leave_values.

   ENDLOOP.

 

   DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

   lo_cmp_usage =   wd_this->wd_cpuse_alv( ).

   IF lo_cmp_usage->has_active_component( ) IS INITIAL.

     lo_cmp_usage->create_component( ).

   ENDIF.

   DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .

   lo_interfacecontroller =   wd_this->wd_cpifc_alv( ).

   DATA lo_value TYPE REF TO cl_salv_wd_config_table.

   lo_value = lo_interfacecontroller->get_model(

   ).

*  lo_interfacecontroller->set_data( r_node_data = lo_nd_value_set ).

**Get the context node information

   lr_info = lo_nd_table->get_node_info( ).

   lt_node_info = lr_info->get_attributes( ).

   LOOP AT lt_node_info INTO ls_node_info.

     ls_name-name = ls_node_info-name.

     APPEND ls_name TO lt_name.

   ENDLOOP.

*Get all the columns to make row editable

   CALL METHOD lo_value->if_salv_wd_column_settings~get_columns

     RECEIVING

       value = lt_columns.

* Make the field dropdown

   CALL METHOD lo_value->if_salv_wd_column_settings~get_column

     EXPORTING

       id    = 'LEAVE_STATUS'

     RECEIVING

       value = lr_column.

* Create Object for dropdown

   CREATE OBJECT lr_dropdown

     EXPORTING

       selected_key_fieldname = 'LEAVE_STATUS'.

   CALL METHOD lr_dropdown->set_valueset_fieldname

     EXPORTING

       value = 'LEAVE_VALUES'.

   CALL METHOD lr_dropdown->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_dropdown.

*Set the table Editable

   lo_value->if_salv_wd_table_settings~set_read_only( value = abap_false ).

   lo_nd_table->bind_table( new_items = lt_table ).

Please suggest me where we are going wrong.

Thanks in advance...!!!

Best Regard's,

Shashi Kanth

Tags:
replied

Hi Krishna,

We forgot to pass the it_valueset to lr_info so the values are not appending to the leave status field.

Data: lr_info TYPE REF TO if_wd_context_node_info.

*--- set attribute info

  lr_info->set_attribute_value_set( name = 'LEAVE_STATUS' value_set = lt_valueset ).

Best Regard's,

Shashi Kanth

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question