Ads

How to Create Editable Column ALV Report

How to Create Editable Column ALV Report in Webdynpro ABAP.

In the previous lesson ,we have learnt ,how to create simple webdynpro ALV report and now let us learn  creating editable column ALV report and what are steps to create and how can we create that report as editable input fields to make changes to ALV report cells. For this scenario ,first of all ,we have to create ALV reports so that we have already created in the last post.

First Step:


Instantiate the used component :

Open the already created wddoinit method of ALV simple report and Go the code wizard symbol and instantiate used component that is ALV component through the F4 help.
How to Create Editable Column ALV Report
The system automatically creates the default code .
How to Create Editable Column ALV Report

Second Step:

Call the method in the used controller:

Select the radio button method call in used cotroller .
How to Create Editable Column ALV Report
Select the interface controller of ALV.
How to Create Editable Column ALV Report
Choose the method Get_model and continue.
How to Create Editable Column ALV Report
The following default code will be created 
How to Create Editable Column ALV Report
Third Step:

We have to access the columns of ALV to make them editable.

Click on the pattern and choose abap objects and continue and enter the class name CL_SALV_WD_CONFIG_TABLE.
How to Create Editable Column ALV Report

Now ,choose the get_colums method of interface if_salv_wd_column_settings.
How to Create Editable Column ALV Report

The following default code will be generated .
How to Create Editable Column ALV Report

The filed id stores the values of the column id.
R_column filed belongs to CL_SALV_WD_COLUMN Which contains methods of ALV column.
Replace object reference 'me' with Object reference lv_value.
CL_SALV_WD_COLUMN  contains the set_cell_editor method which is used to set the type of ui element that column should have.
How to Create Editable Column ALV Report
Using the interface if_salv_wd_table_settings ,call the method set_read_only and set the exporting parameter value as ABAP_FLASE.

 Modify the all default code generated in three steps as below.
 method wddoinit.
data: lo_nd_ekko type ref to if_wd_contet_node,
      lt_ekko type wd_this->elements_ekko.


lo_nd_ekko =wd_context->get_child_node(name = wd_this->wdctx_ekko).

select * from ekko into corresponding fileds of table lt_ekko up to 4 rows.


ld_nd_ekko->bind_table(new_items = lt_ekko set_initial_elements = abap_true).


*Now make the columns editable.

*instantiate the alv used component.

Data lo_cmp_usage type ref to if_wd_component_usage.
lo_cmp_usage->has_active_component()is initial.
lo_cmp_usage->create_component().
endif.

*Call the method in the current controller.

Data lo_interfacecontroller type ref to iwci_salv_wd_table.
lo_interfacecontroller = wd_cpifc_alv().

Data lv_value type ref to cl_salv_wd_config_table. 
lv_value = lo_interfacecontroller->get_model().

*Call the method get_columns of interface if_wd_table_column_settings to change property
of columns.

Data:lt_columns type salv_wd_t_column_ref,
     ls_columns type salv_wd_s_column_ref.

Call Method lv_value->if_salv_wd_column_settings~get_columns.
                 receiving 
                         value = lt_columns.

data lo_bukrs type ref to cl_salv_wd_uie_input_field.

Loop at lt_columns into ls_columns.
case ls_columns-id.
when 'bukrs'.
create object lo_bokrs exporting value_filedname = ls_columns-id.

ls_columns-r_column->set_cell_editor(lo_bukrs).
Endcase.
Endloop.

Call method lv_value->if_salv_wd_table_settings~set_read_only
             Exporting
                 value = abap_false.
Endmethod.
Final output will be looking like in this below image.
How to Create Editable Column ALV Report



Comments

Popular posts from this blog

BADI Interview Questions in SAP ABAP

Sample SAP ABAP Programming Examples for Practice

Module Pool Programming Interview Questions and Answers in SAP ABAP

Step by Step tutorial on BDC Session Method Program in SAP ABAP

SAP ABAP Interview Questions and Answers for 10 Years Experienced