1

While displaying an ALV I get a crash report when executing the program. To create an ALV I have followed a few tutorials and stuff and at the moment it looks like this:

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

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.

Any help is much appreciated.

EDIT: As was suggested I implemented another way of displaying an ALV that can be found below. 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( ).
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Erik
  • 361
  • 5
  • 16
  • 1
    Use class `cl_salv_table` instead. `REUSE_ALV_GRID_DISPLAY` is very old and rusty. The error you're facing is a typical fieldcat problem because the module doesn't validate your input. Also try to remove `i_structure_name` from your exporting parameters –  Jul 12 '17 at 08:53
  • @lausek I didn't know it was old and rusty. Guides I have followed were from 2015 and didn't mention that. I implemented your suggestion and it works fine now. I still don't know why it didn't work before though. – Erik Jul 12 '17 at 09:09

1 Answers1

5

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. Also make sure that the names match those of your internal table lt_where_used_data_of_coll

  • I thought ABAP was not case sensitive? Does the field name and Table name get capitalized even when i declare them in lower case? The declaration of my type, table and fieldnames was as follows: `TYPES: BEGIN OF lty_where_used_data_of_coll, table_id TYPE tabname, table_description TYPE as4text, nr_of_records TYPE i, END OF lty_where_used_data_of_coll. DATA: lt_where_used_data_of_coll TYPE STANDARD TABLE OF lty_where_used_data_of_coll.` – Erik Jul 12 '17 at 09:41
  • Welcome to ABAP :). Even though you have defined your types and fieldnames in lowercase, the ALV function module you used internally calls to another FM REUSE_ALV_FIELDCATALOG_MERGE, which only works when you provide the fieldnames in uppercase letters – Marco Hernández Jul 12 '17 at 15:27
  • 4
    > I thought ABAP was not case sensitive @Erik Anything you write between single quotes in ABAP ' ' is case sensitive :-) – Kush Kashyap Jul 12 '17 at 17:45