简体   繁体   English

调用 REUSE_ALV_GRID_DISPLAY 时崩溃“尚未分配字段符号”

[英]Crash "Field symbol has not yet been assigned" when calling REUSE_ALV_GRID_DISPLAY

While displaying an ALV I get a crash report when executing the program.在显示 ALV 时,我在执行程序时收到崩溃报告。 To create an ALV I have followed a few tutorials and stuff and at the moment it looks like this:为了创建一个 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' is my local table that I have already filled with a working function earlier in my program. 'lt_where_used_data_of_coll' 是我的本地表,我已经在我的程序早期填充了一个工作函数。 This function works and I have tested it and the table fills itself with data.此功能有效,我已经对其进行了测试,并且表格中会填满数据。 My next step was displaying this data to the end user.我的下一步是向最终用户显示这些数据。 The error report I receive when executing this program is:我在执行这个程序时收到的错误报告是:

Short text: Field symbol has not yet been assigned.短文本: Field symbol has not yet been assigned.

What happened?:发生了什么?:

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.

Error analysis:错误分析:

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

Trigger Location of Runtime Error :运行时错误的触发位置

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

I really don't know how to start finding my mistake.我真的不知道如何开始发现我的错误。 It seems like it runs bad when calling a function from ABAP itself.从 ABAP 本身调用函数时,它似乎运行得很糟糕。

Any help is much appreciated.任何帮助深表感谢。

EDIT: As was suggested I implemented another way of displaying an ALV that can be found below.编辑:正如我所建议的,我实现了另一种显示 ALV 的方式,可以在下面找到。 This way works fine and gives no errors.这种方式工作正常并且没有错误。 Question still remains why the older method does give me an error.问题仍然存在,为什么旧​​方法确实给我一个错误。

I replaced the entire block of code above with this:我用这个替换了上面的整个代码块:

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( ).

why the older method does give me an error为什么旧方法确实给我一个错误

Field catalog names are case sensitive.字段目录名称区分大小写。 Capitalize every fieldname and tabname value and see if the error's still there.将每个fieldnametabname值大写,看看错误是否仍然存在。 Also make sure that the names match those of your internal table lt_where_used_data_of_coll还要确保名称与您的内部表lt_where_used_data_of_coll的名称匹配

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM