Wednesday, June 1, 2011

Making the ALV column editable


We will have a small example to make one ALV column editable.
for that first create one application with simple editable and for that you can refer to the below link



1. After that go to the main view and there we need to add the interface controller of the used comp ALV as shown below.



Photobucket

Photobucket

Photobucket

Photobucket

2. After that go to the method Wddoinit and there write the code to instantiate the interface controller and component usage. and Use the class CL_SALV_WD_CONFIG_TABLE
and use its method GET_COLUMN to get the column and SET_READ_ONLY to make ALV table editable
and use the SET_EDITOR method to change the editor of the column to INPUT_FIELD.

Here is the code used ...

method WDDOINIT .

data lo_cmp_usage type ref to if_wd_component_usage.

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( ).

DATA lo_value TYPE ref to cl_salv_wd_config_table.
lo_value = lo_interfacecontroller->get_model(
).

*declaring the input field for using it in cell editor of ALV table
data INP type ref to CL_SALV_WD_UIE_INPUT_FIELD.

create object INP
exporting
VALUE_FIELDNAME = 'NAME'. "here give the name of the field to which you want to do the binding.

* Now get the coloum whose cell editor you want to replace.
data col type ref to CL_SALV_WD_COLUMN.
col = lo_value->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'NAME' ).

*Change the cell editor for the column

col->SET_CELL_EDITOR( INP ).

* Make the ALV table editable
lo_value->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( abap_false ).



endmethod.


Photobucket


Photobucket


Photobucket

Photobucket

Photobucket




Photobucket

test the application and we will get the NAME column as editable.

Photobucket


Thanks :)


Gill...

1 comment:

  1. You can also refer the below link...

    http://theabap.blogspot.in/2012/03/making-particular-column-editable-in.html

    ReplyDelete