系统标准程序:BCALV_EDIT_02 。
如下项目实际使用程序
DATA: celltab type LVC_T_STYL.
gs_layout-stylefname = 'CELLTAB'.
*&---------------------------------------------------------------------*
*& Form FILL_CELLTAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_PT_CELLTAB text
*----------------------------------------------------------------------*
FORM fill_celltab using value(p_mode)
CHANGING pt_celltab TYPE lvc_t_styl.
DATA: ls_celltab TYPE lvc_s_styl,
l_mode type raw4.* This forms sets the style of column 'PRICE' editable* according to 'p_mode' and the rest to read only either way.
IF p_mode EQ 'RW'.*§2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell* to status "editable".
l_mode = cl_gui_alv_grid=>mc_style_enabled.
ELSE. "p_mode eq 'RO'*§2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell* to status "non-editable".
l_mode = cl_gui_alv_grid=>mc_style_disabled.
ENDIF.
ls_celltab-fieldname = 'CARRID'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'CONNID'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'FLDATE'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'PRICE'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'CURRENCY'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'PLANETYPE'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'SEATSMAX'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'SEATSOCC'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'PAYMENTSUM'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.ENDFORM. " FILL_CELLTAB