cancel
Showing results for 
Search instead for 
Did you mean: 

Disable row in ALV .

former_member199126
Participant
0 Kudos

Guys,

I need to make a particular cell in a alv table as read only. Please find the picture

I need to make the check box read only based on the item. IF the item equals 10, it should be readonly. For all others, it should be enabled. Can anyone tell me how to acheive this ?

Thanks,

Karthik

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

I have done this before.

My case was if a field in back end zprev='X' then make that checbox field visible.

For this you need to add readonly attributes in respective node with type ABAP_BOOL

then while populating in ALV TABLE set readonly = 'X' then do code below.

DATA lo_interfacecontroller1 TYPE REF TO iwci_salv_wd_table .
     lo_interfacecontroller1 = wd_this->wd_cpifc_schedule_data( ).
     DATA lo_value TYPE REF TO cl_salv_wd_config_table.
     lo_value = lo_interfacecontroller1->get_model( ).
     DATA : lo_checkbox TYPE REF TO cl_salv_wd_uie_checkbox,
           lr_column TYPE REF TO cl_salv_wd_column.
     DATA:lt_columns TYPE salv_wd_t_column_ref,
           ls_columns TYPE salv_wd_s_column_ref.
     CALL METHOD lo_value->if_salv_wd_column_settings~get_columns
       RECEIVING
         value = lt_columns.

     LOOP AT lt_columns INTO ls_columns.
       CASE ls_columns-id.
         WHEN 'CHECKED'.
           lr_column = ls_columns-r_column.
         WHEN OTHERS.
           EXIT.
       ENDCASE.
     ENDLOOP.
     CREATE OBJECT lo_checkbox
       EXPORTING
         checked_fieldname = 'CHECKED'.
     CALL METHOD lr_column->set_cell_editor
       EXPORTING
         value = lo_checkbox.
     lo_checkbox->set_read_only_fieldname( value = 'READONLY' ).
*Set the table Editable
     lo_value->if_salv_wd_table_settings~set_read_only( value = abap_false ).
*delete column
     CALL METHOD lo_value->if_salv_wd_column_settings~delete_column
       EXPORTING
         id = 'READONLY'.


It was worked perfectly...Thank you

former_member199126
Participant
0 Kudos

Thanks to all the people who helped me . The problem is solved. Unfortunately, i was not able to reply any thing  as it is going for moderators approval. After that my comment is not displayed. I don kno what is the problem.

Former Member
0 Kudos

Hi kartthikeyan,

As suggested by the others above,

1. you need to take a FIELD(edit) type ABAP_BOOL IN THE TABLE CONTEXT.

2.

LOOP AT it into wa where checkbox > 10.

     wa-edit = abap_false.

      modify lt from wa. "transporting checkbox.

    ENDLOOP.

and u need to set the row which u want to hide.

I hope this will solve your problem.

or else u can see this

http://scn.sap.com/docs/DOC-27125

thanks

vijay vikram

Message was edited by: Vijay Vikram

Message was edited by: Vijay Vikram

former_member199126
Participant
0 Kudos

Guys, I need to make the ROW disable, not the column. in the above figure, i need to make the entire row diable if the item equals 10.

guillaume-hrc
Active Contributor
0 Kudos

Hi,

You configure ALV by columns, not by rows. In this case, we make a special processing for ROWS whose ITEM column is equal to 10.

What Swapi explains is right: add a "technical" column (let's call it CHECKBOX_READONLY) in your context that will be responsible for the read-only attribute of the checkbox.

The content of this column is straightforward: if the content of the column ITEM is 10 then it is 'X' otherwise is is SPACE.

Best regards,

Guillaume

former_member210266
Active Participant
0 Kudos

You can use the method

set_read_only_fieldname( 'NAME_OF_THE_COLUMN_FOR_READ_ONLY' ) for all the columns then passing the same column name.That is 'NAME_OF_THE_COLUMN_FOR_READ_ONLY' should be same for all the columns.It will solve your problem.

Former Member
0 Kudos

Karthikeyan Chandrasekaran wrote:

Guys, I need to make the ROW disable, not the column. in the above figure, i need to make the entire row diable if the item equals 10.

Hello Karthikeyan,

  The concept is pretty clear.

  To do any such activity on a paticular cell you need to identify it.

Its same as identification of any cell in two dimentional figure ie. column & then row.

Identify the column on in which the cell resides.

1. Get all the column ref and get the ref of the a prticular
   column


  LR_COLUMN_SETTINGS ?= LV_VALUE.
  LT_COLUMNS = LR_COLUMN_SETTINGS->GET_COLUMNS( ).

  LOOP AT LT_COLUMNS INTO LS_COLUMNS .
    CASE LS_COLUMNS-ID .
      WHEN '< Col- Item >'.

        CREATE OBJECT lr_checkbox
          EXPORTING
            checked_fieldname = '< Col-Item >'.

2. Further there is concept of cell editor which is used to apply condition
   in any particular column. So this will tell to check further condition
   applied on this column before display.

   Also add a new column in your node call 'READ_ONLY' of type WDY_BOOLEAN.
   The value of this field will identify the property value. ( i.e whether
   to enable or disable ).

        ls_columns-r_column->set_cell_editor( lr_checkbox ).
        lr_checkbox->set_enabled_fieldname( 'READ_ONLY' ).

3. Then your rows are nothing but the entries in your table. So evry record
   will be a row and further you need to add your condition to provide value to identify
   to the newly added field.


       Loop at your table.

        If item rq '10'
           New_column = 'X'.
        Else.
           New_column = ' '.
        Endif.

       Endloop.

Further you have to add this to make any modification in table display

    l_value->if_salv_wd_table_settings~set_read_only( value = abap_false ).


I think this will clear your doubt.

Regards,

Monishankar Chatterjee

former_member210266
Active Participant
0 Kudos

Hi

You have to add a new column of type WDY_BOOLEAN in the ALV.

In the ALV configuration method, then for the column corresponding to the checkbox, use the method

  set_read_only_fieldname( 'NAME_OF_THE_COLUMN_FOR_READ_ONLY' ) of the checkbox object.

Hide the column for read only using

  lo_alv->if_salv_wd_column_settings~delete_column( id = ls_column-id ).

Then set the value of the read only column at the initialization or at cell action event of ALV

Regards

Swati

former_member199126
Participant
0 Kudos

Thanks for the help Swati.

   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.
    lr_input->set_read_only_fieldname( value = 'COLUMN_NAME' ).
  ENDLOOP.

apart from the set_read_only_fieldname, we must use the method,

lo_value->if_salv_wd_table_settings~set_read_only( value = abap_false ).

i am wondering why do we need to use this method and set the ALV table as "Editable". We set the row as uneditable inside the loop and by default the ALV is editable. But why is it we are using set_read_only again ... Can you explain ?

former_member210266
Active Participant
0 Kudos

Yes you are right, in order to make an ALV editable, we need to use the method

lo_value->if_salv_wd_table_settings~set_read_only( value = abap_false ).Its for the entire table.

Now its up to you how you customize your ALV by using set_read_only_fieldname. Its basically for cell based operation, but in your case we are using it for the entire row.

Hope it clears you doubt.

Award points if helpful.

former_member199126
Participant
0 Kudos

Swati,

Thanks

Is it possible to enable or disable a single cell in ALV ? If so could you please let me know how to achieve that functionality ?

Karthik

Former Member
0 Kudos

Hi Karthikeyan,

Please check this..

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

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

Cheers,

Kris.