FunctionModel调用ALV时,设置根据…
FunctionModel调用ALV时,设置根据某个字段小记
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = layout
it_fieldcat = fieldcat[]
it_sort = it_sort[] "小记功能
DATA it_sort TYPE slis_sortinfo_alv OCCURS 1 WITH HEADER LINE.
"根据过账日期进行小记
CLEAR it_sort.
it_sort-spos = 1.
it_sort-fieldname = 'BUDAT'.
"过账日期
it_sort-up = 'X'.
it_sort-subtot = 'X'.
* it_sort-expa = 'X'.
"控制小记的展开与否,不设置是展开的
APPEND it_sort .
"统计功能打开
fieldcat-do_sum = 'X'.
append fieldcat.
END-OF-DEFINITION.
效果如图:
具体实现:
控制字段 it_sort
和 it_fieldcat 共同影响
1、it_sort 设置
*
2、fieldcat设置
DATA: fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
*&---------------------------------------------------------------------*
*&宏定义
*&---------------------------------------------------------------------*
DEFINE fill_fieldcat.
fieldcat-col_pos = &1.
fieldcat-fieldname = &2.
fieldcat-seltext_l = &3.
"设置列的颜色
"case fieldcat-fieldname.
" when 'WRBTR_H'. "借方红色,贷方绿色
"
fieldcat-emphasize = con_red.
"
when 'WRBTR_S'.
"
fieldcat-emphasize = con_green.
"
when others.
"endcase.
*&宏定义
*&---------------------------------------------------------------------*
DEFINE
END-OF-DEFINITION.
至于
ieldcat-do_sum = 'X'.
it_sort-up = 'X'.
it_sort-subtot = 'X'.
it_sort-expa = 'X'.
it_sort-subtot
it_sort-expa
这几个X设置成space,什么效果自己试验就行
http://blog.sina.com.cn/sapliumeng