运行此程序时,我收到了一个简短转储(尚未分配字段符号)。
我知道当我没有正确填充t_fieldcat
时,我可能会收到此错误。
据我所知,我已正确填写了现场目录。
我无法弄清楚问题出在哪里。请帮助。
REPORT Y_ALV1.
type-pools slis.
tables: scarr.
data:
t_scarr type table of scarr,
t_fieldcat type slis_t_fieldcat_alv.
data:
wa_fieldcat type slis_fieldcat_alv.
select-options:
s_carrid for scarr-carrid.
start-of-selection.
select * into table t_scarr from scarr where carrid in s_carrid.
if sy-subrc ne 0.
leave list-processing.
endif.
define fill_fieldcatalog.
wa_fieldcat-col_pos = &1.
wa_fieldcat-fieldname = &2.
wa_fieldcat-tabname = &3.
wa_fieldcat-outputlen = &4.
append wa_fieldcat to t_fieldcat.
end-of-definition.
fill_fieldcatalog 1 'carrid' 't_scarr' 10.
fill_fieldcatalog 2 'carrname' 't_scarr' 10.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
IT_FIELDCAT = t_fieldcat
TABLES
T_OUTTAB = t_scarr
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.
答案 0 :(得分:4)
不幸的是,案件在这里很重要。更改以下行:
fill_fieldcatalog 1 'carrid' 't_scarr' 10.
fill_fieldcatalog 2 'carrname' 't_scarr' 10.
到
fill_fieldcatalog 1 'CARRID' 't_scarr' 10.
fill_fieldcatalog 2 'CARRNAME' 't_scarr' 10.
答案 1 :(得分:1)
其他选项是在宏中转换为大写。这样你在调用它时就永远不会犯错误。
wa_fieldcat-fieldname = &2.
TRANSLATE wa_fieldcat-fieldname TO UPPER CASE.
wa_fieldcat-tabname = &3.
TRANSLATE wa_fieldcat-tabname TO UPPER CASE.