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: it_data is not an internal table

0 Kudos
2,986

Hello All,

My requirement is to create an internal table it_data and tried fetching data from VBAK, VBUK and VBKD. After fetching the data records Loop through it_data to run a BDC program which updates the Sale Orders.

I defined my code as below. But receiving an error it_data is not an internal table.

While debugging I could see select statement loading each record into it_data structure and skips at LOOP AT statement. I tried all the ways to define it as an internal table. But did not work.

Kindly help me in this regard.

DATA: BEGIN OF it_data OCCURS 0,

vbeln TYPE vbak-vbeln

..

END OF it_data.

.

.

SELECT a~vbeln v~bstkd v~bstdk......

FROM vbak AS a

INNER JOIN vbuk AS v ON a~vbeln = v~vbeln

INTO it_data.

IF it_data[] NOT INITIAL.

LOOP AT it_data.

REFRESH bdcdata.

PERFORM mapping.

CALL TRANSACTION 'VA02' USING bdcdata MODE 'A'.

ENDLOOP.

ENDIF.

11 REPLIES 11

Eduardo-CE
Active Participant
0 Kudos
2,761

Data: it_data TYPE STANDARD TABLE OF...

Also

SELECT a~vbeln v~bstkd v~bstdk......

FROM vbak AS a

INNER JOIN vbuk AS v ON a~vbeln = v~vbeln

INTO TABLE it_data.

0 Kudos
2,761

Hi,

Thank you for the reply.

I tried as you mentioned. Still I am getting the same error at INTO TABLE it_data. that "IT_DATA is not an internal table."

I am still confused why IT_DATA is not getting considered as an internal table.

When I define as DATA: BEGIN OF it_data OCCURS 0,..... I am not getting error but, While debugging I could see that select statement loading each record into it_data structure and skips at LOOP AT it_data. statement.

Kindly help in this regard.

Thank you much in advance.

Sandra_Rossi
Active Contributor
0 Kudos
2,761

"DATA: BEGIN OF it_data OCCURS 0," is obsolete because it's prone to the error you are experiencing.

"BEGIN OF" and "OCCURS" declares an internal table + a header line. Header lines are obsolete because they are prone to errors. To distinguish the internal table, it's sometimes required to write it using square brackets (see below), otherwise "itab" without square brackets will be considered as being the header line.

itab[]

The right way to declare internal tables is by using TYPE ... TABLE OF ... There are many forms.

0 Kudos
2,761

Hi,

Thank you for the explanation. I have tried with [], error stating that "IT_DATA is not an internal table."

Please suggest how this issue can be resolved. Could you share a sample program to read data from multiple standard tables and writing the internal table data using Loop statement.

Thank you once again.

Eduardo-CE
Active Participant
0 Kudos
2,761

Hello,

Are you using?

SELECT...ENDSELECT. 

Could you please paste the entire code?

Regards.

0 Kudos
2,761

Hi,

Yes.

Please suggest how this issue can be resolved. Could you share a sample program to read data from multiple standard tables and writing the internal table data using Loop statement.

Thank you once again.

Eduardo-CE
Active Participant
0 Kudos
2,761

Hi,

Then theres no need for an internal table, you need a work area, for example:

  TYPES: BEGIN OF ty_data,
vbeln TYPE vbak-vbeln,
rfstk TYPE vbuk-rfstk,
END OF ty_data.

DATA: lw_data TYPE ty_data.

SELECT
a~vbeln
u~rfstk
INTO lw_data
FROM vbak AS a
INNER JOIN vbuk AS u
ON a~vbeln = u~vbeln.

WRITE: lw_data-vbeln,
lw_data-rfstk.

ENDSELECT.

0 Kudos
2,761

Hi,

I have tried this option. Select statement not running more than once in this case, considering more no of Sale Orders to process. Ended up with a runtime error.

Thank you,

matt
Active Contributor
2,761

I have run the above program. It works fine for me.

Please give proper details. "A runtime error" gives no meaningful information. Exactly what runtime error are you getting? And as others have asked you - post your full code.

Sandra_Rossi
Active Contributor
0 Kudos
2,761

How are you "receiving an error it_data is not an internal table"?

Syntax error? Runtime error?

If you have a runtime error, please attach the short dump.

If you have a syntax error, please paste the message and line of code.

matt
Active Contributor
2,761

Don't use OCCURS, it's an obsolete form because it can lead to obscure errors.