*数据定义
TYPES:BEGIN OF ty_alvout,
line_color TYPE char4, "行颜色
sqnr TYPE zfius080-sqnr,
szfx TYPE char4,
END OF ty_alvout.
DATA:gt_alvout TYPE TABLE OF ty_alvout,
gw_alvout TYPE ty_alvout.
定义ALV
DATA: ls_layout TYPE lvc_s_layo,
lt_exclude TYPE ui_functions,
lt_fcat1 TYPE lvc_t_fcat,
ls_variant TYPE disvariant.
DATA: lt_fcat_alv TYPE lvc_t_fcat.
DATA: lt_sort TYPE lvc_t_sort,
ls_sort TYPE lvc_s_sort.
DATA: lt_filter TYPE lvc_t_filt,
ls_filter TYPE lvc_s_filt.
"定义容器
IF NOT g_grid_alv IS INITIAL.
CALL METHOD g_grid_alv->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
EXIT.
ENDIF.
CREATE OBJECT g_cont_alv
EXPORTING
container_name = ‘ALV_CON’.
CREATE OBJECT g_grid_alv
EXPORTING
i_parent = g_cont_alv.
"layout 设置
ls_layout-cwidth_opt = ‘X’.
ls_layout-zebra = ‘X’.
ls_layout-sel_mode = ‘D’.
ls_layout-info_fname = ‘LINE_COLOR’."行样色
def_grid ‘SQNR’ ‘申请单号’ ‘’."
def_grid ‘SZFX’ ‘收支方向’ ‘’."
def_grid ‘XSHTH’ ‘合同编号’ ‘’."
“def_grid ‘ZZHTBH_SD’ ‘合同号’ ‘’.”
def_grid ‘JYDSMS’ ‘交易对手描述’ ‘’."
def_grid ‘YJFKRQ’ ‘预计收付款日期’ ‘’."
def_grid ‘FYXZ’ ‘费用性质’ ‘’."
def_grid ‘BCSQJE’ ‘金额’ ‘’."
def_grid ‘WAERS’ ‘货币’ ‘’."
def_grid ‘SQZTMS’ ‘单据状态’ ‘’."
def_grid ‘SFJHN’ ‘是否在日资金计划内’ ‘’."
def_grid ‘SFKBANK’ ‘收付款银行’ ‘’."
ls_variant-report = sy-repid.
CALL METHOD g_grid_alv->set_table_for_first_display
EXPORTING
is_layout = ls_layout
it_toolbar_excluding = lt_exclude
i_save = ‘A’
is_variant = ls_variant
CHANGING
it_fieldcatalog = lt_fcat
-
IT_SORT = LT_SORT it_outtab = gt_alvout[].
2个地方:
1, ls_layout-info_fname = ‘LINE_COLOR’.“行样色
2,gw_alvout-line_color = ‘C311’.”‘C611’