Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Checkbox should be grayed out in alv once you select it and press save button

Former Member
0 Kudos

Hi all,

I'm displaying a alv and once of the fields(chk) is a checkbox. I need to gray out the checkbox once i select it and press save. It should be editable again only if we execute the report all over.

I'm using REUSE_ALV_GRID_DISPLAY.

Thanks in advance.

3 REPLIES 3

omer_sakar
Participant
0 Kudos

Hi Sarayu,

There is standard demo report : BCALV_TEST_FULLSCREEN ,you can find how to do it.

0 Kudos

Hi Omer,

I wasn't able to figure out. Can you please share a sample code?

Thank you

0 Kudos

You can add below codes :

Step 1 : Before first display alv, set fieldcat-edit = 'X'.

Step 2 : set parameter i_callback_user_command = 'USER_COMMAND' of REUSE_ALV_GRID_DISPLAY 

Step 3 : 
FORM user_command USING r_ucomm LIKE sy-ucomm

                        rs_selfield TYPE slis_selfield.
 DATA :ref_grid TYPE REF TO cl_gui_alv_grid.
 WHEN 'SAVE'.

      LOOP AT gt_fieldcat INTO gs_fieldcat.
        CASE gs_fieldcat-fieldname.
          WHEN 'CHK'.
           gs_fieldcat-edit = ''.
            MODIFY gt_fieldcat FROM gs_fieldcat.
        ENDCASE.
      ENDLOOP.
  ENDCASE.


CALL FUNCTION 'LVC_TRANSFER_FROM_SLIS'
  EXPORTING
    it_fieldcat_alv       = gt_fieldcat"first fieldcatalog CHK is editable
 IMPORTING
 ET_FIELDCAT_LVC       = gt_fieldcat2"second fieldcatalog CHK is noneditable
  tables
    it_data               = gt_report" internal table as displayed
* EXCEPTIONS
*   IT_DATA_MISSING       = 1
*   OTHERS                = 2
          .

  IF ref_grid IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        e_grid = ref_grid.
  ENDIF.

  IF NOT ref_grid IS INITIAL.
    CALL METHOD ref_grid->set_frontend_fieldcatalog
     EXPORTING
        it_fieldcatalog = gt_fieldcat2
       .

    CALL METHOD ref_grid->check_changed_data .
  ENDIF.

rs_selfield-refresh = 'X'.

endform.