1、调用功能模块:CALL FUNCTION REUSE_ALV_GRID_DISPLAYEXPORTINGi_interface_check = 接口一致性检查i_callback_program = sy-repid 当前程序名is_layout = layout 输出样式it_fieldcat = fieldcat 字段定义描述表i_callback_pf_status_set = PF_STATUS_SET 触发事件调用子程序i_callback_user_command = USER_COMMAND 鼠标事件操作子程序it_events = i_events 出口程序触发事件i_call
2、back_html_top_of_page = ALV_TOP_OF_PAGE ALV 输出表头设置i_grid_settings = wl_lvc_s_glay 打印表头设置it_sort = sortable 排序设置TABLESt_outtab = ig_outEXCEPTIONSprogram_error = 1OTHERS = 2.常用属性:(赋值中内容必须为大写)1 Fieldcatdata: fieldcat type slis_t_fieldcat_alv with header line.it_fieldcat = fieldcat属性 (用来定义表单中的各个列的相关信息)F
3、ieldcat-col_pos = n. 输出列Fieldcat-tabname = FIELDNAME. 对应的内表字段名Fieldcat-seltext_s/m/l = 列名. 输出列文本 (_s:短文本 _l:长文本)Fieldcat-emphasize = CX10. 带有颜色的高亮列 (其中 X=(1-7) 颜色同 format)Fieldcat-hotspot = X. 作为热点显示 可触发鼠标触发事件Fieldcat-currency = CURRKEY. 表 TCURX 中的货币名称Fieldcat-quantity(3) 计量单位Fieldcat-qfieldname 参考计
4、量单位的字段名称Fieldcat-round = n. 四舍五入至小数位数下 n 位Fieldcat-exponent = n. 浮点数的幂指数为 nFieldcat-key = X. 关键字段Fieldcat-icon = X. 作为图标输出Fieldcat-symbol = X. 输出作为符号Fieldcat-checkbox = X. 作为复选框输出Fieldcat-just = SPACE, R, L, C. 对齐方式Fieldcat-lzero = X. 输出前导零Fieldcat-no_sign = X. 输出抑制符号Fieldcat-no_zero = X. 为输出隐藏零Fiel
5、dcat-edit_mask = SPACE, mask 输出为 mask 的模式Fieldcat-fix_column = X. 固定列Fieldcat-do_sum = X. 总计列值总和Fieldcat-no_out = X. 列不输出Fieldcat-tech = X. 该字段为技术字段Fieldcat-outputlen = n 列的字符宽度为 nFieldcat-decimals_out = n 能控制小数点的位数为 nFieldcat-datatype = C,I,N 定义数据类型2 Layoutdata: layout type slis_layout_alv .is_layo
6、ut = layout属性 (用于定 义 ALV 表单的相关格式、属性 )info_fieldname = LINE_COLOR. 设置特殊行颜色(将 LINE_COLOR 增加到内表字段,写 CX10到特殊行的 LINE_COLOR, X 为颜色值)colwidth_optimize = X. 优化列宽设置no_colhead = X. 不显 示列名no_vline = X. 不显示列间竖线zebraf2code = &ETA. 设置触发弹出详细信息窗口的功能码,这里是双击no_vline 这个用来设置列间隔线detail_initial_linesdetail_popup 是否弹出详细信息
7、窗口detail_titlebar 设置弹出窗口的标题栏totals_texttotals_onlygroup_change_editheader_text三:FIELDCAT 属性FIELDCAT:types: begin of slis_fieldcat_main,row_pos like sy-curow, “ output in rowcol_pos like sy-cucol, “ position of the columnfieldname type slis_fieldname,tabname type slis_tabname,ref_fieldname like dd03p
8、-fieldname,ref_tabname like dd03p-tabname,currency(5) type c,cfieldname type slis_fieldname, “ field with currency unitctabname type slis_tabname, “ and tablequantity(3) type c,qfieldname type slis_fieldname, “ field with quantity unitqtabname type slis_tabname, “ and tableroundfieldname type slis_f
9、ieldname,roundtabname type slis_tabname,round type i, “ round in write statementdecimalsfieldname type slis_fieldname,decimalstabname type slis_tabname,decimals_out(6) type c, “ decimals in write statementtext_fieldname type slis_fieldname,exponent(3) type c, “ exponent for floatskey(1) type c, “ co
10、lumn with key-coloricon(1) type c, “ as iconsymbol(1) type c, “ as symbolcheckbox(1) type c, “ as checkboxjust(1) type c, “ (R)ight (L)eft (C)ent.lzero(1) type c, “ leading zerono_sign(1) type c, “ write no-signno_zero(1) type c, “ write no-zeroedit_mask type slis_edit_mask, “emphasize(4) type c, “
11、emphasizefix_column(1) type c, “ Spalte fixierendo_sum(1) type c, “ sum upno_out(1) type c, “ (O)blig.(X)no outtech(1) type c, “ technical fieldoutputlen like dd03p-outputlen,offset type dd03p-intlen, “ offsetseltext_l like dd03p-scrtext_l, “ long key wordseltext_m like dd03p-scrtext_m, “ middle key
12、 wordseltext_s like dd03p-scrtext_s, “ short key wordreptext_ddic like dd03p-reptext, “ heading (ddic)ddictxt(1) type c, “ (S)hort (M)iddle (L)ongrollname like dd03p-rollname,* domname like dd03p-domname, “Domname f 黵 Checkboxdatatype like dd03p-datatype,inttype like dd03p-inttype,ddic_outputlen lik
13、e dd03p-outputlen,intlen like dd03p-intlen,lowercase like dd03p-lowercase,end of slis_fieldcat_main.types: begin of slis_fieldcat_alv_spec,key_sel(1) type c, “ field not obligatoryno_sum(1) type c, “ do not sum upsp_group(4) type c, “ group specificationreprep(1) type c, “ selection for rep/repinput
14、(1) type c, “ inputhotspot(1) type c, “ hotspotend of slis_fieldcat_alv_spec.以上是 fieldcat 的属性部分解释col_pos 输出列tabname 标签名称currency(5) 货币单位quantity(3) 计量单位qfieldname 参考计量单位的字段名称round ROUND 值exponent(3) 流动表示的指数key(1) 关键字段icon(1) 作为图标输出symbol(1) 输出作为符号checkbox(1) 作为复选框输出just(1) 对齐lzero(1) 输出前导零no_sign(1)
15、 输出抑制符号no_zero(1) 为输出隐藏零edit_mask 为输出编辑掩码emphasize(4) 带有颜色的高亮列fix_column(1) 固定列do_sum(1) 总计列值no_out(1) 列没有输出tech(1) 技术字段outputlen 列的字符宽度decimals_out(6) = 0 不会有小数点了*LAYOUT:定义部分:DATA: W_LAYOUT TYPE SLIS_LAYOUT_ALV.SLIS_LAYOUT_ALV 构造如下:types: begin of slis_layout_main,dummy,end of slis_layout_main.定义部分
16、:DATA: W_LAYOUT TYPE SLIS_LAYOUT_ALV.SLIS_LAYOUT_ALV 构造如下:types: begin of slis_layout_main,dummy,end of slis_layout_main.types: begin of slis_layout_alv_spec0,no_colhead(1) type c, “ no headings 没有标题no_hotspot(1) type c, “ headings not as hotspot 标题不作 为 hotspotzebra(1) type c, “ striped pattern 镶边样式
17、no_vline(1) type c, “ columns separated by space 行由空间隔no_hline(1) type c, “rows separated by space B20K8A0N5D 列由空间分隔cell_merge(1) type c, “ not suppress field replication 不压制领域复制edit(1) type c, “ for grid only 仅为 gridedit_mode(1) type c, “ for grid only 仅为 gridnumc_sum(1) type c, “ totals for NUMC-F
18、ields possib. 数字型字段可集计no_input(1) type c, “ only display fields 仅显示f2code like sy-ucomm, “reprep(1) type c, “ report report interface active 报告接口激活no_keyfix(1) type c, “ do not fix keycolumns 不固定关键字列expand_all(1) type c, “ Expand all positions 扩展所有位置no_author(1) type c, “ No standard authority check
19、 没有标准用户检查* PF-status 菜单项def_status(1) type c, “ default status space or A 缺省状态空间或Aitem_text(20) type c, “ Text for item button 文本为项目按钮countfname type lvc_fname,end of slis_layout_alv_spec0.types: begin of slis_layout_alv_spec1,* Display options 显示属性colwidth_optimize(1) type c,no_min_linesize(1) type
20、 c, “ line size = width of the listmin_linesize like sy-linsz, “ if initial min_linesize = 80max_linesize like sy-linsz, “ Default 250window_titlebar like sy-title,no_uline_hs(1) type c,* Exceptions 扩展lights_fieldname type slis_fieldname,“ fieldname for exception 扩展字段名lights_tabname type slis_tabnam
21、e, “ fieldname for exception 扩展字段名lights_rollname like dfies-rollname,“ rollname f. exceptiondoculights_condense(1) type c, “ fieldname for exception 扩展字段名* Sums 合计no_sumchoice(1) type c, “ no choice for summing up 无可选择总计no_totalline(1) type c, “ no total line 没有合计行no_subchoice(1) type c, “ no choic
22、e for subtotals 无可选择子合计no_subtotals(1) type c, “ no subtotals possible 没有子合计no_unit_splitting type c, “ no sep. tot.lines by inh.unitstotals_before_items type c, “ diplay totals before the items 在明细前显示合计totals_only(1) type c, “ show only totals 只显示合计totals_text(60) type c, “ text for 1st col. in tot
23、al line 合计行第一列文本subtotals_text(60) type c, “ text for 1st col. in subtotals 子合计行第一列文本* Interaction 继承box_fieldname type slis_fieldname, “ fieldname for checkboxbox_tabname type slis_tabname,“ tabname for checkboxbox_rollname like dd03p-rollname,“ rollname for checkboxexpand_fieldname type slis_field
24、name, “ fieldname flag expandhotspot_fieldname type slis_fieldname, “ fieldname flag hotspotconfirmation_prompt, “ confirm. prompt when leavingkey_hotspot(1) type c, “ keys as hotspot “ K_KEYHOTflexible_key(1) type c, “ key columns movable,.group_buttons(1) type c, “ buttons for COL1 - COL5get_selin
25、fos(1) type c, “ read selection screengroup_change_edit(1) type c, “ Settings by user for new groupno_scrolling(1) type c, “ no scrolling* Detailed screen 屏幕详细detail_popup(1) type c, “ show detail in popup 弹出显示明 细detail_initial_lines(1) type c, “ show also initial lines 显示初始行detail_titlebar like sy-
26、title,“ Titlebar for detail 详细标题栏* Display variants 显示变量header_text(20) type c, “ Text for header button 标题按钮文本default_item(1) type c, “ Items as default 默认明细* colour 颜色info_fieldname type slis_fieldname, “ infofield for listoutputcoltab_fieldname type slis_fieldname, “ colors* others 其它list_append(1) type c, “ no call screenxifunckey type aqs_xikey, “ eXtended interaction(SAPQuery)xidirect type flag, “ eXtended INTeraction(SAPQuery)dtc_layout type dtc_s_layo, “Layout for configure the Tabstipallow_switch_to_list(1) type c, “ACC: Switch Fullscreen to Listend of slis_layout_alv_spec1.