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: 

set specific rows in ALV grid ready for input

Former Member
0 Kudos

Hi everyone,

I have a question about how to set specific rows in ALV grid ready for input.

I know that I can make some columns ready for input before the ALV displayed,but I have no idea how to make specific rows displayed in the ALV ready for input.

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello Aaron

For editable columns we can use the fieldcatalog (LVC_S_FCAT-EDIT = 'X') but for rows you need to define editability on cell level.

The required steps are documented in sample report BCALV_EDIT_02. Below I point out a few crucial points:


*§1.Extend your output table for a field, e.g., CELLTAB, that holds
*   information about the edit status of each cell for the
*   corresponding row (the table type is SORTED!).
DATA: BEGIN OF gt_outtab occurs 0.  "with header line
        include structure sflight.
DATA: celltab type LVC_T_STYL.
DATA: END OF gt_outtab.


*§3.Provide the fieldname of the celltab field by using field
*   STYLEFNAME of the layout structure.
   gs_layout-stylefname = 'CELLTAB'.

   CALL METHOD grid1->set_table_for_first_display
         EXPORTING i_structure_name = 'SFLIGHT'
                   is_layout        = gs_layout
         CHANGING  it_outtab        = gt_outtab[].

Note: in the sample report only field SEATSMAX is editable. In your case you need

to fill CELLTAB for all fields in a row.


*§2.After selecting data, set edit status for each row in a loop
*   according to field SEATSMAX.
  LOOP AT gt_outtab.
    l_index = sy-tabix.
    refresh lt_celltab.
    if gt_outtab-seatsmax ge 300.
        perform fill_celltab using 'RW'
                             changing lt_celltab.
    else.
        perform fill_celltab using 'RO'
                             changing lt_celltab.
    endif.
*§2c.Copy your celltab to the celltab of the current row of gt_outtab.
    INSERT LINES OF lt_celltab INTO TABLE gt_outtab-celltab.
    MODIFY gt_outtab INDEX l_index.
  ENDLOOP.
ENDFORM.                               " SELECT_DATA_AND_INIT_STYLE

NOTE: LVC_T_STYL is a SORTED table type. Thus, take care that you are using the

INSERT ... INTO TABLE statement and not APPEND (because then nothing is appended

to the CELLTAB itab).


  IF p_mode EQ 'RW'.
*§2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
*    to status "editable".
    l_mode = cl_gui_alv_grid=>mc_style_enabled.
  ELSE. "p_mode eq 'RO'
*§2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell
*    to status "non-editable".
    l_mode = cl_gui_alv_grid=>mc_style_disabled.
  ENDIF.

  ls_celltab-fieldname = 'SEATSMAX'.
  ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
  INSERT ls_celltab INTO TABLE pt_celltab.

Regards

Uwe

4 REPLIES 4

former_member451655
Active Participant
0 Kudos

hi ,

You want to Edit ALV Grid Cells After it Displayed ?? it its the case you can use somethin like Below

wa_fieldcat-edit = 'X'. pass this value to the Field Catalog editable Field. hope you are using "REUSE_ALV_GRID_DISPLAY" to Display the ALV , there you have to mention the i_callback_user_command = 'USER_COMMAND' parameter and capture the changes you made over the Editable ALV Field

Br,

Dilum alawatte

0 Kudos

hi,

I mean rows not cells . horizontal not vertical.

0 Kudos

Hi,

plus: I'm using the class cl_gui_alv_grid,not the function module "reuse_alv_grid_display".

uwe_schieferstein
Active Contributor
0 Kudos

Hello Aaron

For editable columns we can use the fieldcatalog (LVC_S_FCAT-EDIT = 'X') but for rows you need to define editability on cell level.

The required steps are documented in sample report BCALV_EDIT_02. Below I point out a few crucial points:


*§1.Extend your output table for a field, e.g., CELLTAB, that holds
*   information about the edit status of each cell for the
*   corresponding row (the table type is SORTED!).
DATA: BEGIN OF gt_outtab occurs 0.  "with header line
        include structure sflight.
DATA: celltab type LVC_T_STYL.
DATA: END OF gt_outtab.


*§3.Provide the fieldname of the celltab field by using field
*   STYLEFNAME of the layout structure.
   gs_layout-stylefname = 'CELLTAB'.

   CALL METHOD grid1->set_table_for_first_display
         EXPORTING i_structure_name = 'SFLIGHT'
                   is_layout        = gs_layout
         CHANGING  it_outtab        = gt_outtab[].

Note: in the sample report only field SEATSMAX is editable. In your case you need

to fill CELLTAB for all fields in a row.


*§2.After selecting data, set edit status for each row in a loop
*   according to field SEATSMAX.
  LOOP AT gt_outtab.
    l_index = sy-tabix.
    refresh lt_celltab.
    if gt_outtab-seatsmax ge 300.
        perform fill_celltab using 'RW'
                             changing lt_celltab.
    else.
        perform fill_celltab using 'RO'
                             changing lt_celltab.
    endif.
*§2c.Copy your celltab to the celltab of the current row of gt_outtab.
    INSERT LINES OF lt_celltab INTO TABLE gt_outtab-celltab.
    MODIFY gt_outtab INDEX l_index.
  ENDLOOP.
ENDFORM.                               " SELECT_DATA_AND_INIT_STYLE

NOTE: LVC_T_STYL is a SORTED table type. Thus, take care that you are using the

INSERT ... INTO TABLE statement and not APPEND (because then nothing is appended

to the CELLTAB itab).


  IF p_mode EQ 'RW'.
*§2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
*    to status "editable".
    l_mode = cl_gui_alv_grid=>mc_style_enabled.
  ELSE. "p_mode eq 'RO'
*§2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell
*    to status "non-editable".
    l_mode = cl_gui_alv_grid=>mc_style_disabled.
  ENDIF.

  ls_celltab-fieldname = 'SEATSMAX'.
  ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
  INSERT ls_celltab INTO TABLE pt_celltab.

Regards

Uwe