Application Development and Automation 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: 
Read only

internal table error

Former Member
0 Likes
2,259

hi,

i have started learning sap abap recently.

i have written a report but at the time of activating it is showing

error

"the work area it_itab is not long enough".

and my report is

REPORT ZPROG2.

TABLES: ZTABLE2.

DATA:BEGIN OF IT_ITAB OCCURS 0,

EMPNO LIKE ZTABLE2-DEPTNO,

END OF IT_ITAB.

SELECT * FROM ZTABLE1 INTO TABLE IT_ITAB.

END SELECT.

LOOP AT IT_ITAB.

WRITE:/ IT_ITAB .

ENDLOOP.

please give me the solution i will be thankfull.

11 REPLIES 11
Read only

Former Member
1,310

YOU NEED TO SELECT DATA ACCORDING TO YOUR INTERNAL TABLE DESIGN,

REPORT ZPROG2.

TABLES: ZTABLE2.

DATA:BEGIN OF IT_ITAB OCCURS 0,

EMPNO LIKE ZTABLE2-DEPTNO,

END OF IT_ITAB.

SELECT DEPTNO  FROM ZTABLE1 INTO TABLE IT_ITAB. "<===CORRECTION
END SELECT.

LOOP AT IT_ITAB.
WRITE:/ IT_ITAB-EMPNO .
ENDLOOP.

Read only

Former Member
0 Likes
1,310

Hi Dev Kumar

Don't use endselect.

u will get the proper result.

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,310

Hello Kumar

Using an itab to select data you must not used the ENDSELECT statement (exception: APPENDING itab).

In addition, if you only want to select specific fields then add the following option to the select statement:

SELECT * FROM ZTABLE1 INTO CORRESPONDING FIELDS OF TABLE IT_ITAB.
""END SELECT.  " => not required because you make an array fetch

Regards

Uwe

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,310

YOu cannot pour 10 cups of cofee into a single cup...

Its the same situation here....select only the needed fields....

Read only

Former Member
0 Likes
1,310

Hi,

First remove * from your select query. Select only empno into your internal table because you have declared your internal table that way. Second thing your target area is an internal table(INTO TABLE it_tab), so don't use ENDSELECT.

SELECT-----ENDSELECT is only used in situation when your target firls is a workarea.

when you select data from a ztable into an internal table, data comes into your internal table in one go this is called array fetch. So no need to use ENDSELECT.

Regards

Abhijeet

Read only

Former Member
0 Likes
1,310

Hi Dev,

Select only the field EMP_NO from the table IT_ITAB, because your ZTABLE1 might be containing more than one fields. In your select statement you are selecting *, ie., all fields into table IT_ITAB which has only one field.

Do not use ENDSELECT and always try to use WHERE condition in a Select statement.

Regards,

Chandra Sekhar

Read only

Former Member
0 Likes
1,310

Hi,

ur select querry should be like

select EMPNO

from ztable1

into table it_tab.

no need of endselect....

or u can use into corresponding fields ,

that is like..

select *

from ztable1

into corresponding fields of table it_tab.

Read only

Former Member
0 Likes
1,310

hi kumar,

EMPNO LIKE ZTABLE2-DEPTNO,

END OF IT_ITAB.

SELECT * FROM ZTABLE1 INTO TABLE IT_ITAB

*you are defining internal table for only dept-no field in the table ztable2.

  • so your itab space can only have space to occupy deptno field.

  • but in select stmt you are selecting all the fields from ztable2,which has no space to occupy in your internal table. so you better removw * from your select stmtand specify deptno.

regards

manju

Read only

Former Member
0 Likes
1,310

hi kumar,

EMPNO LIKE ZTABLE2-DEPTNO,

END OF IT_ITAB.

SELECT * FROM ZTABLE1 INTO TABLE IT_ITAB

*you are defining internal table for only dept-no field in the table ztable2.

  • so your itab space can only have space to occupy deptno field.

  • but in select stmt you are selecting all the fields from ztable2,which has no space to occupy in your internal table. so you better remove * from your select stmtand specify deptno.

regards

manju

Read only

Former Member
0 Likes
1,310

hi kumar,

*you are defining internal table for only dept-no field in the table ztable2.

  • so your itab space can only have space to occupy deptno field.

  • but in select stmt you are selecting all the fields from ztable2,which has no space to occupy in your internal table. so you better remove * from your select stmtand specify deptno.

regards

manju

Read only

Former Member
0 Likes
1,310

hi kumar,

*you are defining internal table for only dept-no field in the table ztable2.

  • so your itab space can only have space to occupy deptno field.

  • but in select stmt you are selecting all the fields from ztable2,which has no space to occupy in your internal table.

*so you better remove * from your select stmtand specify deptno.

regards

manju