09-06-2013 12:41 PM
Hi All,
I am using REUSE_ALV_GRID_DISPLAY to display number of document. After click one document it open a screen where user can provide input by using call screen. I need to gray out that particular row after user save in secondary screen in ALV report.
Thanks,
Sunil
09-06-2013 8:02 PM
Hi Sunil,
You can use the method: cl_gui_alv_grid=>mc_style_disabled.
Please read the below links;
http://wiki.sdn.sap.com/wiki/display/Snippets/Disable+or+Enable+Input+fields+Conditionally+In+ALV
Hope this will help you
Thanks & Regards
09-06-2013 8:33 PM
Check if it is saved using SY_SUBRC Check, then based on the condition call the below statements
DATA: v_fld_dischn TYPE slis_fieldname
t_editcell TYPE lvc_t_styl,
s_editcell TYPE lvc_s_styl.
s_editcell-fieldname = v_fldname.
s_editcell-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT s_editcell INTO TABLE t_editcell.
09-07-2013 8:52 AM
For making a row editble or non editable, you need to include one more column in the input table.
data : begin of it_out,
field1,
field2,
......,
......,
field_style TYPE lvc_t_styl,
end of it_out.
Whichever field you want to edit and disable editing, that field edit attribute must be set in the field catalog.
wa_fieldcat-fieldname = 'BELNR
wa_fieldcat-scrtext_m = 'Doc No'.
wa_fieldcat-edit *= 'X'. "*sets whole column to be editable
wa_fieldcat-col_pos = 7.
wa_fieldcat-outputlen = 15.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
case r_ucomm.
when 'SAVE'.
Now after saving data in secondary code, add the following code.
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_s
if sy-subrc = 0 . "Document number is saved.
read table it_out into wa_out where belnr = "saved document number.
ls_stylerow-fieldname = 'BELNR' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
"set field to disabled
APPEND ls_stylerow TO ls_style-field_style.
MODIFY it_out FROM wa_out.
endif.
RS_SELFIELD-REFRESH = 'X'. "Refresh ALV.
Now the document number would be non-editable for documents already saved.
Your requirement can also be acheived though the following logic.
Add an extra column save_flag in your output tab for the first ALV screen.
data : begin of it_data,
field1,
field2,
......,
......,
save_flag type c,
end of it_data.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
case 'EDIT'
READ TABLE it_data INTO wa_data INDEX rs_selfield-tabindex.
if wa_data-save_flag is initial.
CALL 200 . "Secondary screen.
* if document saved is successful
wa_data-save_flag = 'X'.
modify it_data from wa_data .
* endif.
endif.
RS_SELFIELD-REFRESH = 'X'. "Refresh ALV.
In this case, the secondary screen will be called for inputting data only for documents not already saved.
Regards,
Susmitha