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 problem

former_member734916
Participant
0 Likes
571

Hello All,

I need the solutions for the following.

In the ALV output I am displaying a checkbox in edit mode, but I want this checkbox in edit mode for some records and disable mode for some other records depending on a condition.

Ex.

ITAB. Output fields.

Checkbox F1 F2

if the value of the field F1 = 'V' that checkbox should be in edit mode that means we can check or uncheck.

if the value of the field F1 = 'S' that checkbox should be in disable mode.

points assured.

Regards.

Krishna.

1 ACCEPTED SOLUTION
Read only

mnicolai_77
Active Participant
0 Likes
542

hi,

to make editable and not editable some cells you have to do the following modification to your code:

1 - extend the structure of your table with one more filed

>data: begin of outtab occurs 0,

> Checkbox type xfeld

> F1(1),

> ...

> style TYPE lvc_t_styl,

> end of outtab.

2 - set value 'STYLE' into the field stylefname of strucure typed lvc_s_layo.

>data: ls_layo type lvc_s_layo.

>lvc_s_layo-stylefname = 'STYLE'.

3 - in the fieldcatlog set editable the Checkbox

4 - loop to your internal table outtab and set the style of evry single cell

>data: ls_style type lvc_s_styl.

>loop at outtab.

>if outtab-F1 = 'S'.

>ls_style-fieldname = 'CHECKBOX'.

>ls_style-style = cl_gui_alv_grid=>mc_style_disabled.

>append ls_style to outtab-style.

>clear ls_style.

>else.

>clear outtab-style.

>endif.

>modify outtab.

>endloop.

5 - disply ALV.

for more example see [https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-changing%2bcell%2bcharacteristics%2bin%2balv%2b(OOPS)]

bye

Marco

Edited by: nicolai marco on Jan 13, 2008 10:44 PM

4 REPLIES 4
Read only

mnicolai_77
Active Participant
0 Likes
543

hi,

to make editable and not editable some cells you have to do the following modification to your code:

1 - extend the structure of your table with one more filed

>data: begin of outtab occurs 0,

> Checkbox type xfeld

> F1(1),

> ...

> style TYPE lvc_t_styl,

> end of outtab.

2 - set value 'STYLE' into the field stylefname of strucure typed lvc_s_layo.

>data: ls_layo type lvc_s_layo.

>lvc_s_layo-stylefname = 'STYLE'.

3 - in the fieldcatlog set editable the Checkbox

4 - loop to your internal table outtab and set the style of evry single cell

>data: ls_style type lvc_s_styl.

>loop at outtab.

>if outtab-F1 = 'S'.

>ls_style-fieldname = 'CHECKBOX'.

>ls_style-style = cl_gui_alv_grid=>mc_style_disabled.

>append ls_style to outtab-style.

>clear ls_style.

>else.

>clear outtab-style.

>endif.

>modify outtab.

>endloop.

5 - disply ALV.

for more example see [https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-changing%2bcell%2bcharacteristics%2bin%2balv%2b(OOPS)]

bye

Marco

Edited by: nicolai marco on Jan 13, 2008 10:44 PM

Read only

0 Likes
542

Hello Marco,

Thanks for your answer.

I did the all changes in my code as suggested by you still it is not working properly, can you see the below code and tell me still I am missing anything.

type-pools : slis.

DATA: l_f_repid LIKE sy-repid.

DATA: l_t_fieldcat TYPE slis_t_fieldcat_alv,

l_r_fieldcat LIKE LINE OF l_t_fieldcat.

class cl_gui_alv_grid definition load.

*output tab

data : begin of itab occurs 0,

cb,

f1,

f2(10),

style TYPE lvc_t_styl,

end of itab.

data: ls_style type lvc_s_styl.

data: ls_layo type lvc_s_layo.

ls_layo-stylefname = 'STYLE'.

itab-f1 = 'S'.

itab-f2 = 'Test'.

append itab.

clear itab.

itab-f1 = 'V'.

itab-f2 = 'Test1'.

append itab.

clear itab.

itab-f1 = 'S'.

itab-f2 = 'Test2'.

append itab.

clear itab.

l_r_fieldcat-col_pos = 1.

l_r_fieldcat-tabname = 'ITAB'.

l_r_fieldcat-fieldname = 'CB'.

l_r_fieldcat-checkbox = 'X'.

l_r_fieldcat-edit = 'X'.

append l_r_fieldcat to l_t_fieldcat .

clear l_r_fieldcat.

l_r_fieldcat-col_pos = 2.

l_r_fieldcat-tabname = 'ITAB'.

l_r_fieldcat-fieldname = 'F1'.

append l_r_fieldcat to l_t_fieldcat .

clear l_r_fieldcat.

l_r_fieldcat-col_pos = 3.

l_r_fieldcat-tabname = 'ITAB'.

l_r_fieldcat-fieldname = 'F2'.

append l_r_fieldcat to l_t_fieldcat .

clear l_r_fieldcat.

loop at itab.

if itab-f1 = 'S'.

ls_style-fieldname = 'CB'.

ls_style-style = cl_gui_alv_grid=>mc_style_button .

ls_style-style = cl_gui_alv_grid=>mc_style_disabled.

append ls_style to itab-style.

clear ls_style.

else.

clear itab-style.

endif.

modify itab.

endloop.

l_f_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = l_f_repid

IT_FIELDCAT = l_t_fieldcat

TABLES

t_outtab = itab .

Regards.

Krishna.

Read only

0 Likes
542

hi Krishna,

I have corrected the code that you have posted and now it works

in bold my correction.

>DATA: l_f_repid LIKE sy-repid.

>DATA: l_t_fieldcat TYPE lvc_t_fcat,

> l_r_fieldcat TYPE lvc_s_fcat.

>

>CLASS cl_gui_alv_grid DEFINITION LOAD.

>DATA : BEGIN OF itab OCCURS 0,

> cb,

> f1,

> f2(10),

> style TYPE lvc_t_styl,

> END OF itab.

>DATA: ls_style TYPE lvc_s_styl.

>DATA: ls_layo TYPE lvc_s_layo.

>ls_layo-stylefname = 'STYLE'.

>

>itab-f1 = 'S'.

>itab-f2 = 'Test'.

>APPEND itab.

>CLEAR itab.

>

>itab-f1 = 'V'.

>itab-f2 = 'Test1'.

>APPEND itab.

>CLEAR itab.

>

>itab-f1 = 'S'.

>itab-f2 = 'Test2'.

>APPEND itab.

>CLEAR itab.

>

>l_r_fieldcat-col_pos = 1.

>l_r_fieldcat-tabname = 'ITAB'.

>l_r_fieldcat-fieldname = 'CB'.

>l_r_fieldcat-checkbox = 'X'.

>l_r_fieldcat-edit = 'X'.

>APPEND l_r_fieldcat TO l_t_fieldcat .

>CLEAR l_r_fieldcat.

>

>l_r_fieldcat-col_pos = 2.

>l_r_fieldcat-tabname = 'ITAB'.

>l_r_fieldcat-fieldname = 'F1'.

>APPEND l_r_fieldcat TO l_t_fieldcat .

>CLEAR l_r_fieldcat.

>

>l_r_fieldcat-col_pos = 3.

>l_r_fieldcat-tabname = 'ITAB'.

>l_r_fieldcat-fieldname = 'F2'.

>APPEND l_r_fieldcat TO l_t_fieldcat .

>CLEAR l_r_fieldcat.

>

>

>LOOP AT itab.

> IF itab-f1 = 'S'.

> ls_style-fieldname = 'CB'.

> ls_style-style = cl_gui_alv_grid=>mc_style_button .

> ls_style-style = cl_gui_alv_grid=>mc_style_disabled.

> APPEND ls_style TO itab-style.

> CLEAR ls_style.

> ELSE.

> CLEAR itab-style.

> ENDIF.

> MODIFY itab.

>ENDLOOP.

>

>l_f_repid = sy-repid.

>CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

> EXPORTING

> i_callback_program = l_f_repid

> is_layout_lvc = ls_layo

> it_fieldcat_lvc = l_t_fieldcat

> TABLES

> t_outtab = itab.

you have forgotten to pass the structure layout to the function REUSE_ALV_GRID_DISPLAY.

bye

Marco

Read only

Former Member
0 Likes
542

Hi,

check the program bcal_grid_edit , all the functionalites r present in that program.

Plzz reward points if it helps.