Skip to Content

This document help you to edit particular cell in ALV .

Execute SE80 transaction. Create Web Dynpro Component and add alv in used component in web dynpro component.

1alv.PNG

Create node in context of the component controller. In node one of the EDIT attribute should be type WDY_BOOLEAN.

2alv.PNG

3alv.PNG

Copy and map context node MARA and  from the component controller’s context to the context of view as shown below.

4alv.PNG

In Layout of Main View ,insert VIEW_CONTAINER_UIEELEMENT name it as view as shown below

5alv.PNG

Add the used component in the view properties

6alv.PNG

Add the code in WDDOINT method of view

method WDDOINIT .

   DATA lo_nd_mara TYPE REF TO if_wd_context_node.
   DATA ls_mara TYPE wd_this->Element_mara.
   DATA lt_mara TYPE wd_this->Elements_mara.

   lo_nd_mara = wd_context->get_child_node( name = wd_this->wdctx_mara ).

SELECT matnr ernam FROM mara
     INTO CORRESPONDING FIELDS OF TABLE lt_mara UP TO 4 ROWS.

LOOP AT lt_mara INTO ls_mara .
   IF ls_maramatnr > 50.
       ls_maraedit = .“abap_false.
     ELSE.
       ls_maraedit = ‘X’. “abap_true.
     ENDIF.
    MODIFY lt_mara from ls_mara TRANSPORTING edit.
ENDLOOP.

   lo_nd_mara->bind_table( new_items = lt_mara set_initial_elements = abap_false ).

   DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
   DATA lr_column    TYPE REF TO cl_salv_wd_column.

   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 lv_value TYPE REF TO cl_salv_wd_config_table.
   lv_value = lo_interfacecontroller->get_model(
   ).

   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 : lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.

   LOOP AT lt_columns INTO ls_columns.
     lr_column = ls_columnsr_column.

     CASE ls_columnsid.
      WHEN ‘MATNR’.
         CREATE OBJECT lr_input_field
           EXPORTING
             value_fieldname = ls_columnsid.

         lr_column->set_cell_editor( value = lr_input_field ).
         lr_input_field->set_read_only_fieldname( value = ‘EDIT’ ).
     ENDCASE.
   ENDLOOP.

DATA: lr_table_settings TYPE REF TO if_salv_wd_table_settings.
lr_table_settings ?= lv_value.
lr_table_settings->set_read_only( abap_false ).

lv_value->if_salv_wd_column_settings~delete_column( id = ‘EDIT’ ).

endmethod.


Set data to ALV for display (via reverse context mapping).

The selected flights are inside context node MARA. To display them in the

ALV it is necessary to map the context node MARA to the context node

DATA of the ALV interface controller. 

Open your Web Dynpro component’s node Component Usages -> ALV ->

INTERFACECONTROLLER_USAGE. 

7alv.PNG

lick on the Controller Usage button. The component controller of your Web Dynpro

component appears on the right side of the screen.

Map context node MARA of your Web Dynpro component to context DATA

of the interface controller of the ALV component.

8alv.PNG

Go to Window Embed view TABLE of component SALV_WD_TABLE into MAINVIEW.

To embed the ALV table into the MAINVIEW, go to the window MAIN and switch to

tab page window. Embed the ALV view TABLE to view container TABLE by choosing the

context menu entry embed view. A popup appears. Use the F4 help and select the

following entry.

9alv.PNG

Create the web dynpro application.Save & activate the web dynpro component.

Test Your Web Dynpro Application

The result will look like the following:

10alv.PNG


To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply