Skip to Content

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

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Feb 17, 2017 at 02:51 PM

    Hi Sarayu,

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

    Add comment
    10|10000 characters needed characters exceeded

    • 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.