cancel
Showing results for 
Search instead for 
Did you mean: 

Editing single cell in a row of ALV table

Former Member
0 Kudos

Hi Experts,

I need to edit single or double cells in ALV table.

My Requirement is:

I am displaying all the records in a ALV. All the records are in display mode.

Out of all the columns , i have two columns Mod Rank and Tech Rank.

Now my require is to edit that particular columns of the selected record in a ALV.

Now i am able to edit Mod Rank and Tech Rank columns of all the records even though i selected single record in a ALV.

Accepted Solutions (1)

Accepted Solutions (1)

ashish_sharma1
Explorer
0 Kudos

Hello Venkat,

Below thread might be helpful for you.

http://scn.sap.com/thread/884976

Thanks

Ashish Sharma

Former Member
0 Kudos

Hi Ashish,

That thread doesn't represent anything related to edit single cell out of the selected column.

For eq if there are 10 records which consists of 5 columns(fields).

Now i will be selecting a record and of the selected record i would be editing only particlar column. In the link given above all columns are getting in edited mode...

ashish_sharma1
Explorer
0 Kudos

Hello Venkat,

You might find below link helpful I guess this is as per your requirement. This document is from SAP site. I haven't tried it on my system, I hope it works:)

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a...

Thanks,

Ashish Sharma

Former Member
0 Kudos

Hi Ashish,

This link only depicts editing entire colmn.

I dont want to edit entire column, I only want to edit single cell of a particular column of selected recprd....

Former Member
0 Kudos

Hi Venkat,

There is a work around for making an individual cell in your ALV as editable.

1. The column that is to be edited should have a cell editor as Input field (LR_INPUT) . All others should be TextView.

2. Add an attribute sat READ_ONLY to the node that is bound to DATA node of the ALV.

3. Now this attribute should be true or false depending on whether you want that cell in that particular row as Read only or not

4. Use the code lr_input->set_read_only_fieldname( value = 'READ_ONLY' ).

5. Now make the table editable.

Hope this helped.

Former Member
0 Kudos

You can check this link for reference.

http://wiki.sdn.sap.com/wiki/display/WDABAP/How+to+edit+conditionally+row+of+a+ALV+table+in+Web+Dynp...

Here all the cells in the rows are editable because all the cells have cell editor as input field.

You should have cell editor as input field for only those cells that are required to be edited.

Former Member
0 Kudos

Hi Kushboo,

Thanks for your Reply...

I have developed my code which is given below for editing single cell of particular row selected.

But here also i am able to edit the cells which are not selected that means apart from selected row all the columns(which i want) of not selected record getting in edit mode.

DATA:

           l_alv_model               TYPE REF TO cl_salv_wd_config_table,

           lr_column_settings        TYPE REF TO if_salv_wd_column_settings,

           lr_column                 TYPE REF TO cl_salv_wd_column,

           lt_col                    TYPE SALV_WD_T_COLUMN_REF,

           ls_col                    TYPE SALV_WD_S_COLUMN_REF,

           lr_input_field            type ref to cl_salv_wd_uie_input_field.

LOOP AT LT_COL INTO LS_COL.

       CASE LS_COL-ID.

         WHEN 'MODRANK'.

           CREATE OBJECT LR_INPUT_FIELD

             EXPORTING

               VALUE_FIELDNAME = LS_COL-ID.

           lr_input_field->set_read_only_fieldname( 'READ_ONLY' ).

           LS_COL-R_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

         WHEN 'TECHRANK'.

          CREATE OBJECT LR_INPUT_FIELD

             EXPORTING

               VALUE_FIELDNAME = LS_COL-ID.

           lr_input_field->set_read_only_fieldname( 'READ_ONLY' ).

           LS_COL-R_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

       ENDCASE.

*      ls_main-read_only = 'X'.

*      else.

*        ls_main-read_only = ' '.

*    ENDIF.

   ENDLOOP.

   loop at lt_main into ls_main.

     if sy-tabix = lv_index.

        ls_main-read_only = 'X'.

     else.

       ls_main-read_only = ' '.

     endif.

     modify lt_main from ls_main.

   endloop.

lo_nd_main->bind_table( lt_main ).

Former Member
0 Kudos

Hi,

Have you tried debugging and checked that Read Only values are set properly. Check your node in debugging mode if only the rows that are to be edited have the value Abap_false and all other have abap_true.

Also, Can you also try filling READ_ONLY attribute of the node before hand only and not after all the configuration. i.e. modify your internal table LT_MAIN before binding it to the node for the first time itself.

The link to the article has very nicely mentioned how to work with this and it works. The only thing i think is the sequence of your code. After configuration you are changing the READ_ONLY attribute.

Please check this sequence.

Former Member
0 Kudos

Hi Kushboo,

I was able to edit for single cell for the selected row.

I will also post my code below...so that it will be useful to other people..

In the below code i am editing two columns MOD_RANK and TECH_RANK.

These two columns will be in edit mode once after selecting the required record

DATA: LO_ND_MAIN TYPE REF TO IF_WD_CONTEXT_NODE,

         LO_EL_MAIN TYPE REF TO IF_WD_CONTEXT_ELEMENT,

         LS_MAIN TYPE WD_THIS->ELEMENT_MAIN,

         LT_MAIN TYPE WD_THIS->ELEMENTS_MAIN,

         LV_INDEX TYPE I.

*navigate from <CONTEXT> to <MAIN> via lead selection

   LO_ND_MAIN = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_MAIN ).

*

*   get element via lead selection

   LO_EL_MAIN = LO_ND_MAIN->GET_ELEMENT( ).

*

* get all declared attributes

   LO_EL_MAIN->GET_STATIC_ATTRIBUTES(

     IMPORTING

       STATIC_ATTRIBUTES = LS_MAIN ).

*

*  "To get the main internal table

   LO_ND_MAIN->GET_STATIC_ATTRIBUTES_TABLE(

   IMPORTING

     TABLE = LT_MAIN ).

   LV_INDEX = LO_ND_MAIN->GET_LEAD_SELECTION_INDEX(  ).

   DATA: L_ALV_MODEL    TYPE REF TO CL_SALV_WD_CONFIG_TABLE,

         LR_COLUMN_SETTINGS TYPE REF TO IF_SALV_WD_COLUMN_SETTINGS,

         LR_COLUMN     TYPE REF TO CL_SALV_WD_COLUMN,

         LT_COL        TYPE SALV_WD_T_COLUMN_REF,

         LS_COL        TYPE SALV_WD_S_COLUMN_REF,

         LR_INPUT_FIELD TYPE REF TO CL_SALV_WD_UIE_INPUT_FIELD.

   DATA   L_REF_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE.

          L_REF_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ALV( ).

          L_ALV_MODEL = L_REF_INTERFACECONTROLLER->GET_MODEL( ).

          L_ALV_MODEL->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( ABAP_FALSE ).

   LR_COLUMN_SETTINGS ?= L_ALV_MODEL.

   LT_COL = LR_COLUMN_SETTINGS->GET_COLUMNS( ).

   LOOP AT LT_MAIN INTO LS_MAIN.

     IF SY-TABIX = LV_INDEX.

       LS_MAIN-READ_ONLY = ' '.

     ELSE.

       LS_MAIN-READ_ONLY = 'X'.

     ENDIF.

     MODIFY LT_MAIN FROM LS_MAIN.

   ENDLOOP.

   LOOP AT LT_COL INTO LS_COL.

     CASE LS_COL-ID.

       WHEN 'MODRANK'.

         CREATE OBJECT LR_INPUT_FIELD

           EXPORTING

             VALUE_FIELDNAME = LS_COL-ID.

         LR_INPUT_FIELD->SET_READ_ONLY_FIELDNAME( 'READ_ONLY' ).

         LS_COL-R_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

       WHEN 'TECHRANK'.

         CREATE OBJECT LR_INPUT_FIELD

           EXPORTING

             VALUE_FIELDNAME = LS_COL-ID.

         LR_INPUT_FIELD->SET_READ_ONLY_FIELDNAME( 'READ_ONLY' ).

         LS_COL-R_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

     ENDCASE.

   ENDLOOP.

   LO_ND_MAIN->BIND_TABLE( LT_MAIN ).

   CLEAR LV_INDEX.

I have one more doubt in ALV component where i have to select multiple records at a time

In ordinary table we will set in Property of the layout, in ALV where will do?

Answers (0)