01-14-2016 6:12 AM
Hello I have been working on a simple ALV Grid Program.
But to my surprise,I have been getting an error
"WA_FCAT CANNOT BE CONVERTED TO THE LINE TYPE OF IT_FCAT"
Here is the Code:
*&---------------------------------------------------------------------*
*& Report ZALV_REPORT *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
INCLUDE ZALV_REPORT_TOP . " global Data
* INCLUDE ZALV_REPORT_O01 . " PBO-Modules *
* INCLUDE ZALV_REPORT_I01 . " PAI-Modules *
INCLUDE ZALV_REPORT_F01 . " FORM-Routines *
INITIALIZATION.
AT SELECTION-SCREEN.
START-OF-SELECTION.
perform f_get_data.
END-OF-SELECTION.
if not it_vbak is initial.
perform f_fieldcat_alv.
endif.
*&---------------------------------------------------------------------*
*& Include ZALV_REPORT_TOP Report ZAL*
*& *
*&---------------------------------------------------------------------*
REPORT ZALV_REPORT.
type-pools: slis.
data: gs_vbak type vbak.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
SELECT-OPTIONS: S_VBELN FOR GS_VBAK-VBELN.
SELECTION-SCREEN END OF BLOCK B1.
TYPES: begin of ty_vbak,
VBELN type VBELN_VA,
ERDAT type ERDAT,
ERZET type ERZET,
ERNAM type ERNAM,
ANGDT type ANGDT_V,
BNDDT type BNDDT,
AUDAT type AUDAT,
VBTYP type VBTYP,
TRVOG type TRVOG,
AUART type AUART,
AUGRU type AUGRU,
end of ty_vbak.
DATA: it_vbak type table of ty_vbak,
wa_vbak type ty_vbak,
it_fcat type standard table of slis_t_fieldcat_alv,
wa_fcat type slis_fieldcat_alv.
*&---------------------------------------------------------------------*
*& Include ZALV_REPORT_F01 *
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form f_get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_get_data .
refresh : it_vbak.
clear : it_vbak.
if not s_vbeln is initial.
SELECT VBELN
ERDAT
ERZET
ERNAM
ANGDT
BNDDT
AUDAT
VBTYP
TRVOG
AUART
AUGRU
FROM VBAK INTO TABLE IT_VBAK
WHERE VBELN IN S_VBELN.
ELSE.
SELECT VBELN
ERDAT
ERZET
ERNAM
ANGDT
BNDDT
AUDAT
VBTYP
TRVOG
AUART
AUGRU
FROM VBAK INTO TABLE IT_VBAK
UP TO 100 ROWS.
endif.
ENDFORM. " f_get_data
*&---------------------------------------------------------------------*
*& Form f_fieldcat_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_fieldcat_alv .
refresh: it_fcat.
clear: wa_fcat.
wa_fcat-row_pos = '1'.
wa_fcat-col_pos = '1'.
wa_fcat-fieldname = 'VBELN'.
wa_fcat-tabname = 'it_fcat'.
wa_fcat-seltext_m = 'Sales Order'.
append wa_fcat to it_fcat.
clear : wa_fcat.
ENDFORM. " f_fieldcat_alv
I tried checking everything in data declaration but I did not find any fault..
I Do not know what is wrong with the code.
Please help.Thank you in advance.
01-14-2016 6:20 AM
Hi Ashim,
The error was in Fieldcat declaration. You should declared the internal table
it_fcat type slis_t_fieldcat_alv,
wa_fcat type slis_fieldcat_alv.
01-14-2016 6:20 AM
Hi Ashim,
The error was in Fieldcat declaration. You should declared the internal table
it_fcat type slis_t_fieldcat_alv,
wa_fcat type slis_fieldcat_alv.
01-14-2016 6:20 AM
Hi,
it_fcat type standard table of slis_t_fieldcat_alv,
It should be it_fcat type slis_t_fieldcat_alv
Regards,
Taiyeb
01-14-2016 6:23 AM
Hi Ashim,
please declare correctly.
i.e
it_fcat type slis_t_fieldcat_alv,
wa_fcat type slis_fieldcat_alv.
01-14-2016 7:33 AM
So you declared it_fcat as a table of tables. Use either
it_fcat type slis_t_fieldcat_alv,
or
it_fcat type standard table of slis_fieldcat_alv,
Regards,
Raymond
01-17-2016 9:55 PM