ALV的报表对用户定义格式的控制(ALV I_SAVE)
很多ALV的报表都需要手动的进行设置格式以使数据看上去更有意义和条理,如果每次进来都重新操作一遍是很烦人的,所以SAP有提供了一个保存格式的功能,保存格式可以是 ‘缺省设置’ 和 ‘特定用户’ 两种 至于这两种功能的激活是在程序中指定的。
I_SAVE 参数有四个可选值 分别是 空(两个功能都关闭,只能选择更改不能保存) X(只保留缺省默认的) U(只保留特定用户功能) A(缺省默认和特定用户都可以),
1.FUN ALV
在调用显示ALV函数的时候有个I_SAVE 参数
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
i_save = 'A'
is_variant = v_stru_disvar
it_events = git_events[]
it_sort = it_sort[]
is_print = gs_print
TABLES
t_outtab = gt_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
2.OO ALV 的方式和FUN的有点不同
DATA:g_variant TYPE disvariant.
g_variant-report = sy-repid.
CALL METHOD gcl_alv->set_table_for_first_display
EXPORTING
is_layout = gs_layout
is_variant = g_variant
i_save = 'A'
it_toolbar_excluding = gt_exclude
CHANGING
it_outtab = gt_data[]
it_fieldcatalog = gt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
下面是SAP对 I_SAVE 这个参数的官方介绍。
' ' = Display variants cannot be saved
Defined display variants (such as delivered display variants) can be selected for presentation regardless of this indicator. However, changes cannot be saved.
'X' = Standard save mode
Display variants can be saved as standard display variants.
Saving display variants as user-specific is not possible.
'U' = User-specific save mode
Display variants can only be saved as user-specific.
'A' = Standard and user-specific save mode
Display variants can be saved both as user-specific and as standard
variants. Users make their choice on the dialog box for saving the
display variant.