cancel
Showing results for 
Search instead for 
Did you mean: 

Dropdown in ALV table

ChandraMahajan
Active Contributor
0 Kudos

Hi All,

I want to show one column in ALV as dropdown. I have node ALV_TAB in which there is field status. This field I want to show as dropdown. I read some threads on this. But I am only able to display the column as dropdown. I want to fill the dropdown with some values. As of now the dropdown shows the value fetched from backend table (single value). My requirement is to have that column in editable mode with values (new, accept, reject etc) in dropdown. So that user will select the value and process that record.

Do I need to take one more attribute of type wdr_context_attr_value in node ALV_TAB? and how this needs to link with status field.

Please let me know.

Thanks,

Chandra

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hello,

I read your explanaton about list boxes in ALV, but I still have questons.

1. In my ALV I need to have two list boxes fields and I did the same (like in your example) for the second drop list row and it does not work I have a dump.

2. When I want to give to user input field in ALV , how can I do it when user append or insert new row ?

Thanks for the future advance.

Igor.

Former Member
0 Kudos

HI,

Please guide me how to code for drop down list in ALV,

Awaiting for ur reply ASAP>

Regards,...

ChandraMahajan
Active Contributor
0 Kudos

Hi,

declare node. in this you can have attribute eg. STATUS type string and STATUS_LIST type WDR_CONTEXT_ATTR_VALUE_LIST.

below code will help you.

DATA lo_nd_alv_chgdlr TYPE REF TO if_wd_context_node.

DATA lo_el_alv_chgdlr TYPE REF TO if_wd_context_element.

lo_nd_alv_chgdlr = wd_context->get_child_node( name = wd_this->wdctx_alv_chgdlr ).

DATA: lt_valueset TYPE wdr_context_attr_value_list,

ls_valueset TYPE wdr_context_attr_value,

stru_alv_chgdlr TYPE wd_this->element_alv_chgdlr,

itab_alv_chgdlr TYPE wd_this->elements_alv_chgdlr.

CLEAR: ls_valueset.

ls_valueset-value = 'A'.

ls_valueset-text = 'Accepted'.

APPEND ls_valueset TO lt_valueset.

CLEAR: ls_valueset.

ls_valueset-value = 'R'.

ls_valueset-text = 'Rejected'.

APPEND ls_valueset TO lt_valueset.

CLEAR: stru_alv_chgdlr.

DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table,

l_ref_cmp_usage TYPE REF TO if_wd_component_usage.

l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).

IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.

l_ref_cmp_usage->create_component( ).

ENDIF.

l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).

l_ref_interfacecontroller->set_data( r_node_data = lo_nd_alv_chgdlr ).

DATA:

l_alv_model TYPE REF TO cl_salv_wd_config_table,

lr_column_settings TYPE REF TO if_salv_wd_column_settings,

lr_column TYPE REF TO cl_salv_wd_column,

lr_dropdown TYPE REF TO cl_salv_wd_uie_dropdown_by_idx.

l_alv_model = l_ref_interfacecontroller->get_model( ).

l_alv_model->if_salv_wd_table_settings~set_read_only( abap_false ).

lr_column ?= l_alv_model->if_salv_wd_column_settings~get_column( id = 'STATUS' ).

CREATE OBJECT lr_dropdown

EXPORTING

selected_key_fieldname = 'STATUS'.

lr_dropdown->set_valueset_fieldname( value = 'STATUS_LIST' ).

lr_dropdown->set_read_only( value = abap_false ).

lr_dropdown->set_type( if_salv_wd_c_uie_drdn_by_index=>type_key_value ).

lr_column->set_cell_editor( lr_dropdown ).

**Get the data in internal table it_alv

LOOP AT it_alv INTO wa_alv.

stru_alv_chgdlr-pin = wa_alv-pin.

stru_alv_chgdlr-customer = wa_alv-customer.

*Some code

stru_alv_chgdlr-status_list = lt_valueset.

ENDLOOP. " LOOP AT it_alv INTO wa_alv.

lo_nd_alv_chgdlr->bind_elements( itab_alv_chgdlr ).

Regards,

Chandra

Edited by: Chandrashekhar Mahajan on Mar 25, 2008 5:31 AM

Former Member
0 Kudos

Hi Chandrashekhar,

I have the same requirement but I'm not getting any idea how to do it. can you share how u have done it?

Thanks,

Ram

ChandraMahajan
Active Contributor
0 Kudos

Problem resolved...