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: 

row not geting editable

ravi_kumar221
Participant
0 Kudos

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

12 REPLIES 12

0 Kudos

In the 'Field Catalog'

gs_fcat-row_no = 1.

gs_fcat-edit = 'X'.


append gs_fcat to gt_fcat.

Thanks & Regards

0 Kudos

I am getting

The data object "GS_FCAT" has no component called "ROW_NO", but there

is a component called "ROW_POS".

0 Kudos

Hi Ravi Kumar ,

     To make a row editable in ALV use the method set_ready_for_input and set the parameter           i_ready_for_input to '1'.

          If this parameter is set '0' ,row becomes non-editable.

Regards,

Thulja

0 Kudos

how to do code is ther pls hap

Former Member
0 Kudos

Hi,

In your fieldcat gs_fcat make the row_pos = 1 as below.

gs_fcat-row_pos = 1.

gs_fcat-edit = 'X'.

hope this helps.

0 Kudos

not woking

0 Kudos

Hi You can not make the check box as the editable fields.

write your field cat as below.

"Building field catalog

     CLEAR gs_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-edit = 'X'.

     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-edit = 'X'.

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


Hope this helps.

0 Kudos

colum is editable not 1 row

0 Kudos

Yes field CARRID and CARRNAME are editable now.

What is your requirement, what fields do you want to make editable. Checkbox can not be made editable.

0 Kudos

Hope this thread helps you

ALV - Editable grid control

0 Kudos

edit line on select  not all calom

0 Kudos

For that you will have to switch to class based ALV display methods as suggested by Thakur.

Have a look.