1. 程式人生 > >OOALV 控制到每一個單元格的編輯狀態

OOALV 控制到每一個單元格的編輯狀態

系統標準程式: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