Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

row not geting editable

help row is not getting editable

REPORT ZTEST2366.

TYPE-POOLS: slis.

TYPES: BEGIN OF ty_scarr,

           checkbox   TYPE c,

           carrid         TYPE scarr-carrid,

           carrname    TYPE scarr-carrname,

           color(4)       TYPE c"Field for the color of the row

         END OF ty_scarr.

DATAgt_scarr    TYPE STANDARD TABLE OF ty_scarr,

         gs_scarr    TYPE ty_scarr,

         gt_fcat     TYPE slis_t_fieldcat_alv,

         gs_fcat     TYPE slis_fieldcat_alv,

         gs_layout   TYPE slis_layout_alv,

         gv_repid    TYPE syrepid,

         gv_color(1) TYPE c VALUE '1'.

START-OF-SELECTION.

    gv_repid = sy-repid.

    SELECT carrid carrname

      FROM scarr

      INTO CORRESPONDING FIELDS OF TABLE gt_scarr.

    "The loop changes the color of the rows in the ALV

    LOOP AT gt_scarr INTO gs_scarr.

      "There are only 7 color we can use

      IF gv_color = 8.

        gv_color = 1.

      ENDIF.

       "The field must have the content like 'C110', 'C120',....

      CONCATENATE 'C'

                  gv_color

                  '10'

             INTO gs_scarr-color.

      MODIFY gt_scarr FROM gs_scarr.

      gv_color = gv_color + 1.

    ENDLOOP.

    "Building field catalog

    CLEAR gs_fcat.

    gs_fcat-row_pos = 0.

    gs_fcat-edit = 'X'.

    APPEND gs_fcat TO gt_fcat.

    gs_fcat-fieldname  = 'CHECKBOX'.

    gs_fcat-seltext_m  = 'Select'.

    gs_fcat-checkbox  = 'X'.

    gs_fcat-hotspot     = 'X'.

    APPEND gs_fcat TO gt_fcat.

    CLEAR gs_fcat.

    gs_fcat-fieldname     = 'CARRID'.

    gs_fcat-ref_tabname   = 'SCARR'.

    gs_fcat-ref_fieldname = 'CARRID'.

    APPEND gs_fcat TO gt_fcat.

    CLEAR gs_fcat.

    gs_fcat-fieldname     = 'CARRNAME'.

    gs_fcat-ref_tabname   = 'SCARR'.

    gs_fcat-ref_fieldname = 'CARRNAME'.

    APPEND gs_fcat TO gt_fcat.

    "Layout information for the ALV

    gs_layout-colwidth_optimize = 'X'.

    gs_layout-info_fieldname    = 'COLOR'.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

      EXPORTING

        i_callback_program           = gv_repid

        i_callback_user_command = 'USER_COMMAND'

        is_layout                          = gs_layout

        it_fieldcat                         = gt_fcat

      TABLES

        t_outtab                           = gt_scarr.

*&---------------------------------------------------------------------*

*&      Form  user_command

*&---------------------------------------------------------------------*

*   Form for user actions on the ALV

*----------------------------------------------------------------------*

FORM user_command USING r_ucomm LIKE sy-ucomm

                          rs_selfield TYPE slis_selfield.

     "Reference to the ALV grid object

    DATA: lr_grid TYPE REF TO cl_gui_alv_grid.

    READ TABLE gt_scarr INTO gs_scarr INDEX rs_selfield-tabindex.

    "Modifying the selected row - we modify the checkbox and the color.

    gs_scarr-checkbox = 'X'.

    gs_scarr-color    = 'C810'.

    MODIFY gt_scarr FROM gs_scarr INDEX rs_selfield-tabindex.

    "Getting the reference to teh ALV grid

    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

      IMPORTING

        e_grid = lr_grid.

    "Calling method to refresh the data in the ALV

    CALL METHOD lr_grid->refresh_table_display.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

      EXPORTING

        i_callback_program           = gv_repid

        i_callback_user_command = 'USER_COMMAND'

        is_layout                          = gs_layout

        it_fieldcat                         = gt_fcat

      TABLES

        t_outtab                           = gt_scarr.

ENDFORM.                    "user_command

Not what you were looking for? View more on this topic or Ask a question