呼叫REUSE_ALV_GRID_DISPLAY时崩溃"Field symbol has not yet been assigned"



显示ALV时,我在执行程序时收到崩溃报告。为了创建一个 ALV,我遵循了一些教程和东西,目前它看起来像这样:

TYPE-POOLS: slis. 
*build field catalog
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
repid TYPE sy-repid.
REFRESH it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-reptext_ddic = 'Table ID'.
wa_fieldcat-fieldname    = 'table_id'.
wa_fieldcat-tabname      = 'lt_where_used_data_of_coll'.
wa_fieldcat-outputlen    = '18'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-reptext_ddic = 'Table Description'.
wa_fieldcat-fieldname    = 'table_description'.
wa_fieldcat-tabname      = 'lt_where_used_data_of_coll'.
wa_fieldcat-outputlen    = '40'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-reptext_ddic = 'Numer of Records Found'.
wa_fieldcat-fieldname    = 'nr_of_records'.
wa_fieldcat-tabname      = 'lt_where_used_data_of_coll'.
wa_fieldcat-outputlen    = '30'.
APPEND wa_fieldcat TO it_fieldcat.
*pass data and field catalog to ALV function module
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program      = repid
it_fieldcat             = it_fieldcat
i_structure_name        = 'lty_where_used_data_of_coll'
TABLES
t_outtab                = lt_where_used_data_of_coll.

"lt_where_used_data_of_coll"是我的本地表,我已经在程序前面填充了一个工作函数。这个函数有效,我已经测试过它,表格用数据填充了自己。我的下一步是向最终用户显示此数据。执行此程序时收到的错误报告是:

短文:Field symbol has not yet been assigned.

发生了什么事?:

Error in the ABAP Application Program.
The current ABAP program "SAPLSLVC" had to be terminated because it has
come across a statement that unfortunately cannot be executed.

错误分析:

You attempted to access an unassigned field symbol
(data segment "-1").

运行时错误的触发位置

Program                                 SAPLSLVC
Include                                 LSLVCF36
Row                                     3,273
Module type                             (FORM)
Module Name                             FILL_DATA_TABLE

我真的不知道如何开始发现我的错误。从 ABAP 本身调用函数时似乎运行不好。

任何帮助都非常感谢。

编辑:正如建议的那样,我实现了另一种显示ALV的方式,可以在下面找到。这种方式工作正常,不会出错。问题仍然存在,为什么旧方法确实给了我一个错误。

我用这个替换了上面的整个代码块:

DATA alv TYPE REF TO cl_salv_table. DATA message TYPE REF TO cx_salv_msg.
*initialize ALV
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = alv
CHANGING
t_table      = lt_where_used_data_of_coll ).
CATCH cx_salv_msg INTO message.
" error handling
ENDTRY.
*display ALV
alv->display( ).

为什么旧方法确实给了我一个错误

字段目录名称区分大小写。大写每个fieldnametabname值,看看错误是否仍然存在。还要确保名称与内部表的名称匹配lt_where_used_data_of_coll

相关内容

  • 没有找到相关文章

最新更新