SAP_ALV

调用功能模块:

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY‘

EXPORTING

i_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_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.

常用属性:(赋值‘‘中内容必须为大写)

1.  Fieldcat

data: fieldcat type slis_t_fieldcat_alv with header line.

it_fieldcat              = fieldcat[]

属性 (用来定义表单中的各个列的相关信息)

Fieldcat-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          参考计量单位的字段名称

Fieldcat-round = n.           四舍五入至小数位数下 n 位

Fieldcat-exponent = n.         浮点数的幂指数为n

Fieldcat-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‘.        为输出隐藏零

Fieldcat-edit_mask = SPACE, mask..  输出为mask的模式

Fieldcat-fix_column = ‘X‘.      固定列

Fieldcat-do_sum = ‘X‘.        总计列值总和

Fieldcat-no_out = ‘X‘.         列不输出

Fieldcat-tech = ‘X‘.           该字段为技术字段

Fieldcat-outputlen = n        列的字符宽度为n

Fieldcat-decimals_out = n     能控制小数点的位数为n

Fieldcat-datatype = C,I,N…        定义数据类型

2.  Layout

data: layout type slis_layout_alv .

is_layout                = layout

属性 (用于定义ALV表单的相关格式、属性)

info_fieldname = ‘LINE_COLOR‘.  设置特殊行颜色

(将LINE_COLOR增加到内表字段,写‘CX10‘到特殊行的LINE_COLOR, X为颜色值)

colwidth_optimize = ‘X‘.   优化列宽设置

no_colhead = ‘X‘.         不显示列名

no_vline = ‘X‘.            不显示列间竖线

zebra

f2code = ‘&ETA‘.    设置触发弹出详细信息窗口的功能码,这里是双击

no_vline           这个用来设置列间隔线

detail_initial_lines

detail_popup        是否弹出详细信息窗口

detail_titlebar       设置弹出窗口的标题栏

totals_text

totals_only

group_change_edit

header_text

三:

FIELDCAT 属性

FIELDCAT:

types: begin of slis_fieldcat_main,

row_pos        like sy-curow, " output in row

col_pos        like sy-cucol, " position of the column

fieldname      type slis_fieldname,

tabname        type slis_tabname,

ref_fieldname  like dd03p-fieldname,

ref_tabname    like dd03p-tabname,

currency(5)    type c,

cfieldname     type slis_fieldname, " field with currency unit

ctabname       type slis_tabname,   " and table

quantity(3)    type c,

qfieldname     type slis_fieldname, " field with quantity unit

qtabname       type slis_tabname,   " and table

roundfieldname type slis_fieldname,

roundtabname   type slis_tabname,

round          type i,        " round in write statement

decimalsfieldname type slis_fieldname,

decimalstabname   type slis_tabname,

decimals_out(6)   type c,     " decimals in write statement

text_fieldname type slis_fieldname,

exponent(3)       type c,     " exponent for floats

key(1)         type c,        " column with key-color

icon(1)        type c,        " as icon

symbol(1)      type c,        " as symbol

checkbox(1)    type c,        " as checkbox

just(1)        type c,        " (R)ight (L)eft (C)ent.

lzero(1)       type c,        " leading zero

no_sign(1)     type c,        " write no-sign

no_zero(1)     type c,        " write no-zero

edit_mask      type slis_edit_mask,                "

emphasize(4)   type c,        " emphasize

fix_column(1)   type c,       " Spalte fixieren

do_sum(1)      type c,        " sum up

no_out(1)      type c,        " (O)blig.(X)no out

tech(1)        type c,        " technical field

outputlen      like dd03p-outputlen,

offset         type dd03p-intlen,        " offset

seltext_l      like dd03p-scrtext_l, " long key word

seltext_m      like dd03p-scrtext_m, " middle key word

seltext_s      like dd03p-scrtext_s, " short key word

reptext_ddic   like dd03p-reptext,   " heading (ddic)

ddictxt(1)     type c,        " (S)hort (M)iddle (L)ong

rollname       like dd03p-rollname,

*        domname        like dd03p-domname,     "Domname f黵 Checkbox

datatype       like dd03p-datatype,

inttype        like dd03p-inttype,

ddic_outputlen like 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 obligatory

no_sum(1)      type c,        " do not sum up

sp_group(4)    type c,        " group specification

reprep(1)      type c,        " selection for rep/rep

input(1)       type c,        " input

hotspot(1)     type c,        " hotspot

end 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)     输出抑制符号

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.

定义部分: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 标题不作为hotspot

zebra(1) type c, " striped pattern 镶边样式

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 仅为grid

edit_mode(1) type c, " for grid only 仅为grid

numc_sum(1) type c, " totals for NUMC-Fields 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 没有标准用户检查

* PF-status 菜单项

def_status(1) type c, " default status space or ‘A‘ 缺省状态空间或‘A‘

item_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 c, " line size = width of the list

min_linesize like sy-linsz, " if initial min_linesize = 80

max_linesize like sy-linsz, " Default 250

window_titlebar like sy-title,

no_uline_hs(1) type c,

* Exceptions 扩展

lights_fieldname type slis_fieldname," fieldname for exception 扩展字段名

lights_tabname type slis_tabname, " fieldname for exception 扩展字段名

lights_rollname like dfies-rollname," rollname f. exceptiondocu

lights_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 choice for subtotals 无可选择子合计

no_subtotals(1) type c, " no subtotals possible 没有子合计

no_unit_splitting type c, " no sep. tot.lines by inh.units

totals_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 total line 合计行第一列文本

subtotals_text(60) type c, " text for 1st col. in subtotals 子合计行第一列文本

* Interaction 继承

box_fieldname type slis_fieldname, " fieldname for checkbox

box_tabname type slis_tabname," tabname for checkbox

box_rollname like dd03p-rollname," rollname for checkbox

expand_fieldname type slis_fieldname, " fieldname flag ‘expand‘

hotspot_fieldname type slis_fieldname, " fieldname flag hotspot

confirmation_prompt, " confirm. prompt when leaving

key_hotspot(1) type c, " keys as hotspot " K_KEYHOT

flexible_key(1) type c, " key columns movable,...

group_buttons(1) type c, " buttons for COL1 - COL5

get_selinfos(1) type c, " read selection screen

group_change_edit(1) type c, " Settings by user for new group

no_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-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 listoutput

coltab_fieldname type slis_fieldname, " colors

* others 其它

list_append(1) type c, " no call screen

xifunckey type aqs_xikey, " eXtended interaction(SAPQuery)

xidirect type flag, " eXtended INTeraction(SAPQuery)

dtc_layout type dtc_s_layo, "Layout for configure the Tabstip

allow_switch_to_list(1) type c, "ACC: Switch Fullscreen to List

end of slis_layout_alv_spec1.

时间: 2024-10-12 16:50:11

SAP_ALV的相关文章