cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Grid and a Drop-Down column

Former Member
0 Kudos

Hi All,

Currently I'm working on a Web Dynpro ABAP component where I'm display several columns of data within an ALV Grid.

I have made two of the columns input fields so the User can update the back-end tables. I want to made these two columns not only input fields, but I want them to have "Drop Down" capability (Value and Text) so that the User can pick only standard values.

Does anyone have any sample code I could use.

Thank you in Advance.

Paul

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Yes, this works. Thank you for your help.

Paul

Former Member
0 Kudos

Hi,

Try this code.

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 = 1.
   WA-VALUE = 'AAA'.
   APPEND WA TO ITAB.
   
* navigate from <CONTEXT> to <DD> via lead selection
  lo_nd_dd = wd_context->get_child_node( name = wd_this->wdctx_dd ). " GET NODE
 
* get element via lead selection
*  lo_el_dd = lo_nd_dd->get_element(  ).
 
* get node info
  lo_node_info_dd = lo_nd_dd->get_node_info( ). " GET NODE INFO
 
* get all declared attributes
  lo_node_info_dd->SET_ATTRIBUTE_VALUE_SET(    " BIND NODE INFO WITH ITAB VALUES
      name = 'DROP'
      value_SET = ITAB  ).

Here DD is node name and DROP is attribute inside node.

For selecting value from this node assign event to this node.

Regards

Vishnu Gupta

uday_gubbala2
Active Contributor
0 Kudos

Hi Paul,

I can send you a properly formatted document with snapshots if you are facing any problems understanding the distorted code which I have pasted above. just pass on your maid id if you need.

Regards,

Uday

uday_gubbala2
Active Contributor
0 Kudos

Hi Paul,

I dont think that you can provide the capability of both the input field & dropdown to the same columns. (Coz using input fields you should be able to enter any value you wish whereas using a dropdown you can enter a value from within the value set specified.) If you want to create a dropdown within your ALV columns then just go through the code snippet below:

I have a context node by name NODE with the attributes from SFLIGHT. I have 2 additional attributes TEMP & TEMP_NEW under the same node. I have typed them with my custom data element so that they can use the value range defined at the domain level. My task is to display these 2 columns TEMP & TEMP_NEW as dropdowns with the permissible values coming from their associated domains.

Regards,

Uday

METHOD build_alv .

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_link TYPE REF TO cl_salv_wd_uie_link_to_action,

lr_checkbox TYPE REF TO cl_salv_wd_uie_checkbox,

lr_image TYPE REF TO cl_salv_wd_uie_image,

lr_dropdown TYPE REF TO CL_SALV_WD_UIE_DROPDOWN_BY_KEY.

FIELD-SYMBOLS

<fs_column> LIKE LINE OF lt_columns.

  • Instantiate the ALV Component

lr_alv_usage = wd_this->wd_cpuse_alv( ).

IF lr_alv_usage->has_active_component( ) IS INITIAL.

lr_alv_usage->create_component( ).

ENDIF.

  • Get reference to model

lr_if_controller = wd_this->wd_cpifc_alv( ).

lr_config = lr_if_controller->get_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 ).

  • Set the UI elements.

lr_column_settings ?= lr_config.

lt_columns = lr_column_settings->get_columns( ).

    • You can use the below commented approach to fill the dropdowns instead of using a custom domain

  • data: lr_node_info type ref to if_wd_context_node_info,

  • lr_node type ref to if_wd_context_node,

  • wa_value_set type wdr_context_attr_value,

  • lt_value_set type table of wdr_context_attr_value.

*

  • lr_node = wd_context->get_child_node( name = 'NODE' ).

  • lr_node_info = lr_node->get_node_info( ).

  • wa_value_set-value = '1'.

  • wa_value_set-text = 'One'.

  • insert wa_value_set into table lt_value_set.

*

  • wa_value_set-value = '2'.

  • wa_value_set-text = 'Two'.

  • insert wa_value_set into table lt_value_set.

*

  • wa_value_set-value = '3'.

  • wa_value_set-text = 'Three'.

  • insert wa_value_set into table lt_value_set.

*

  • lr_node_info->set_attribute_value_set( name = 'TEMP'

  • value_set = lt_value_set ).

**********************************************************************************

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.

ENDMETHOD.

arjun_thakur
Active Contributor
0 Kudos

Hi Paul,

Refer standard component: SALV_WD_TEST_TABLE_EVENTS,

I hope it helps.

Regards

Arjun