*&----------------------------------------------------------------------*
*& 使用方法 *ALV表头
*& append_alv_field 'PREPI' 'Tag No' '' '' '0' 'X' '' '' ''.
*& 给Alv写表头在top 文件里定义
*&----------------------------------------------------------------------*
DATA: g_line type slis_fieldcat_alv,
it_fieldcat type slis_t_fieldcat_alv.
ALV常用参数的详细描述
调用功能模块:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_interface_check = '' 接口一致性检查
i_callback_program = sy-repid 当前程序名
is_layout = layout 输出样式
it_fieldcat = it_fieldcat[] 字段定义描述表
i_callback_pf_status_set = 'PF_STATUS_SET' 触发事件调用子程序
i_callback_user_command = 'USER_COMMAND' 鼠标事件操作子程序
it_events = i_events[] 出口程序触发事件
i_callback_html_top_of_page = 'ALV_TOP_OF_PAGE' ALV输出表头设置
i_grid_settings = wl_lvc_s_glay 打印表头设置
it_sort = sortable[] 排序设置
TABLES
t_outtab = ig_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
*&define macro
define append_alv_field.
clear g_line.
g_line-fieldname = &1. * 数据库表里的 字段名
g_line-tabname = 'IT_DATA'. * 内表名
g_line-reptext_ddic = &2.
g_line-seltext_l = &2.
g_line-seltext_m = &2.
g_line-seltext_s = &2.
g_line-cfieldname = &3.
g_line-ctabname = &4.
g_line-no_out = &5.
g_line-no_zero = &6.
g_line-outputlen = &7.
g_line-qfieldname = &8.
g_line-just = &9.
g_line-ddictxt = 'L'.
*&----------------------------------------------------------------------*
*& add date 2007/12/17
*&----------------------------------------------------------------------*
g_line-seltext_s/m/l /reptext_ddic = ‘列名’.输出列文本(这几种类型没见得有什么区别) (_s:短文本 M是字段名 ;_reptext_DDIC _l:长文本)
g_line-emphasize = ‘CX10’. 带有颜色的高亮列//(其中X=(1-7) 颜色同format)
g_line-hotspot = ‘X’. 作为热点显示//可触发鼠标触发事件
g_line-currency = ‘CURRKEY’. 表 TCURX 中的货币名称
g_line-quantity(3) 计量单位
g_line-qfieldname 参考计量单位的字段名称
g_line-round = n. 四舍五入至小数位数下 n 位
g_line-exponent = n. 浮点数的幂指数为n
g_line-key = ‘X’. 关键字段
g_line-icon = ‘X’. 作为图标输出
g_line-symbol = ‘X’ 输出作为符号
g_line-checkbox = ‘X’. 作为复选框输出
g_line-just = SPACE, 'R', 'L', 'C'. 对齐方式
g_line-lzero = ‘X’. 输出前导零
g_line-no_sign = ‘X’. 输出抑制符号
g_line-no_zero = ‘X’. 为输出隐藏零
g_line-edit_mask = SPACE, mask. 输出为mask的模式
g_line-fix_column = ‘X’. 固定列
g_line-do_sum = ‘X’. 总计列值总和
g_line-no_out = ‘X’. 列不输出
g_line-tech = ‘X’. 该字段为技术字段
g_line-outputlen = n 列的字符宽度为n
g_line-decimals_out = n 能控制小数点的位数为n
g_line-datatype = C,I,N… 定义数据类型
*&----------------------------------------------------------------------*
*& add date 2007/12/17
*&----------------------------------------------------------------------*
append g_line to it_fieldcat.
Layout说明:
data: layout type slis_layout_alv .
it_layout-f2code = '&ETA'。 * 双击事件(明细事件)
it_layout-zebra = 'X'. * zebra 线
it_layout-detail_popup = 'X'. * 双击事件
it_layout-colwidth_optimize = 'X'. * 自动缩进行
it_layout-box_fieldname = 'mark'. * 在Alv 里多出一个mark 按钮
it_layout-comfirmation_prompt = 'X' * 在点击系统按钮时会弹出一个对话框.
it_layout-detail_initial_lines = 'X' * 将此行上所有的值全显示出来(Detail Screen),不管是否为 '0'.
it_layout-no_colhead ='X' * 没有表头
it_layout-no_vline = 'X' * ALV没有竖线
it_layout-detail_titlebar 设置弹出窗口的标题栏
it_layout-totals_text ='' 计算
it_layout-totals_only='' 计算
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/chfeijj/archive/2007/12/18/1946555.aspx