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

raising a n error message

Former Member
0 Likes
1,569

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

MATKL LIKE MARA-MATKL,

UOM LIKE MARA-MEINS,

LAEDA LIKE MARA-LAEDA,

END OF ITAB.

DATA: WA_ITAB LIKE LINE OF ITAB.

SELECT * FROM MARA INTO TABLE ITAB WHERE MATNR = '521196'.

LOOP AT ITAB INTO WA_ITAB.

WRITE : WA_ITAB-MATKL.

ENDLOOP.

messaging is coming as 'The work area "ITAB" is not long enough.'

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,497
TYPES: BEGIN OF TY_ITAB,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MATKL LIKE MARA-MATKL,
UOM LIKE MARA-MEINS,
LAEDA LIKE MARA-LAEDA,
END OF TY_ITAB.

DATA: ITAB TYPE TABLE  OF TY_ITAB,
          WA_ITAB TYPE TY_ITAB.

Regards

Kannaiah

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

MATKL LIKE MARA-MATKL,

UOM LIKE MARA-MEINS,

LAEDA LIKE MARA-LAEDA,

END OF ITAB.

DATA: WA_ITAB LIKE LINE OF ITAB.

SELECT * FROM MARA INTO TABLE ITAB WHERE MATNR = '521196'.

LOOP AT ITAB INTO WA_ITAB.

WRITE : WA_ITAB-MATKL.

ENDLOOP.

messaging is coming as 'The work area "ITAB" is not long enough.'

11 REPLIES 11
Read only

Former Member
0 Likes
1,497

Make data declaration as:

TYPES: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

MATKL LIKE MARA-MATKL,

UOM LIKE MARA-MEINS,

LAEDA LIKE MARA-LAEDA,

END OF ITAB.

DATA: WA_ITAB TYPE ITAB.

Read only

0 Likes
1,497

Unable to interpret "OCCURS". Possible causes of error: Incorrect spelling or comma error.

Read only

Former Member
0 Likes
1,497

Declare the internal table

data: itab like mara occurs 0 with header line.

Read only

Former Member
0 Likes
1,497

Hi,

Ur selecting all feilds fron mara into ITAB but in Itab there only few filds declared.

So use

data itab like mara occurs 0 with header line.

Or

SELECT MATNR MTART MATKL UOM LAEDA FROM MARA INTO TABLE ITAB WHERE MATNR = '521196'.

Reward pts if helpfull.

Regards,

Dhan

Read only

Former Member
0 Likes
1,497

you are selecting all the columns (using SELECT *) but your itab has only five fields...this is the reason for this error msg...

either declare your table as

data itab type table of mara.

OR

modify your select statement to select only the fields that are a part of the internal table

SELECT MATNR MTART MATKL MEINS LAEDA FROM MARA INTO TABLE ITAB WHERE MATNR = '521196'.

Read only

Former Member
0 Likes
1,498
TYPES: BEGIN OF TY_ITAB,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MATKL LIKE MARA-MATKL,
UOM LIKE MARA-MEINS,
LAEDA LIKE MARA-LAEDA,
END OF TY_ITAB.

DATA: ITAB TYPE TABLE  OF TY_ITAB,
          WA_ITAB TYPE TY_ITAB.

Regards

Kannaiah

Read only

Former Member
0 Likes
1,497

hi,

Itab has

MATNR

MTART

MATKL

UOM

LAEDA only these fields

use

select MATNR

MTART

MATKL

UOM

LAEDA from mara

INTO TABLE ITAB WHERE MATNR = '521196'.

Reward points if helpful

Regards,

priya

Read only

Former Member
0 Likes
1,497

Hi,

You have created an internal table with 5 fields and you are trying to fill that table with all the fields from the table MARA.

SO you either modify the SELECT stmt by changing * to 5 fields or change the structure of the internal table to mara.

SELECT MATNR MTART MATKL MEINS LAEDA LAEDA,

FROM MARA INTO TABLE ITAB WHERE MATNR = '521196'

or

data : BEGIN OF ITAB OCCURS 0.

include structure mara.

data end of itab.

Thanks and Regards.

Read only

Former Member
0 Likes
1,497

Hi,

Chnage the select statement as below :



DATA: BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MATKL LIKE MARA-MATKL,
UOM LIKE MARA-MEINS,
LAEDA LIKE MARA-LAEDA,
END OF ITAB.


DATA: WA_ITAB LIKE LINE OF ITAB.


SELECT * FROM MARA INTO corresponding fields of TABLE ITAB WHERE MATNR = '521196'.

LOOP AT ITAB INTO WA_ITAB.
WRITE : WA_ITAB-MATKL.
ENDLOOP.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,497

Hi,

you should use 'CORRESPONDING FIELDS OF 'in the select statement..

Regards,

venkat n

Read only

Former Member
0 Likes
1,497

hi,

Tables : mara .

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

MATKL LIKE MARA-MATKL,

UOM LIKE MARA-MEINS,

LAEDA LIKE MARA-LAEDA,

END OF ITAB.

DATA: WA_ITAB LIKE LINE OF ITAB.

SELECT * FROM MARA INTO corresponding fields of TABLE ITAB WHERE MATNR = '521196'.

if sy-subrc = 0.

LOOP AT ITAB INTO WA_ITAB.

WRITE : WA_ITAB-MATKL.

ENDLOOP.

endif.