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

REG REPORT

Former Member
0 Likes
466

TABLES : MARA.

TYPES : BEGIN OF ITAB,

MATNR TYPE MARA-MATNR,

ERNAM TYPE MARA-ERNAM,

END OF ITAB.

DATA : ITAB1 LIKE STANDARD TABLE OF ITAB WITH HEADER LINE .

PARAMETER : MATERIAL LIKE MARA-MATNR.

SELECT MATNR ERNAM FROM MARA INTO TABLE ITAB1 WHERE MATNR = MATERIAL.

LOOP AT ITAB1.

WRITE : ITAB1-MATNR, ITAB1-ERNAM.

ENDLOOP.

when i executing this simple report it showing error, that matnr is not there in itab1

pls help me.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
449

hi ali,

when u use types keyword then u have to use type keyword while declaring bcozzzz types is used for user defined structure.

like is used for declaring existing sap objects [database tables, standard structures,....... type is used for declaring existing data types [int, float, user defined structures......]

try like this,

DATA : ITAB1 type STANDARD TABLE OF ITAB WITH HEADER LINE .

if helpful reward some points.

with regards,

Suresh Aluri.

4 REPLIES 4
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
449

Hi


TABLES : MARA.

TYPES : BEGIN OF ITAB,
MATNR TYPE MARA-MATNR,
ERNAM TYPE MARA-ERNAM,
END OF ITAB.

 " See the change in below line, You can use TYPE TABLE OF
 " since ITAB is TYPE created TYPES.
DATA : ITAB1 TYPE TABLE OF ITAB WITH HEADER LINE .

PARAMETER : MATERIAL LIKE MARA-MATNR.

SELECT MATNR ERNAM FROM MARA INTO TABLE ITAB1 WHERE MATNR = MATERIAL.

LOOP AT ITAB1.
WRITE : ITAB1-MATNR, ITAB1-ERNAM.
ENDLOOP.

Regards,

Sesh

Read only

Former Member
0 Likes
450

hi ali,

when u use types keyword then u have to use type keyword while declaring bcozzzz types is used for user defined structure.

like is used for declaring existing sap objects [database tables, standard structures,....... type is used for declaring existing data types [int, float, user defined structures......]

try like this,

DATA : ITAB1 type STANDARD TABLE OF ITAB WITH HEADER LINE .

if helpful reward some points.

with regards,

Suresh Aluri.

Read only

former_member196280
Active Contributor
0 Likes
449

DATA : ITAB1 <b>LIKE</b> STANDARD TABLE OF ITAB WITH HEADER LINE .

If you use LIKE it will check for standard table type

Now you have to do either of this correction.

1) TABLES : MARA.

TYPES : BEGIN OF ITAB,

MATNR TYPE MARA-MATNR,

ERNAM TYPE MARA-ERNAM,

END OF ITAB.

DATA : ITAB1 LIKE STANDARD TABLE OF <u><b>MARA</b></u> WITH HEADER LINE .

PARAMETER : MATERIAL LIKE MARA-MATNR.

SELECT MATNR ERNAM FROM MARA INTO TABLE ITAB1 WHERE MATNR = MATERIAL.

LOOP AT ITAB1.

WRITE : ITAB1-MATNR, ITAB1-ERNAM.

ENDLOOP.

******************************8

OR

2) TABLES : MARA.

TYPES : BEGIN OF ITAB,

MATNR TYPE MARA-MATNR,

ERNAM TYPE MARA-ERNAM,

END OF ITAB.

DATA : ITAB1 <u><b>TYPE</b></u> STANDARD TABLE OF ITAB WITH HEADER LINE .

PARAMETER : MATERIAL LIKE MARA-MATNR.

SELECT MATNR ERNAM FROM MARA INTO TABLE ITAB1 WHERE MATNR = MATERIAL.

LOOP AT ITAB1.

WRITE : ITAB1-MATNR, ITAB1-ERNAM.

ENDLOOP.

Close the thread if your question is answered.

Regards,

SaiRam

Read only

Former Member
0 Likes
449

hi

error is ur taking ITAB! as like ITAB

you have to refer that table as TYPE

reward if usefull

now it won't give any error

TABLES : MARA.

TYPES : BEGIN OF ITAB,

MATNR TYPE MARA-MATNR,

ERNAM TYPE MARA-ERNAM,

END OF ITAB.

DATA : ITAB1 <b><u>type</u></b> STANDARD TABLE OF ITAB WITH HEADER LINE .

PARAMETER : MATERIAL LIKE MARA-MATNR.

SELECT MATNR ERNAM FROM MARA INTO TABLE ITAB1 WHERE MATNR = MATERIAL.

LOOP AT ITAB1.

WRITE : ITAB1-MATNR, ITAB1-ERNAM.

ENDLOOP.