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

Problem in OOPs ALV

Former Member
0 Likes
481

Hello All,

I am displaying my list output using OOPs ALV. In this, I have to keep few fields as editable & others in display only. My requirement is, I have a field in my internal table. If that field has value 'X' then that particular row of ALV is to be display mode only. No field in that row should be editable. How to achieve this? Please help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
440

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.

<<<<<Check for field value "X" & fill cells as RO ( Read Only ) or RW ( Editable ) >>>>>>>>>>>

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

3 REPLIES 3
Read only

Former Member
0 Likes
441

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.

<<<<<Check for field value "X" & fill cells as RO ( Read Only ) or RW ( Editable ) >>>>>>>>>>>

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

Read only

Former Member
0 Likes
440

one can make any row in alv edittable by specifying the style as enabled or disabled

loop at your internal table .

IF your identifier is x

ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled.

append ls_stylerow to <work area>-field_style.

modify internal table from work area.

else.

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.

append ls_stylerow to <work area>-field_style.

modify internal table from work area.

endif.

endloop.

in this if your identifier is x or blank the row will be non edittable otherwise it will be in edittable mode.

Edited by: pratyush v on Feb 4, 2009 6:42 AM

Read only

Former Member
0 Likes
440

Hello All,

Thank you very much for your answer.I am making the fields editable by passing EDIT = X in field catalog as I want only few fields to be editable & not all.As per your solution if the identifier is not X then all the fields in row will be editable which again I dont want. So I am not sure whether this solution will work . Still I will try but if you can provide me with some other solution then please do. Thanks in advance.

Edited by: ANUGRAH PRAKASH on Feb 4, 2009 1:42 PM