首页 > 代码库 > ALV-REUSE_ALV_GRID_DISPLAY_LVC详细参数属性
ALV-REUSE_ALV_GRID_DISPLAY_LVC详细参数属性
秤砣原创—ALV-REUSE_ALV_GRID_DISPLAY_LVC详细参数属性
在SAP的HCM开发中经常会用到ALV,刚开始的时候只知道用 REUSE_ALV_GRID_DISPLAY_LVC这个Function就可以把数据显示出来(这里只说grid),但是这个Function里面的参数属性却一直糊里糊涂的,所以到后来报表开发越来越复杂的时候,就发现懂得Function里面参数的用法非常关键,比如说ALV的分类小计要用到IT_SORT这个参数,列宽等ALV布局要用到IS_LAYOUT参数等等。你要是不知道这些参数的存在或者是不知道它们的用法的话你根本就没办法做。基于自己的这种艰苦的摸爬滚打岁月,就把我知道的ALV参数属性作下总结。
LVC_S_FCAT:ALV 控制字段目录说明
ALV_S_FCAT说明:字段类别 (用于 LVC 和 KKBLO)
INCLUDE <cl_alv_control>的说明:里面有好多ALV布局的属性,中文意思跟英文单词意思同样理解
***INCLUDE <CL_ALV_CONTROL> .
CONSTANTS:
* Style 1
ALV_STYLE_COLOR_BACKGROUND(4) TYPE X VALUE ‘00000001‘,
ALV_STYLE_COLOR_HEADING(4) TYPE X VALUE ‘00000002‘,
ALV_STYLE_COLOR_NORMAL(4) TYPE X VALUE ‘00000003‘,
ALV_STYLE_COLOR_TOTAL(4) TYPE X VALUE ‘00000004‘,
ALV_STYLE_COLOR_KEY(4) TYPE X VALUE ‘00000005‘,
ALV_STYLE_COLOR_POSITIVE(4) TYPE X VALUE ‘00000006‘,
ALV_STYLE_COLOR_NEGATIVE(4) TYPE X VALUE ‘00000007‘,
ALV_STYLE_COLOR_GROUP(4) TYPE X VALUE ‘00000008‘,
ALV_STYLE_COLOR_INT_BACKGROUND(4) TYPE X VALUE ‘00000009‘,
ALV_STYLE_COLOR_INT_HEADING(4) TYPE X VALUE ‘0000000A‘,
ALV_STYLE_COLOR_INT_NORMAL(4) TYPE X VALUE ‘0000000B‘,
ALV_STYLE_COLOR_INT_TOTAL(4) TYPE X VALUE ‘0000000C‘,
ALV_STYLE_COLOR_INT_KEY(4) TYPE X VALUE ‘0000000D‘,
ALV_STYLE_COLOR_INT_POSITIVE(4) TYPE X VALUE ‘0000000E‘,
ALV_STYLE_COLOR_INT_NEGATIVE(4) TYPE X VALUE ‘0000000F‘,
ALV_STYLE_COLOR_INT_GROUP(4) TYPE X VALUE ‘00000010‘,
ALV_STYLE_COLOR_INV_BACKGROUND(4) TYPE X VALUE ‘00000011‘,
ALV_STYLE_COLOR_INV_HEADING(4) TYPE X VALUE ‘00000012‘,
ALV_STYLE_COLOR_INV_NORMAL(4) TYPE X VALUE ‘00000013‘,
ALV_STYLE_COLOR_INV_TOTAL(4) TYPE X VALUE ‘00000014‘,
ALV_STYLE_COLOR_INV_KEY(4) TYPE X VALUE ‘00000015‘,
ALV_STYLE_COLOR_INV_POSITIVE(4) TYPE X VALUE ‘00000016‘,
ALV_STYLE_COLOR_INV_NEGATIVE(4) TYPE X VALUE ‘00000017‘,
ALV_STYLE_COLOR_INV_GROUP(4) TYPE X VALUE ‘00000018‘,
ALV_STYLE_FONT_BOLD(4) TYPE X VALUE ‘00000020‘,
ALV_STYLE_FONT_BOLD_NO(4) TYPE X VALUE ‘00000040‘,
ALV_STYLE_FONT_ITALIC(4) TYPE X VALUE ‘00000080‘,
ALV_STYLE_FONT_ITALIC_NO(4) TYPE X VALUE ‘00000100‘,
ALV_STYLE_FONT_UNDERLINED(4) TYPE X VALUE ‘00000200‘,
ALV_STYLE_FONT_UNDERLINED_NO(4) TYPE X VALUE ‘00000400‘,
ALV_STYLE_ALIGN_LEFT_TOP(4) TYPE X VALUE ‘00000800‘,
ALV_STYLE_ALIGN_CENTER_TOP(4) TYPE X VALUE ‘00001000‘,
ALV_STYLE_ALIGN_RIGHT_TOP(4) TYPE X VALUE ‘00001800‘,
ALV_STYLE_ALIGN_LEFT_CENTER(4) TYPE X VALUE ‘00002000‘,
ALV_STYLE_ALIGN_CENTER_CENTER(4) TYPE X VALUE ‘00002800‘,
ALV_STYLE_ALIGN_RIGHT_CENTER(4) TYPE X VALUE ‘00003000‘,
ALV_STYLE_ALIGN_LEFT_BOTTOM(4) TYPE X VALUE ‘00003800‘,
ALV_STYLE_ALIGN_CENTER_BOTTOM(4) TYPE X VALUE ‘00004000‘,
ALV_STYLE_ALIGN_RIGHT_BOTTOM(4) TYPE X VALUE ‘00004800‘,
ALV_STYLE_FONT_SYMBOL(4) TYPE X VALUE ‘00008000‘,
ALV_STYLE_FONT_SYMBOL_NO(4) TYPE X VALUE ‘00010000‘,
ALV_STYLE_CHECKBOX_NOT_CHECKED(4) TYPE X VALUE ‘00020000‘,
ALV_STYLE_CHECKBOX_CHECKED(4) TYPE X VALUE ‘00040000‘,
ALV_STYLE_CHECKBOX_NO(4) TYPE X VALUE ‘00060000‘,
ALV_STYLE_ENABLED(4) TYPE X VALUE ‘00080000‘,
ALV_STYLE_DISABLED(4) TYPE X VALUE ‘00100000‘,
ALV_STYLE_SINGLE_CLK_EVENT(4) TYPE X VALUE ‘00200000‘,
ALV_STYLE_SINGLE_CLK_EVENT_NO(4) TYPE X VALUE ‘00400000‘,
ALV_STYLE_RADIO_NOT_CHECKED(4) TYPE X VALUE ‘00800000‘,
ALV_STYLE_RADIO_CHECKED(4) TYPE X VALUE ‘01000000‘,
ALV_STYLE_RADIO_NO(4) TYPE X VALUE ‘01800000‘,
ALV_STYLE_F4(4) TYPE X VALUE ‘02000000‘,
ALV_STYLE_F4_NO(4) TYPE X VALUE ‘04000000‘,
ALV_STYLE_IMAGE(4) TYPE X VALUE ‘08000000‘,
ALV_STYLE_NO_DELETE_ROW(4) TYPE X VALUE ‘10000000‘,
ALV_STYLE_BUTTON(4) TYPE X VALUE ‘20000000‘,
ALV_STYLE_BUTTON_NO(4) TYPE X VALUE ‘40000000‘,
* Style 2
ALV_STYLE2_NO_BORDER_LEFT(4) TYPE X VALUE ‘00010000‘,
ALV_STYLE2_NO_BORDER_RIGHT(4) TYPE X VALUE ‘00020000‘,
ALV_STYLE2_NO_BORDER_TOP(4) TYPE X VALUE ‘00040000‘,
ALV_STYLE2_NO_BORDER_BOTTOM(4) TYPE X VALUE ‘00080000‘,
* Style 3 ( WEBSTYLES ).
* Style 4
ALV_STYLE4_ZEBRA_ROW(4) TYPE X VALUE ‘00000001‘,
ALV_STYLE4_STOP_MERGE(4) TYPE X VALUE ‘00000002‘,
ALV_STYLE4_LINK(4) nbsp; TYPE X VALUE ‘00000004‘,
ALV_STYLE4_LINK_NO(4) TYPE X VALUE ‘00000008‘,
* Column Styles
ALV_COL_STYLE_SORT_UP(4) TYPE X VALUE ‘00000001‘,
ALV_COL_STYLE_SORT_DOWN(4) TYPE X VALUE ‘00000002‘,
ALV_COL_STYLE_FILTER(4) TYPE X VALUE ‘00000004‘,
ALV_COL_STYLE_TOTAL(4) TYPE X VALUE ‘00000008‘,
ALV_COL_STYLE_SUBTOTAL(4) TYPE X VALUE ‘00000010‘,
ALV_COL_STYLE_CHARACTERISTIC(4) TYPE X VALUE ‘00000020‘,
ALV_COL_STYLE_KEYFIGURE(4) TYPE X VALUE ‘00000040‘,
ALV_COL_STYLE_KEY(4) TYPE X VALUE ‘00000080‘,
ALV_COL_STYLE_EXCEPTION(4) TYPE X VALUE ‘00000100‘,
ALV_COL_STYLE_SIGNED_KEYFIGURE(4) TYPE X VALUE ‘00000200‘,
ALV_COL_STYLE_MERGE(4) TYPE X VALUE ‘00000400‘,
ALV_COL_STYLE_FIXED(4) TYPE X VALUE ‘00000800‘,
ALV_COL_STYLE_AUTO_VALUE(4) TYPE X VALUE ‘00001000‘,
ALV_COL_STYLE_NO_DISP(4) TYPE X VALUE ‘00002000‘,
ALV_COL_STYLE_HASREF(4) TYPE X VALUE ‘00004000‘,
ALV_COL_STYLE_AVERAGE(4) TYPE X VALUE ‘00008000‘,
ALV_COL_STYLE_MIN(4) TYPE X VALUE ‘00010000‘,
ALV_COL_STYLE_MAX(4) TYPE X VALUE ‘00020000‘.
附上一个网上找到的例子(可直接运行),改例子是关于设置ALV单元格内字体格式的,比如说粗体,其它ALV控制的操作可以看我博客SAP-ALV分类的其它文章。
FS:该例子由原作者保留版权
*&---------------------------------------------------------------------*
*& Report ZALV_FONT_STYLE_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZALV_FONT_STYLE_TEST.
* Include for all style values
INCLUDE <cl_alv_control>." Internal table for final output data
DATA: i_flight TYPE STANDARD TABLE OF sflight." Internal table for field catalog info
DATA: i_fields TYPE lvc_t_fcat." Field symbol for field catalog
FIELD-SYMBOLS: <wa_fields> TYPE lvc_s_fcat.
* Select data
SELECT * FROM sflight
INTO TABLE i_flight
UP TO 100 ROWS.IF sy-subrc = 0." Get field catalog
CALL FUNCTION ‘LVC_FIELDCATALOG_MERGE‘
EXPORTING
i_structure_name = ‘SFLIGHT‘
CHANGING
ct_fieldcat = i_fields
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3
.
IF sy-subrc = 0." Changing the style of field catalog
LOOP AT i_fields ASSIGNING <wa_fields>.
IF sy-tabix > 4.
<wa_fields>-style = ALV_STYLE_FONT_ITALIC.
ELSE.
<wa_fields>-style = ALV_STYLE_FONT_BOLD."ALV_STYLE_FONT_BOLD.
ENDIF.
ENDLOOP. ENDIF." Calling the FM to display ALV report
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY_LVC‘
EXPORTING
i_structure_name = ‘SFLIGHT‘
i_grid_title = ‘Style demo‘(001)
it_fieldcat_lvc = i_fields
TABLES
t_outtab = i_flight
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.
ENDIF.
程序输出结果:
ALV-REUSE_ALV_GRID_DISPLAY_LVC详细参数属性