cancel
Showing results for 
Search instead for 
Did you mean: 

Editing values within Dynamic ALV

Former Member
0 Kudos

Hello All,

I am currently working on dynamic ALV and want the columns to be editible.

I have gone through the tutorial

Link : [https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4c70444a-0801-0010-7688-9e4bd844b783]

and have created a dynamic Context and a corresponding ALV LIST display. Everything is fine except that i want to be able to edit values within the list and i want this to get populated back into the context.

I have gone through the tutorial.

Link : [https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1]

But i couldn't relate that with the tutorial for dynamic ALV.

Please help.

Best Regards,

Mz

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hello Lekha,

Thanks for your inputs.

I solved the problem using the following code.......


DATA:
   lo_value type ref to cl_salv_wd_config_table,
     lr_column      TYPE REF TO cl_salv_wd_column,            " Table fo rcolumn ref
     ls_columns     TYPE salv_wd_s_column_ref,                " Structure for column ref
    lt_columns     TYPE salv_wd_t_column_ref,                " Structure for column ref
   lr_input       TYPE REF TO cl_salv_wd_uie_input_field.
DATA: l_value TYPE REF TO cl_salv_wd_config_table,
      lr_column_settings TYPE REF TO if_salv_wd_column_settings,
      lr_table_settings type ref to if_salv_wd_table_settings.

l_value = lo_interfacecontroller->get_model( ).

* Get the column ref
  CALL METHOD l_value->if_salv_wd_column_settings~get_columns
    RECEIVING
      value = lt_columns.

  LOOP AT lt_columns INTO ls_columns.
    lr_column = ls_columns-r_column.

        CREATE OBJECT lr_input
          EXPORTING
            value_fieldname = ls_columns-id.
        CALL METHOD lr_column->set_cell_editor
          EXPORTING
            value = lr_input.
*     Set the read only attribute
  lr_table_settings ?= l_value.                                     <-------------------------------------
  lr_table_settings->set_read_only( abap_false ).      <------------------------------------
 endloop.

Thanks a lot for your help. Points awarded

Mz

Former Member
0 Kudos

Hello Lekha,

I am sorry to say that the code which you have provided is not working.

Maybe i am doing something wrong.

This is the entire code below.



data lo_interfacecontroller type ref to iwci_salv_wd_table .
data lo_cmp_usage type ref to if_wd_component_usage.
data : L_VIEW_CONTROLLER_API type ref to IF_WD_VIEW_CONTROLLER.
lo_cmp_usage =   wd_this->wd_cpuse_alv( ).
if lo_cmp_usage->has_active_component( ) is initial.
  lo_cmp_usage->create_component( ).
endif.

lo_interfacecontroller =   wd_this->wd_cpifc_alv( ).

  lo_interfacecontroller->set_data(
*   only_if_new_descr =                 " wdy_boolean
    "r_node_data =
    dyn_node                    " ref to if_wd_context_node
  ).

********************
DATA:
   lo_value type ref to cl_salv_wd_config_table,
     lr_column      TYPE REF TO cl_salv_wd_column,            " Table fo rcolumn ref
     ls_columns     TYPE salv_wd_s_column_ref,                " Structure for column ref
    lt_columns     TYPE salv_wd_t_column_ref,                " Structure for column ref
   lr_input       TYPE REF TO cl_salv_wd_uie_input_field.


lo_value = lo_interfacecontroller->get_model( ).

* Get the column ref
  CALL METHOD lo_value->if_salv_wd_column_settings~get_columns
    RECEIVING
      value = lt_columns.

  LOOP AT lt_columns INTO ls_columns.
    lr_column = ls_columns-r_column.
case ls_columns-id.

when 'JAN2007'.

        CREATE OBJECT lr_input
          EXPORTING
            value_fieldname = ls_columns-id.
        CALL METHOD lr_column->set_cell_editor
          EXPORTING
            value = lr_input.
*     Set the read only attribute
        lr_input->set_read_only_fieldname( value = 'FALSE' ).
endcase.
 endloop.
*
**********************


L_VIEW_CONTROLLER_API = WD_THIS->WD_GET_API( ).
L_VIEW_CONTROLLER_API->PREPARE_DYNAMIC_NAVIGATION(
source_window_name = 'WINDOW1'
source_vusage_name = 'MAIN_USAGE_0'
source_plug_name = 'TO_V1'
target_component_name = 'SALV_WD_TABLE'
target_component_usage = 'ALV'
target_view_name = 'TABLE'
target_plug_name = 'DEFAULT'
target_embedding_position = 'MAIN/VIEW_CONTAINER'
 ).

WD_THIS->FIRE_TO_V1_PLG( ).

The part which is entered as per your instructions are given between the asterisk lines.

Sorry if there are any silly mistakes on my part.

I have one small doubt regarding the value to be passed for the method lr_input->set_read_only_fieldname. This is a string value. I think that this could be the cause of the error. When i checked the class interface, CL_SALV_WD_UIE_INPUT_FIELD i found that the method set_read_only_fieldname is calling another attribute if_salv_wd_c_table_evt_editor=>set_read_only_fieldname.

Hope this was useful

Best Regards,

Mz

Former Member
0 Kudos

Hi,

Sorry,

You have to use SET_READ_ONLY as abap_false instead of SET_READ_ONLY_FIELDNAME.

lr_input->set_read_only( value = abap_false ).

Regards,

Lekha.

Former Member
0 Kudos

Hello Lekha,

Thanks for your speedy reply.

i have changed the method as specified by you and executed.

Its still not coming up.

I used debugger and found that the statements were being executed perfectly within the case statment.

Maybe the function module which i call after setting the property is not correct.


L_VIEW_CONTROLLER_API = WD_THIS->WD_GET_API( ).
L_VIEW_CONTROLLER_API->PREPARE_DYNAMIC_NAVIGATION(
source_window_name = 'WINDOW1'
source_vusage_name = 'MAIN_USAGE_0'
source_plug_name = 'TO_V1'
target_component_name = 'SALV_WD_TABLE'
target_component_usage = 'ALV'
target_view_name = 'TABLE'
target_plug_name = 'DEFAULT'
target_embedding_position = 'MAIN/VIEW_CONTAINER'
 ).

Mz

Former Member
0 Kudos

Hello Lekha,

I am getting an error at the statement


* Get the column ref
  CALL METHOD lo_value->if_salv_wd_column_settings~get_columns
    RECEIVING
      value = lt_columns.

The type of LT_COLUMNS cannot be converted to the type of "VALUE".

Former Member
0 Kudos

Hi,

lt_columns     TYPE salv_wd_T_column_ref, "table type.

Please check the cl_salv_wd_config_table for the same method if you have any errors.

Regards,

Lekha.

Former Member
0 Kudos

Lekha,

Suppose i have a table with colums c1 c2 and c3, i would like to make all cells under columns c2 and c3 editable and all cells under c1 read-only

This is the part of code i used for alv display



data lo_cmp_usage type ref to if_wd_component_usage.
data : L_VIEW_CONTROLLER_API type ref to IF_WD_VIEW_CONTROLLER.
lo_cmp_usage =   wd_this->wd_cpuse_alv( ).
if lo_cmp_usage->has_active_component( ) is initial.
  lo_cmp_usage->create_component( ).
endif.

data lo_interfacecontroller type ref to iwci_salv_wd_table .
lo_interfacecontroller =   wd_this->wd_cpifc_alv( ).

  lo_interfacecontroller->set_data(
*   only_if_new_descr =                 " wdy_boolean
    "r_node_data =
    dyn_node                    " ref to if_wd_context_node
  ).


L_VIEW_CONTROLLER_API = WD_THIS->WD_GET_API( ).
L_VIEW_CONTROLLER_API->PREPARE_DYNAMIC_NAVIGATION(
source_window_name = 'ZWINDOW1'
source_vusage_name = 'MAIN_USAGE_0'
source_plug_name = 'TO_V1'
target_component_name = 'SALV_WD_TABLE'
target_component_usage = 'ALV'
target_view_name = 'TABLE'
target_plug_name = 'DEFAULT'
target_embedding_position = 'MAIN/VIEW_CONTAINER'
 ).

WD_THIS->FIRE_TO_V1_PLG( )

Former Member
0 Kudos

HI,

After you SET the data to the node, I guess you will have the model object reference also(cl_salv_wd_config_table).

lo_interfacecontoller.........set_data.

After the above statement. Get the model node.

DATA:
   lo_value type ref to cl_salv_wdconfig_table,
     lr_column      TYPE REF TO cl_salv_wd_column,            " Table fo rcolumn ref
     ls_columns     TYPE salv_wd_s_column_ref,                " Structure for column ref
    lt_columns     TYPE salv_wd_s_column_ref,                " Structure for column ref
   lr_input       TYPE REF TO cl_salv_wd_uie_input_field.


lo_value = lo_inerfacecontroller->get_model( ).

* Get the column ref
  CALL METHOD lo_value->if_salv_wd_column_settings~get_columns
    RECEIVING
      value = lt_columns.

  LOOP AT wd_comp_controller->gref_columns INTO ls_columns.
    lr_column = ls_columns-r_column.
case ls_columns->id.

when 'c2'.

        CREATE OBJECT lr_input
          EXPORTING
            value_fieldname = ls_columns->id.
        CALL METHOD lr_column->set_cell_editor
          EXPORTING
            value = lr_input.
*     Set the read only attribute
        lr_input->set_read_only_fieldname( value = abap_false ).
when 'c3'.
        CREATE OBJECT lr_input
          EXPORTING
            value_fieldname = ls_columns->id.
        CALL METHOD lr_column->set_cell_editor
          EXPORTING
            value = lr_input.
    lr_input->set_read_only_fieldname( value = abap_false ).
endcase.
 endloop.

Above code, c2 and c3 the inputs fieilds will be there. C1 nothing you have to do.

Regards,

Lekha.

Edited by: Lekha on Sep 4, 2009 8:19 PM

Former Member
0 Kudos

Hello Lekha,

I want the entire table to be editable except for a few columns.

Please let me know if you require further info.

Thanks

Mz

Former Member
0 Kudos

Hi,

Few columns or for few cells in some rows.

Regards,

Lekha.

Former Member
0 Kudos

Hi,

When you show the ALV for 1st time then you want to show some rows are eidtable or entire table.

Regards,

Lekha.