cancel
Showing results for 
Search instead for 
Did you mean: 

Why is data in DropDownByIndex not visible in WDA ALV

rachid_abik2
Member
0 Kudos

Hi Experts,

I was trying to implement a DropDownByIndex in a WDA ALV.

I have created one context node sflight having the structure SFLIGHT and after that deleting the dictionary reference to add the attribute valueset(value list) for the DropDownByIndex element.

The value list called VALUESET of type WDR_CONTEXT_ATTR_VALUE_LIST.

I have created the context node sflight in both places component controller and view controller and mapped them and mapped the data node of interface controller of component usage to this node in component controller.

I can see 3 blank elements in the dropdown element.

In the WDDOINIT method of view, I have written below code:

METHOD wddoinit.

DATA: lo_nd_sflight TYPE REF TO if_wd_context_node,

lo_el_sflight TYPE REF TO if_wd_context_element.

DATA: lt_sflight TYPE TABLE OF wd_this->element_sflight,

ls_flight TYPE wd_this->element_sflight.

DATA: lr_config TYPE REF TO cl_salv_wd_config_table,

lr_column TYPE REF TO cl_salv_wd_column,

lr_comp_if_alv TYPE REF TO iwci_salv_wd_table,

lo_cmp_usage TYPE REF TO if_wd_component_usage,

lr_dropdown_key TYPE REF TO cl_salv_wd_uie_dropdown_by_idx,

lt_columns TYPE salv_wd_t_column_ref,

lr_column_settings TYPE REF TO if_salv_wd_column_settings,

lr_node_info TYPE REF TO if_wd_context_node_info,

lr_node TYPE REF TO if_wd_context_node,

wa_value_set TYPE wdr_context_attr_value,

lt_value_set TYPE TABLE OF wdr_context_attr_value,

lv_planetype TYPE sflight-planetype,

lt_planetype TYPE STANDARD TABLE OF sflight-planetype,

lv_tabix TYPE sy-tabix,

lv_count(2) TYPE n.

FIELD-SYMBOLS <fs_column> LIKE LINE OF lt_columns.

SELECT * UP TO 5 rows FROM sflight INTO CORRESPONDING FIELDS OF TABLE lt_sflight.

  • navigate from <CONTEXT> to <SFLIGHT> via lead selection

lo_nd_sflight = wd_context->get_child_node( name = wd_this->wdctx_sflight ).

lo_el_sflight = lo_nd_sflight->get_element( ).

MOVE 'AA' TO wa_value_set-text.

MOVE 'AA' TO wa_value_set-value.

APPEND wa_value_set TO lt_value_set.

MOVE 'AB' TO wa_value_set-text.

MOVE 'AB' TO wa_value_set-value.

APPEND wa_value_set TO lt_value_set.

MOVE 'AD' TO wa_value_set-text.

MOVE 'AD' TO wa_value_set-value.

APPEND wa_value_set TO lt_value_set.

LOOP AT lt_sflight INTO ls_flight.

clear ls_flight-carrid.

lv_tabix = sy-tabix.

ls_flight-VALUESET[] = lt_value_set[].

MODIFY lt_sflight FROM ls_flight INDEX lv_tabix TRANSPORTING carrid VALUESET.

ENDLOOP.

  • Bind data

lo_nd_sflight->bind_table( lt_sflight ).

  • Get ALV Component

lo_cmp_usage = wd_this->wd_cpuse_alv( ).

IF lo_cmp_usage->has_active_component( ) IS INITIAL.

lo_cmp_usage->create_component( ).

ENDIF.

  • Get References for ALV

lr_comp_if_alv = wd_this->wd_cpifc_alv( ). " get component

lr_comp_if_alv->set_data( r_node_data = lo_nd_sflight ).

lr_config = lr_comp_if_alv->get_model( ). " get cofig model

  • Find the desired column and assign the dropdown

  • Insetad of looping through all coumns, you can also use the following

  • statement to get the col reference:

lr_column = lr_config->if_salv_wd_column_settings~get_column( 'CARRID' ).

CREATE OBJECT lr_dropdown_key

EXPORTING

selected_key_fieldname = 'CARRID'.

lr_dropdown_key->set_valueset_fieldname( value = 'VALUESET' ).

lr_dropdown_key->set_type( if_salv_wd_c_uie_drdn_by_index=>type_key_convert_to_value ).

lr_column->set_cell_editor( lr_dropdown_key ).

  • ALV - Disable Write Protection

lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).

ENDMETHOD.

Why is data in DropDown not visible?

Regards,

Rachid

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The valueset is not a normal attribute as you have tried to use it, but instead a property of the node info. When you use set_valueset_fieldname you are only saying which attribute it should use to read the value set from the node info. It can't read it directly from the context. Even if your approach worked it would have to be a subnode. You can't have a 1:n attribute.

You need to use IF_WD_CONTEXT_NODE_INFO=>SET_ATTRIBUTE_VALUE_SET to populate the Value Set values into the context node info for the context node.

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/bb/69b441b0133531e10000000a155106/frameset.htm