Skip to Content
avatar image
Former Member

internal table error

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.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

11 Answers

  • Aug 31, 2008 at 01:20 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 31, 2008 at 01:44 PM

    Hi Dev Kumar

    Don't use endselect.

    u will get the proper result.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 31, 2008 at 04:59 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 01, 2008 at 04:19 AM

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

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 04:23 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 04:25 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 04:29 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 01:34 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 01:35 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 01:35 PM

    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

    Add comment
    10|10000 characters needed characters exceeded