‎2006 Sep 20 11:48 AM
hi friends,
i added a editing functionality in my ALV program. the requirement is that i need to edit field based on condition .if condition satisfies then it should be editable else it should be non editable..
for example
internal table contains 2 fields.
dliveryno and delivery text.
field delivery text should be editable if the delivery number exist else it should be a non editable fields.
please help me init.
with Regards,
ram
‎2006 Sep 20 11:50 AM
‎2006 Sep 20 11:51 AM
Declare a field celltab TYPE lvc_t_styl in the final internal table which u are showing in the ALV.
In the layout give it as
wa_layout-stylefname = text-083. "CELLTAB
Write a code like this sample code before calling the CALL METHOD o_alvgrid->set_table_for_first_display.
&----
*& Form no_edit_for_date
&----
Reset Editable for Date Records
----
FORM no_edit_for_date TABLES p_i_final STRUCTURE wa_final.
DATA : lt_celltab TYPE lvc_t_styl,
ls_celltab TYPE lvc_s_styl.
DATA : lt_celltab1 TYPE lvc_t_styl,
ls_celltab1 TYPE lvc_s_styl,
lws_tabix TYPE sy-tabix.
CLEAR: wa_final, lt_celltab, lt_celltab1, ls_celltab, ls_celltab1.
LOOP AT p_i_final INTO wa_final WHERE zzmod_eff_code NE 03.
lws_tabix = sy-tabix.
ls_celltab-fieldname = text-027. "DATE
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE lt_celltab.
wa_final-celltab[] = lt_celltab[].
MODIFY p_i_final FROM wa_final INDEX lws_tabix.
CLEAR: ls_celltab, lt_celltab, lws_tabix.
ENDLOOP.
LOOP AT p_i_final INTO wa_final WHERE zzmod_eff_code EQ 03 OR
zzmod_eff_code EQ 04 OR
zzmod_eff_code EQ 05.
lws_tabix = sy-tabix.
ls_celltab1-fieldname = text-027. "DATE
ls_celltab1-style = cl_gui_alv_grid=>mc_style_enabled.
INSERT ls_celltab1 INTO TABLE lt_celltab1.
wa_final-celltab[] = lt_celltab1[].
MODIFY p_i_final FROM wa_final INDEX lws_tabix.
CLEAR lws_tabix.
ENDLOOP.
ENDFORM. " no_edit_for_date
Regards,
Prakash.
‎2006 Sep 20 12:22 PM
Hi Prakash,
i am not clear with ur answer please send me some easy example ..
with regards,
Ram
‎2006 Sep 20 12:37 PM
Ram,
I think ur requirement is to make a cell editable non-editable based on some condition. Also if u r using the class to display the ALV go with the below steps.
For this what u do declare a field <b>celltab TYPE lvc_t_styl</b> in the final internal table which u are showing in the ALV.
In the layout give it as
wa_layout-stylefname = 'CELLTAB'.
Write a code like this sample code before calling the CALL METHOD o_alvgrid->set_table_for_first_display.
*-- Create Field catalog
PERFORM field_catalog TABLES i_fieldcat.
**-- Set ALV Layout
PERFORM create_layout.
**-- No Edit control for Date when mode eff code = '1', '2'.
PERFORM no_edit_for_date TABLES i_final.
**-- Generate ALV Grid
PERFORM display_list TABLES i_final
i_fieldcat
USING wa_layout.
Here for me the requirement is to make a date cell enabled or disabled based on effective code. So i return the below code.
&----
*& Form no_edit_for_date
&----
Reset Editable for Date Records
----
FORM no_edit_for_date TABLES p_i_final STRUCTURE wa_final.
DATA : lt_celltab TYPE lvc_t_styl,
ls_celltab TYPE lvc_s_styl.
DATA : lt_celltab1 TYPE lvc_t_styl,
ls_celltab1 TYPE lvc_s_styl,
lws_tabix TYPE sy-tabix.
CLEAR: wa_final, lt_celltab, lt_celltab1, ls_celltab, ls_celltab1.
LOOP AT p_i_final INTO wa_final WHERE zzmod_eff_code NE 03.
lws_tabix = sy-tabix.
ls_celltab-fieldname = text-027. "DATE
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE lt_celltab.
wa_final-celltab[] = lt_celltab[].
MODIFY p_i_final FROM wa_final INDEX lws_tabix.
CLEAR: ls_celltab, lt_celltab, lws_tabix.
ENDLOOP.
LOOP AT p_i_final INTO wa_final WHERE zzmod_eff_code EQ 03 OR
zzmod_eff_code EQ 04 OR
zzmod_eff_code EQ 05.
lws_tabix = sy-tabix.
ls_celltab1-fieldname = text-027. "DATE
ls_celltab1-style = cl_gui_alv_grid=>mc_style_enabled.
INSERT ls_celltab1 INTO TABLE lt_celltab1.
wa_final-celltab[] = lt_celltab1[].
MODIFY p_i_final FROM wa_final INDEX lws_tabix.
CLEAR lws_tabix.
ENDLOOP.
ENDFORM. " no_edit_for_date
<b>What u can do is </b>
DATA : lt_celltab TYPE lvc_t_styl,
ls_celltab TYPE lvc_s_styl.
DATA : lt_celltab1 TYPE lvc_t_styl,
ls_celltab1 TYPE lvc_s_styl,
lws_tabix TYPE sy-tabix.
CLEAR: wa_final, lt_celltab, lt_celltab1, ls_celltab, ls_celltab1.
LOOP AT p_i_final INTO wa_final WHERE deliveryno eq space.
lws_tabix = sy-tabix.
ls_celltab-fieldname = 'DELIVERY_TEXT'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
*<b>This cl_gui_alv_grid=>mc_style_disabled will make a cell disabled</b>
INSERT ls_celltab INTO TABLE lt_celltab.
wa_final-celltab[] = lt_celltab[].
MODIFY p_i_final FROM wa_final INDEX lws_tabix.
CLEAR: ls_celltab, lt_celltab, lws_tabix.
ENDLOOP.
LOOP AT p_i_final INTO wa_final WHERE deliveryno ne space
lws_tabix = sy-tabix.
ls_celltab1-fieldname = 'DELIVERY_TEXT'.
ls_celltab1-style = cl_gui_alv_grid=>mc_style_enabled.
*<b>This cl_gui_alv_grid=>mc_style_enabled will make a cell enabled</b>
INSERT ls_celltab1 INTO TABLE lt_celltab1.
wa_final-celltab[] = lt_celltab1[].
MODIFY p_i_final FROM wa_final INDEX lws_tabix.
CLEAR lws_tabix.
ENDLOOP.
Hope this is usefull.
Regards,
Prakash.
‎2006 Sep 20 12:23 PM
Hello,
Please go to transaction DWDM. There are many examples with source code.
Regs,
Venkat Ramanan N