cancel
Showing results for 
Search instead for 
Did you mean: 

Drop down by key in Editable ALV

former_member450736
Active Participant
0 Kudos

Hi,

i have two dropdown by keys in Editable ALV it is country and region.

for country i am able set attribute value set and i can see them in the alv country drop down for which coding is done in wddoinit, after setting attribute values set only i am making specific country column editor as drop down in alv, so when i start the applicaiton i can see countries.

now based on the country values i need get regions and fill region drop down again i am using node info and set attribute value set method for region field and setting those region values i am ablet to see them in the node info however they are not displayed in region drop down of alv.

the only difference i can see is country values are filled and then i am making columns ( country and region ) both drop downs but in regions case i made region column drop down first and then filling region values in the node info ( obviously not in wddoinit because values are based country value )

why this regions are not coming here?? any idea???

please suggest!!

Accepted Solutions (0)

Answers (1)

Answers (1)

Madhu2004
Active Contributor
0 Kudos

Hi,

As you need to populate the Region based on the country, it is clear that each row mahy have different values in the Region drop down. So dropdown by key will not serve the purpose.

Instead use DropdownbyIndex. For sample code on how to use dropdownbyindex refer the below link:

[Dropdown y index ALV|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0cbdde3-fe58-2c10-fcbc-8db18e693877?quicklink=index&overridelayout=true]

Regards,

Madhu

former_member450736
Active Participant
0 Kudos

you are correct, i changed it to drop down by index, however values are not displayed now..

i am using value set concept while creating cell editor i used drop down by index and also passing value set field name.

however when i insert row in alv no values are displayed...

this coding in wddoinit

WHEN 'COMPANY_ID'.
            lo_header->set_prop_ddic_binding_field(
             property =  if_salv_wd_c_ddic_binding=>bind_prop_text
             value = if_salv_wd_c_ddic_binding=>ddic_bind_none ).

            lo_header->set_text( 'Company ' ).

            CREATE OBJECT lo_ddidx
              EXPORTING
                selected_key_fieldname = 'COMPANY_ID'.
                lo_col->set_cell_editor( lo_ddidx ).

when i insert row in the event handler of ON_DATA_CHECK, i have following code

READ TABLE r_param->t_inserted_rows INTO ls_new_row INDEX 1.

  IF sy-subrc = 0.

    wd_this->gv_sequence = wd_this->gv_sequence + 1.

    lo_el = lo_nd->get_element( ls_new_row-index ).

    lo_el->set_attribute( value = wd_this->gv_sequence
    name = 'VENUE_ID').

*    ASSIGN ls_new_row-r_value->* TO <lfs_static>.
*    <lfs_static>-value_set_company = wd_this->gt_values.

    IF wd_this->gt_cols IS NOT INITIAL.
      LOOP AT wd_this->gt_cols INTO ls_cols.
        lo_col ?= ls_cols-r_column.
        CASE ls_cols-id.

          WHEN 'COMPANY_ID'.
            lo_ddidx ?= lo_col->get_cell_editor( ).

            IF lo_ddidx IS BOUND.
              lo_ddidx->set_valueset_fieldname(
           EXPORTING value = 'VALUE_SET_COMPANY'
             ).
              lo_ddidx->set_type( EXPORTING value = if_salv_wd_c_uie_drdn_by_index=>type_key_convert_to_value ).

              lo_col->set_cell_editor( lo_ddidx ).
            ENDIF.


        ENDCASE.
      ENDLOOP.
    ENDIF.
    lo_el->set_attribute( value = wd_this->gt_values
    name = 'VALUE_SET_COMPANY').

i dont know what went wrong here...

former_member450736
Active Participant
0 Kudos

problem solved...

just moved below code from on_data_check to wddoinit

WHEN 'COMPANY_ID'.
            lo_ddidx ?= lo_col->get_cell_editor( ).
 
            IF lo_ddidx IS BOUND.
              lo_ddidx->set_valueset_fieldname(
           EXPORTING value = 'VALUE_SET_COMPANY'
             ).
              lo_ddidx->set_type( EXPORTING value = if_salv_wd_c_uie_drdn_by_index=>type_key_convert_to_value ).
 
              lo_col->set_cell_editor( lo_ddidx ).
            ENDIF.

and added code

READ TABLE r_param->t_inserted_rows INTO ls_new_row INDEX 1.

  IF sy-subrc = 0.

    wd_this->gv_sequence = wd_this->gv_sequence + 1.

    lo_el = lo_nd->get_element( ls_new_row-index ).

    lo_el->set_attribute( value = wd_this->gv_sequence
    name = 'VENUE_ID').

        lo_el->set_attribute( value = wd_this->gt_values
    name = 'VALUE_SET_COMPANY').

    lo_el->set_attribute( value = wd_this->gt_countries
    name = 'VALUE_SET_COUNTRY').


  ENDIF.

to on_data_check of alv event