cancel
Showing results for 
Search instead for 
Did you mean: 

DropdownbyKey -Defaulting value

Former Member
0 Kudos

Hi,

I am displaying dropdown in ALV grid by Dropdownkey.It shows up when I press arrow but I want to default it to one value everytime.

Like 'DAY' should be defaulted.How do we do that?

DATA lo_nd_dd TYPE REF TO if_wd_context_node.
  DATA lo_el_dd TYPE REF TO if_wd_context_element.
  DATA lo_node_info_dd TYPE REF TO if_wd_context_node_info.
*  data: wa type wdr_context_attr_value,
*        itAB type table of wdr_context_attr_value.
  TYPES: BEGIN OF tt,
         name TYPE string,
         value TYPE string,

         END OF tt.

  DATA: itab TYPE TABLE OF tt,
        wa TYPE tt.



  wa-name = 'DAY'.
  wa-value = 'DAY'.
  APPEND wa TO itab.

  wa-name = 'WEEK'.
  wa-value = 'WEEK'.
  APPEND wa TO itab.



DATA: lr_dropdown        TYPE REF TO cl_salv_wd_uie_dropdown_by_key.
        CREATE OBJECT lr_dropdown
          EXPORTING
            selected_key_fieldname = 'DUOMEA'.
        ls_columns-r_column->set_cell_editor( lr_dropdown ).


        lo_node_info_dd->set_attribute_value_set(    " BIND NODE INFO WITH ITAB VALUES
            name = 'DUOMEA'
            value_set = itab  ).

			

Rgds

vara

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can set default value directly at sttribute level, Goto Content->Node->select the attribute and scroll at the bottom and set the Default value as 'DAY'.

Regards,

Radhika.

Former Member
0 Kudos

Raja sekhar,

I have tried

lo_nd_alv_data->set_attribute(
                  value  = 'DAYS'
                  name   = 'DUOMEA').

but I get a dump as

Node COMPONENTCONTROLLER.1.ALV_DATA does not contain any elements

Radhika,

DEFAULT option is only working on Input fields but it doesn't work for ALV grid -Dropdown Cell.

Do we have any other option?

Here is how I mainted attributes.

Attribute Name DUOMEA

Type assignment Type

Type ZSCH-DUOMEA -- this is of char 10

Read-only 0

Default Value 'DAYS'

Null Value 0

Input Help Mode Automatic

Determined Input Help

Type of Input Help

Formatting

Compression Default Value

Rgds

vara

Former Member
0 Kudos

Hi Vara

defaulting a value for a dropdown by key is not possible , it is only possible through dropdown by index.

or if it is a input field it can be defaulted as radhika said.

try with the dropdown by index

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You don't set the default value at the node level, but at the element level. Consider updating the internal table with the default values before you even do a bind_Table.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Hi Vara

>

> defaulting a value for a dropdown by key is not possible , it is only possible through dropdown by index.

> or if it is a input field it can be defaulted as radhika said.

> try with the dropdown by index

That is not correct. Of course you can set a default value for a DDLBbyKey. You just need to set the default value into the attribute of the element that the DLLB is bound to.

Former Member
0 Kudos

Thomas,

Updating Internal table did the trick.

Thank you.Awarded full points.

rgds

vara

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

To achieve this, you will have to set the context attribute value to 'DAY' and this value will be shown as defalut in the dropdown.

lo_node_info_dd->set_attribute( name = 'DUOMEA' value = 'DAY' ).

Regards,

Manne.