有的时候写好代码调用 REUSE_…
有的时候写好代码调用 REUSE_ALV_FIELDCATALOG_MERGE
时会莫名的出错提示为 READ_REPORT_LINE_TOO_LONG 下面列出的错误信息有这么一句.
The internal table "/FUNCTION=K_KKB_FIELDCAT_MERGE/DATA=L_ABAP_SOURCE[]" is 72
characters wide. The program line is 99 characters wide.
该FM会把整个程序代码拷贝至其内表中,如果程序的行超过72个字符,即报如上错误。可以做以下设置。
TYPE-POOLS:SLIS. "调用该类型池
DATA:fieldCat TYPE SLIS_T_FIELDCAT_ALV
WITH HEADER LINE,
layout TYPE
SLIS_LAYOUT_ALV,
w_repid LIKE SY-REPID.
DATA:LSPFLI LIKE STANDARD TABLE OF SPFLI
WITH HEADER LINE.
START-OF-SELECTION.
PERFORM GETDATA.
PERFORM CATALOG.
PERFORM ALVSHOW.
FORM GETDATA.
SELECT * FROM SPFLI
INTO CORRESPONDING FIELDS OF TABLE LSPFLI.
ENDFORM.
FORM CATALOG.
w_repid =
SY-REPID.
CLEAR fieldCat.
CALL FUNCTION
'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME
= w_repid
*I_INTERNAL_TABNAME
=
I_STRUCTURE_NAME
= 'SPFLI'
*I_CLIENT_NEVER_DISPLAY
=
'X'
*I_INCLNAME
=
*I_BYPASSING_BUFFER
=
*I_BUFFER_ACTIVE
=
CHANGING
CT_FIELDCAT
= fieldCat[]
"导出FIELDCAT内表数据
EXCEPTIONS
INCONSISTENT_INTERFACE
= 1
PROGRAM_ERROR
= 2
OTHERS
= 3
.
IF SY-SUBRC <>
0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER
SY-MSGNO
WITH SY-MSGV1 SY-MSGV2
SY-MSGV3 SY-MSGV4.
ENDIF.
"对fieldcat属性的修改
*READ TABLE fieldCat
INDEX 2. "将第二列设为热点显示
*fieldCat-HOTSPOT =
'X'.
*MODIFY fieldCat INDEX
2.
*
*READ TABLE fieldCat
INDEX 4. "将第四列设为KEY值字段
*fieldCat-KEY =
'X'.
*MODIFY fieldCat INDEX
4.
*
*READ TABLE fieldCat
INDEX 5. "将第五列设为CHECKBOX
*fieldCat-CHECKBOX =
'X'.
*MODIFY fieldCat INDEX
5.
layout-COLWIDTH_OPTIMIZE = 'X'.
"设置LAYOUT输出格式最优化
ENDFORM.
FORM ALVSHOW.
CALL FUNCTION
'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM
= w_repid
I_GRID_TITLE
= 'ALV REPORT TEST'
"ALV显示标题
IS_LAYOUT
= layout
IT_FIELDCAT
= fieldCat[]
TABLES
T_OUTTAB
=
LSPFLI
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.
ENDFORM.
The internal table "/FUNCTION=K_KKB_FIELDCAT_MERGE/DATA=L_ABAP_SOURCE[]" is 72
characters wide. The program line is 99 characters wide.
该FM会把整个程序代码拷贝至其内表中,如果程序的行超过72个字符,即报如上错误。可以做以下设置。
调用REUSE_ALV_FIELDCATALOG_MERGE函数来获取FIELDCAT
REUSE_ALV_FIELDCATALOG_MERGE函数可根据内表结构返回FIELDCAT字段结构信息,具体的参数等信息请查看ALV调用的几个标准函数里相关的介绍,好的,那么让我们开始学习如何使用此函数。
REPORT ZZWEI_ALV_DEMO.
*ALV START
*定义FIELDCAT与LAYOUT
TABLES:SPFLI.
*屏幕开始事件
*The Function Of GETDATA
*FORM CATALOG 根据结构体获取FIELDCAT
*The Function Of Show ALV
引自:http://www.cnblogs.com/foxting/archive/2012/07/25/2607687.html
http://blog.sina.com.cn/sapliumeng