Application Development and Automation 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: 
Read only

ALV Disabling a single Row

Former Member
0 Likes
3,524

Hi,

I have a ALV with 17 rows and i need to make Rows 12 - 17 non-editable ,

i tried it using the following code

LOOP AT i_output INTO wa_i_output.
           IF sy-tabix GT 12.
               ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.   "set field to disabled
              APPEND ls_stylerow  TO wa_i_output-field_style.
              MODIFY i_output FROM wa_i_output.
           ENDIF.
        ENDLOOP.

But i am not getting the desired result.

Any help regarding this will be greatly appreciated.

Rgds,

K

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,068

Hi Ken

Try this


LOOP AT i_output INTO wa_i_output.
           IF sy-tabix GE 12.
              ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.   "set field to disabled
              APPEND ls_stylerow  TO lt_styletab.
              INSERT LINES OF lt_styletab INTO ls_listrow-cellstyles .
              MODIFY i_output FROM  ls_listrow.
           ENDIF.
        ENDLOOP.

Pushpraj

Hi,

I have a ALV with 17 rows and i need to make Rows 12 - 17 non-editable ,

i tried it using the following code

LOOP AT i_output INTO wa_i_output.
           IF sy-tabix GT 12.
               ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.   "set field to disabled
              APPEND ls_stylerow  TO wa_i_output-field_style.
              MODIFY i_output FROM wa_i_output.
           ENDIF.
        ENDLOOP.

But i am not getting the desired result.

Any help regarding this will be greatly appreciated.

Rgds,

K

8 REPLIES 8
Read only

Former Member
Read only

Former Member
0 Likes
2,068

Hi,

If u want to disable some rows in an alv grid, than u can specify the row in fieldcatalog as edit ' '.

This will make the specified rows as disabled.

thank u.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
2,068

Hi,

Use this link:-

Hope this solves your problem.

Thanks & Regards,

Tarun Gambhir

Read only

Former Member
0 Likes
2,069

Hi Ken

Try this


LOOP AT i_output INTO wa_i_output.
           IF sy-tabix GE 12.
              ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.   "set field to disabled
              APPEND ls_stylerow  TO lt_styletab.
              INSERT LINES OF lt_styletab INTO ls_listrow-cellstyles .
              MODIFY i_output FROM  ls_listrow.
           ENDIF.
        ENDLOOP.

Pushpraj

Read only

0 Likes
2,068

Hi Pushparaj,

Its getting a dump. I think the insert statement aint correct.

Any suggestions??

Rgds,

K.

Read only

0 Likes
2,068

Hi Ken

Try this


LOOP AT i_output INTO wa_i_output.
           IF sy-tabix GE 12.
              ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.   "set field to disabled
              APPEND ls_stylerow  TO lt_styletab.
              INSERT LINES OF lt_styletab INTO TABLE wa_i_output-i_cellstyles.
           ENDIF.
ENDLOOP.

i_cellstyles is to be passed like this in the layout structure

ls_layout-stylefname = 'I_CELLSTYLES'.

Pushpraj

Read only

0 Likes
2,068

Thanks Pushparaj. It really helped to solve our issue.

Rgds,

K.

Read only

Former Member
0 Likes
2,068

Try this way..

DATA: BEGIN OF t_vbrk OCCURS 0.

INCLUDE STRUCTURE zsvbrk.

DATA: status TYPE statusicon30.

DATA: modify TYPE statusicon30.

DATA: cltab TYPE lvc_t_styl. """Add field for cell style

DATA: messages TYPE lvc_t_msg1.

DATA: row_no TYPE lvc_s_roid-row_id.

DATA: END OF t_vbrk.

PERFORM set_style TABLES t_vbrk[].

&----


*& Form set_style

&----


  • text

----


  • -->P_T_VBRK[] text

----


FORM set_style TABLES p_t_vbrk STRUCTURE t_vbrk.

DATA: lt_cell TYPE lvc_t_styl,

l_ind TYPE i.

LOOP AT p_t_vbrk .

l_ind = sy-tabix.

PERFORM fill_tab USING 'RO' CHANGING lt_cell.

INSERT LINES OF lt_cell INTO TABLE p_t_vbrk-cltab.

p_t_vbrk-row_no = l_ind.

MODIFY p_t_vbrk INDEX l_ind.

ENDLOOP.

ENDFORM.

&----


*& Form FILL_TAB

&----


  • text

----


  • -->P_0239 text

  • <--P_LT_CELL text

----


FORM fill_tab USING value(p_mode)

CHANGING p_lt_cell TYPE lvc_t_styl.

DATA: ls_cell TYPE lvc_s_styl,

l_mode TYPE raw4.

IF p_mode = 'RW'.

l_mode = cl_gui_alv_grid=>mc_style_enabled.

ELSE.

l_mode = cl_gui_alv_grid=>mc_style_disabled.

ENDIF.

ls_cell-fieldname = 'MANDT'.

ls_cell-style = l_mode.

INSERT ls_cell INTO TABLE p_lt_cell.

ls_cell-fieldname = 'VBELN'.

ls_cell-style = l_mode.

INSERT ls_cell INTO TABLE p_lt_cell.

ENDFORM. " FILL_TAB

Hope this solve ur problem..