Skip to Content

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

Drop down in ALV for Webdynpro ABAP

Hi Experts,

I was trying to implement one Web dynpro ABAP application that will show one ALV and ALV will content one dropdown so that user can select data from the drop down. Addtion to that, my dropdown should have data based on another column of ALV.

I have followed one article which is available in Net.

At the end of development, ALV is displayed with dropdown. Also dropdown has data binded. However, no data is visible in dropdown.

I have created one context node having four dictionary element and one elemt for dispplaying the dropdown.

In the DoInit method of view, i have written below code:

  • Data Declaration

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.

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.

I am still finding the answer why data in drop down is not visible. However, I can select by clicking dropdown and blank elements (since data is not visible) can be selected.

Tags:
Former Member
replied

Hey

i am using the same code except i have just modified little bit the select statement to restrict the number of entries.

and also besides writing the code in wddoinit i have added the compenent usage of alv component and added the node

having the structure ckst and after that deleting the dictionary reference to add the attribute valueset in both places

component controller and view controller and mapped them and mapped the data node of interface controller of comp

usage to this node in comp contrlr.

and adding the view container and embeding table view of alv comp there.

that's it

and here is the code which is almost same as yours except small change in select statement.

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.

thanks

sarbjeet

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