2022 Nov 04 3:31 PM
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.
2022 Nov 04 4:36 PM
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.
2022 Nov 04 5:04 PM
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.
2022 Nov 04 5:36 PM
"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.
2022 Nov 04 6:00 PM
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.
2022 Nov 04 5:47 PM
Hello,
Are you using?
SELECT...ENDSELECT.
Could you please paste the entire code?
Regards.
2022 Nov 04 5:50 PM
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.
2022 Nov 04 5:59 PM
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.
2022 Nov 04 6:29 PM
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,
2022 Nov 06 7:39 AM
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.
2022 Nov 05 8:57 AM
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.
2022 Nov 06 7:43 AM
Don't use OCCURS, it's an obsolete form because it can lead to obscure errors.