cancel
Showing results for 
Search instead for 
Did you mean: 

Droplist in WD ALV Cell

Former Member
0 Kudos

Hi,

I have an editable ALV.I want to give an option in a cell with droplist (DAYS/Weeks)

How can we achieve this?

Do we have any sample WD in SAP for this requirement?

Rgds

vara

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

But if you would like to achieve the DropDownByIdx functionality then create a context attribute of type WDR_CONTEXT_ATTR_VALUE_SET which would contain the values to be displayed within the dropdown. You would have to populate the TEXT & VALUE properties into this particular context attribute. You then follow the similar approach as in the earlier example except that you create an instance of type CL_SALV_WD_UIE_DROPDOWN_BY_IDX instead of CL_SALV_WD_UIE_DROPDOWN_BY_KEY.

1) You bind the SELECTED_KEY_FIELDNAME property to the context attribute of your desired column. (So if you have attributes like COL1, COL2... & a special attribute of type WDR_CONTEXT_ATTR_VALUE_SET then to make COL2 appear as dropdown you get the reference of this particular column and change after doing the steps 2 & 3 below you change its celleditor to a DropDownByIdx.)

2) Then fill values to the dropdown by using the SET_VALUESET_FIELDNAME method of class CL_SALV_WD_UIE_DROPDOWN_BY_IDX. (So you made your COL2 as dropdown and then specify values for it by calling the SET_VALUESET_FIELDNAME on the dropdowns reference & pass your attribute of type WDR_CONTEXT_ATTR_VALUE_SET which you had created earlier.)

3) Using the dropdowns reference you call the SET_TYPE method of CL_SALV_WD_UIE_DROPDOWN_BY_IDX & pass the value as:

IF_SALV_WD_C_UIE_DRDN_BY_INDEX=>TYPE_KEY_CONVERT_TO_VALUE.

Thats it you should have achieved similar functionality of DEMO_VARIABLE_DROPDOWN within an ALV. If you are still unclear you can reach across to me & I would get back to you with a link from where you can access the step-by-step explanation of all the above with respective screenshots.

Regards,

Uday

Former Member
0 Kudos

Thank you uday it solvedd my problem.

I have awarded points.

Thank you lekha.

rgds

vara

Answers (4)

Answers (4)

uday_gubbala2
Active Contributor
0 Kudos
DATA:     lr_alv_usage       TYPE REF TO if_wd_component_usage,
                  lr_if_controller   TYPE REF TO iwci_salv_wd_table,
                  lr_config          TYPE REF TO cl_salv_wd_config_table,
                  lr_column_settings TYPE REF TO if_salv_wd_column_settings,
                  lt_columns         TYPE        salv_wd_t_column_ref,
                  lr_dropdown        TYPE REF TO CL_SALV_WD_UIE_DROPDOWN_BY_KEY.

  FIELD-SYMBOLS   <fs_column> LIKE LINE OF lt_columns.

" Write code to Instantiate the ALV Component

" Write code to get reference to the ALV model

" To get the dropdowns displayed you need to set the table to editable by using below statement
  lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).

" Get reference to all the ALV's columns in the form of an internal table
  lr_column_settings ?= lr_config.
  lt_columns = lr_column_settings->get_columns( ).

" Loop through the columns & change the cell editors accordingly. In my code below
" I change the columns by name TEMP & TEMP_NEW to dropdowns
LOOP AT lt_columns ASSIGNING <fs_column>.
    IF <fs_column>-id = 'CARRID'.
      CREATE OBJECT lr_link.
      lr_link->set_text_fieldname( <fs_column>-id ).
      <fs_column>-r_column->set_cell_editor( lr_link ).
    ENDIF.

IF <fs_column>-id = 'TEMP'.
      CREATE OBJECT lr_dropdown
        EXPORTING
          selected_key_fieldname = 'TEMP'.
      <fs_column>-r_column->set_cell_editor( lr_dropdown ).
    ENDIF.

    IF <fs_column>-id = 'TEMP_NEW'.
      CREATE OBJECT lr_dropdown
        EXPORTING
          selected_key_fieldname = 'TEMP_NEW'.
      <fs_column>-r_column->set_cell_editor( lr_dropdown ).
    ENDIF.
  ENDLOOP.
uday_gubbala2
Active Contributor
0 Kudos

Hi Vara,

I guess that you intend to achieve the kind of functionality presented in the standard component DEMO_VARIABLE_DROPDOWN. This is a component which displays dropdowns within a table but I guess you intend to achieve similar functionality using an ALV where the user can select different values for the dropdown in different rows. For that kind of functionality you need to go for an DropDownByIdx. Basically you would need to get the references of all the columns using the GET_COLUMNS method. Then you loop them until you are in the pass containing the reference of the desired column. You then just create an instance of a dropdown and set it as the cell editor for that particular column. Try go through the coding below.

Please note that the coding is to achieve the functionality of a DropDownByKey i.e, as soon as the user selects a value in 1 row the value in all other rows also changes accordingly.

Regards,

Uday

aashish_sinha
Active Contributor
0 Kudos

Hi,

I guess u can use class CL_SALV_WD_CONFIG_TABLE and method IF_SALV_WD_STD_FUNCTIONS~SET_GRAPHIC_ALLOWED.

It will Hides/Shows "Display As" Dropdown List Box. I don't know if it will work for whole or one, i have to check it.

Regards

Aashish

Former Member
0 Kudos

Hi,

If you want to have dropdown for a single cell in ALV, then use the CELLVARIANT.

You have to dropdown by index for this. To fill the dropdown is based on your requirement.

You have to get to know the Monthand year to get the days/weeks for that month of a year.

Refer this for cell_variant -

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0e7461d-5e6c-2b10-dda9-9e99df4d...

Regards,

Lekha.

Former Member
0 Kudos

Lekha,

I guess i did not put my requirement in proper way.Here is the way I need in ALV grid cell

http://i624.photobucket.com/albums/tt328/vara_07/image.jpg

All I need is I want to hard code DAYS/WEEKS in the cell.

Rgds

Vara

Former Member
0 Kudos

Hi,

I have some restrictions in opening up your link.

For hardcoding, you need to know the year and mon based on which you can fill the dropdown with that many days and weeks.

You have to fill lt_list type WDR_CONTEXT_ATTR_VALUE_LIST with key and text.

do 31  times.   "31days

lv_index = sy-index.
ls_list-key = lv_index.
ls_list-text = lv_index.
append ls_list to lt_list
clear ls_list.
enddo.

Likewise populate the weeks into table depensing on your requirement.

Refer this link for my reply-

But you have to use the get_columns method of the model object.

If you have to have only for one cell of that columns then you need to also sue the cell variant.

Regards,

Lekha