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 question

Former Member
0 Likes
1,140

Hi All,

Is there a way of defining an 'Internal Table' without using 'Occurs n' specification.

Regards

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,120

Yes, there is.

Types: Begin of ttab,
       field1 type c,
       field2 type c,
       end of ttab.

data: itab type table of ttab with header line.

Regards,

Rich Heilman

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,121

Yes, there is.

Types: Begin of ttab,
       field1 type c,
       field2 type c,
       end of ttab.

data: itab type table of ttab with header line.

Regards,

Rich Heilman

Read only

0 Likes
1,120

If you don't want to use a head line either, you need to use a word area to access the table.




Types: Begin of ttab,       
       field1 type c,  
       field2 type c,  
       end of ttab.

data: itab type table of ttab.
data: wa like line of itab.


Regards,

Rich Heilman

Read only

venkata_ramisetti
Active Contributor
0 Likes
1,120

Hi

You can write like thi....

TYPES: TYP_MARA TYPE STANDARD TABLE OF MARA.

DATA: T_MARA TYPE TYP_MARA.

Thanks,

Ramakrishna

Message was edited by: Ramakrishna Prasad

Read only

Former Member
0 Likes
1,120

Yes U can declare an internal table without using Occurs n specification. Declare internal table of TYPES....Then declare internal table using this TYPES.

Below is a small code which will help U.

TYPES : BEGIN OF TY_VENDOR_MASTER,

FLAG TYPE C,

LIFNR TYPE LIFNR,

BUKRS TYPE BUKRS,

KTOKK TYPE KTOKK,

END OF TY_VENDOR_MASTER.

This is the TYPES internal table. Now declare internal table as

DATA : IT_VENDOR_MASTER TYPE STANDARD TABLE OF TY_VENDOR_MASTER.

This one u can use to store data which is fetched from database.

To use this internal table for other operations u have to use workarea...

DATA : WA_IT_VENDOR_MASTER TYPE TY_VENDOR_MASTER.

Hope this will be useful.

Pl. award appropriate points.

Is there a way of defining an 'Internal Table' without using 'Occurs n' specification.

Read only

0 Likes
1,120

Thanks Rich, Ramakrishna and Ramesh,

Thanks to all of you.

Rich, Is it better to use 'WITH HEADER LINE' option or 'WORK AREA' option from a Performance perspective.

Ramesh, Actually i used TYPE STANDARD TABLE OF statement for storing data. I then tried to use this internal table with 'FOR ALL ENTRIES IN it'. It gave me an error saying that the 'it' has not been declared using OCCURS.

Thanks to you guys.

Regards.

Read only

0 Likes
1,120

I would say that you should get used to using the TYPE TABLE OF and using work areas instead of header lines. The reason is that in ABAP Objects, the OCCURS and WITH HEADER LINE are not allowed.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,120

Hi George,

If you want to declare a internal table without a 'occurs n' you can do it only if you know an structure name.

For Eg.

You know there is database table called mara. If you want an internal table with the structure similar to mara then use...

data: it_mara like mara-matnr.

For your information if you write an itab without 'occurs n' it becomes a structure.

Hope it helps.

Regards,

Maheswaran.B