Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Error: WA cannot be converted to the line type of Internal table

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

bhagaban_pradhan2
Participant
0 Kudos

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.

5 REPLIES 5

bhagaban_pradhan2
Participant
0 Kudos

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.

0 Kudos

Hi,

it_fcat type standard table of slis_t_fieldcat_alv,


It should be it_fcat type slis_t_fieldcat_alv


Regards,

Taiyeb

bhagaban_pradhan2
Participant
0 Kudos

Hi Ashim,

please declare correctly.

i.e

  it_fcat type slis_t_fieldcat_alv,

       wa_fcat type  slis_fieldcat_alv.

raymond_giuseppi
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Thanks.It worked.