首页 > 代码库 > SAP_ALV

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.

 

本文出自 “小恐龙” 博客,谢绝转载!

SAP_ALV