Question

Good Day Everyone,

There is this something i've been trying to exercise in abap and that is the Displaying of column datas in ALV by retrieving the values from excel file into an internal table. I've been trying to debug my program for quite some time now and i can't seem to solve the error it's been stating which is "Field symbol has not yet been assigned" please guide me. I already made some research on how to solve this short dump error but most of the other issues posted on the net is selected from some specific table with column fields. I was just wondering that maybe my case is a little bit different from others.

The function that retrieved the values from excel is properly working and i have no problem at all in displaying them.Below is the code i constructed.

TYPE-POOLS: truxs,
        slis.

TYPES: BEGIN OF t_itab,
      col1 TYPE char20,
      col2 TYPE char20,
      col3 TYPE char20,
      col4 TYPE char20,
      col5 TYPE char20,
   END OF t_itab,
   t_it_itab type STANDARD TABLE OF t_itab.

Data: gt_tab TYPE t_it_itab,
  wa_tab TYPE t_itab,
  g_numrows TYPE i.

PARAMETERS: p_fname TYPE c LENGTH 50.

INITIALIZATION.

AT SELECTION-SCREEN OUTPUT.

AT SELECTION-SCREEN.
AT SELECTION-SCREEN on VALUE-REQUEST FOR p_fname.
DATA: l_filename LIKE  IBIPPARMS-PATH.
CALL FUNCTION 'F4_FILENAME'
 EXPORTING
   PROGRAM_NAME        = SYST-CPROG
   DYNPRO_NUMBER       = '1000'
 IMPORTING
   FILE_NAME           = l_filename
        .
p_fname = l_filename.

START-OF-SELECTION.

DATA: lc_fname TYPE RLGRAP-FILENAME,
  lt_tab TYPE TRUXS_T_TEXT_DATA.

  lc_fname = p_fname.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
  EXPORTING
    I_TAB_RAW_DATA             = lt_tab
    I_FILENAME                 = lc_fname
  TABLES
    I_TAB_CONVERTED_DATA       = gt_tab
  EXCEPTIONS
    CONVERSION_FAILED          = 1
  OTHERS                       = 2
      .
IF SY-SUBRC <> 0.
  WRITE 'Error'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

" Delete First Row / HEADER
DELETE gt_tab INDEX 1.

IF gt_tab[] is INITIAL.
  MESSAGE 'No Record(s) found' TYPE 'I'.
  EXIT.
ELSE.
  PERFORM DisplayALv.
ENDIF.

FORM DISPLAYALV.
 DATA: l_it_fcat type SLIS_T_FIELDCAT_ALV,
       l_wa_fcat TYPE SLIS_FIELDCAT_ALV.

 l_wa_fcat-fieldname = 'col1'.
 l_wa_fcat-ref_tabname = 'gt_tab'.
 l_wa_fcat-reptext_ddic = 'Column 1'.
 l_wa_fcat-outputlen = '30'.
 APPEND l_wa_fcat TO l_it_fcat.
 CLEAR l_wa_fcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    I_CALLBACK_PROGRAM       = sy-repid
    IT_FIELDCAT              = l_it_fcat
    I_DEFAULT          = 'X'
    I_SAVE             = 'A'
  TABLES
    T_OUTTAB           = gt_tab[].

IF SY-SUBRC <> 0.
  WRITE: 'SY-SUBRC: ', SY-SUBRC .
ENDIF.

ENDFORM.

Any tips, tricks and advice in my program would be highly sought. Thanks in Advance

Was it helpful?

Solution

You're using a type which is not defined in the data dictionary. This requires a different approach when creating the ALV fieldcat. Try this:

l_wa_fcat-fieldname = 'COL1'.
l_wa_fcat-inttype = 'C'.
l_wa_fcat-outputlen = '30'.
l_wa_fcat-text_fieldname = 'Column 1'.
l_wa_fcat-seltext_s = 'Column 1'.

Also make sure you enter the fieldname value with capitalized letters.

OTHER TIPS

I'm no ABAP expert but I noticed 2 things in the code you posted:

  • you said the error is "Field symbol has not yet been assigned" but you have no field symbol in your code. Maybe it's used inside one of the function modules you call. If so, try to post the code where the error pops up;
  • you use gt_tab[] which, if I remember well, is the way to access the body of an internal table with header line. In your code gt_tab is not an internal table with header line, but you use it to store one with function 'TEXT_CONVERT_XLS_TO_SAP' ;

Try to post the code where the error is being generated.

Regards, Sergiu

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top