short Dump: Field symbol has not yet been assigned

17,510

Solution 1

Unfortunately the case does matter here. Change the following lines:

fill_fieldcatalog 1 'carrid' 't_scarr' 10.
fill_fieldcatalog 2 'carrname' 't_scarr' 10.

to

fill_fieldcatalog 1 'CARRID' 't_scarr' 10.
fill_fieldcatalog 2 'CARRNAME' 't_scarr' 10.

Solution 2

Other option would be to do the translation to upper case in your macro. That way you can never make a mistake when calling it.

wa_fieldcat-fieldname = &2.
TRANSLATE wa_fieldcat-fieldname TO UPPER CASE.
wa_fieldcat-tabname = &3.
TRANSLATE wa_fieldcat-tabname TO UPPER CASE.
Share:
17,510
Abap newbie
Author by

Abap newbie

Updated on June 04, 2022

Comments

  • Abap newbie
    Abap newbie almost 2 years

    I am getting a short dump (Field symbol has not yet been assigned) when I run this program. I know that I may get this error when I don't fill the t_fieldcat correctly. As far as I know I have filled the field catalog correctly.

    I cannot figure out where the problem is..Please help.

    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.