我是ABAP的新手,我正在使用FM'REUSE_ALV_FIELDCATALOG_MERGE'和'REUSE_ALV_GRID_DISPLAY'创建ALV。
当我使用过时的出现0 定义定义内部表IT_MARD
时,它正在工作。但是当我使用type standard table
定义内部表时,我得到异常条件“NO_FIELDCATALOG_AVAILABLE”。你能解释一下这两个定义之间的区别,以及为什么它不适用于后一种情况。以下是代码。
REPORT ztest_fieldcatalog3.
TYPE-POOLS:slis.
*Semi Automatic Fieldcatalog Generation.
*DATA: BEGIN OF IT_MARD OCCURS 0,
* MATNR LIKE MARD-MATNR,
* WERKS LIKE MARD-WERKS, ""
* LGORT LIKE MARD-LGORT,
* PSTAT LIKE MARD-PSTAT,
* END OF IT_MARD.
TYPES: BEGIN OF ty_mard,
matnr type mard-matnr,
werks type mard-werks,
lgort type mard-lgort,
pstat type mard-pstat,
END OF ty_mard.
DATA: IT_MARD TYPE STANDARD TABLE OF ty_mard.
"Use function module create Fieldcat.
DATA:l_program TYPE sy-repid VALUE sy-repid.
DATA:i_fieldcat TYPE slis_t_fieldcat_alv.
SELECT matnr
werks
lgort
pstat
FROM mard
INTO CORRESPONDING FIELDS OF TABLE it_mard
UP TO 100 ROWS.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = l_program
i_internal_tabname = 'IT_MARD'
i_inclname = l_program
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = i_fieldcat[].
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"Call ALV and pass fieldcatalog and data
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_program
it_fieldcat = i_fieldcat
TABLES
t_outtab = it_mard.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
答案 0 :(得分:1)
不同之处在于OCCURS
创建了一个带有标题行的表,而TYPE STANDARD TABLE OF
则没有(除非您明确告诉它)。我想功能模块能够从带有标题行的表中猜测结构,而不是没有标题行的表。我的建议是