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 definition difference

Former Member
0 Likes
1,293

Hello!

I have a doubt about two ways of defining an internal table cos they look alike but i dont really know if the do the same.

First way to define:

DATA: BEGIN OF tvbdpr OCCURS 100.

INCLUDE STRUCTURE vbdpr.

DATA: END OF tvbdpr.

Second way to define:

data: tvbdpr type standard table of vbdpr with header line.

Are they the same?

Regards,

Roberto Okumura.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,162

Hi,

Thanx for all the answers. But i have another doubt.

Is there a way to define an internal table without using "occurs" or "with header line" and at the same time to be able to perform the same operations as if it had a header line?

Thanx again.

9 REPLIES 9
Read only

Former Member
0 Likes
1,162

Hi,

Both declarations declare a internal talbe with a header line.. how ever the initial size of the both declaration is different.

<b>These both are one and same</b>

DATA: BEGIN OF tvbdpr OCCURS 0.

INCLUDE STRUCTURE vbdpr.

DATA: END OF tvbdpr.

data: tvbdpr type standard table of vbdpr with header line.

<b>

*-- This declaration will declare a internal table with</b> a initial size of 100 records..

DATA: BEGIN OF tvbdpr OCCURS 100.

INCLUDE STRUCTURE vbdpr.

DATA: END OF tvbdpr.

Read only

Former Member
0 Likes
1,162

hi

both are not same why beacuse u r specifying size first itself in the declaration

where as in 2nd case u r not specifying size but taking it as type table of vbdpr , but both have the header line.

Regards

sandhya

Read only

Former Member
0 Likes
1,162

HI,

Technically speaking both are having the same functionality but different technical despription.

I mean.

DATA: BEGIN OF tvbdpr OCCURS 100.

INCLUDE STRUCTURE vbdpr.

DATA: END OF tvbdpr.

the system implicitely creates the header line with the help of key word BEGIN OF.

You need to understand the EXPLICIT Work Aread and IMPLICIT Work Area.

data: tvbdpr type standard table of vbdpr with header line.

The system explicitely creates the header line.

Performance wise better to go for data: tvbdpr type standard table of vbdpr with header line. becuase no need to create work area for doing some other calculations at header line level or work aread level.

DATA: BEGIN OF tvbdpr OCCURS 100.

INCLUDE STRUCTURE vbdpr.

DATA: END OF tvbdpr.

first it recoginze the table vbdpr then allocate the memory area for your internal table.

finally, if you want to define the explicit work area better to go for with header line internal table otherwise go without header line .

Read only

Former Member
0 Likes
1,163

Hi,

Thanx for all the answers. But i have another doubt.

Is there a way to define an internal table without using "occurs" or "with header line" and at the same time to be able to perform the same operations as if it had a header line?

Thanx again.

Read only

0 Likes
1,162

hi,

internal table can be used to store & do some operations on multiple records at a time.

without using "occurs" or "with header line" it is not called as a internal table and we cont store multiple records.

But you can define the internal table without header line.

for example,

data: begin of itab occurs 0,

kunnr like kna1-kunnr,

end of itab.

data: itab_witout_header like itab occurs 0.

loop at internal table........endloop. and

read table internaltable...............

some otheroperations are internally liked with the internal table.

without using "occurs" or "with header line" we cant work with the above specified conditions.

You can define the structures for holding the single values at a time.

award points.

sekhar

Read only

0 Likes
1,162

Hi

it is not usually good to use occurs specification and with header line instead u can for work area concept

u can go like this for ex

types: begin of itab,

vbeln like vbak-vbeln,

end of itab.

data: itab1 type table of itab,

wa type itab. -> work area declaration

now u can do the operations thru this work area

it is really good practise to do in this way

still any questions welcome

regards

sandhya

Read only

Former Member
0 Likes
1,162

hi,

speaking with Size.

DATA: BEGIN OF tvbdpr OCCURS 100.

no need to define the size of your internal table with 100 . you can define 0 as well.

becuase, the system will allocates 8KB memory if you define internal table with occurs 0.

if it is 100 then 100 * 8 = 800 kb.

the system try to allocates 800 kb at runtime as per your declaration of internal table. The system automatically increases your size of the internal table once after reaches the storage of your records(8kb), if you specified occurs 0.

OCCURS keyword will create the body of the internal table to hold your records.

data: tvbdpr type standard table of vbdpr with header line.

it allocates and increases your internal table memory depends on your records how much you need to keep in that internal table. system automatically increases your internaltable, if required to store more records.

Read only

Former Member
0 Likes
1,162

Please Don't use occurs. Now it is absolute now.

Use like this.

DATA : tvbdpr TYPE TABLE OF vbdpr. " Internal table without header line

DATA : wa_tvbdpr TYPE vbdpr. " External Work area

And in your example,

1) DATA: BEGIN OF tvbdpr OCCURS 100.

INCLUDE STRUCTURE vbdpr.

DATA: END OF tvbdpr.

Ans : You can add here other additional fields also.

2) data: tvbdpr type standard table of vbdpr with header line.

Ans : You can't add other additional fields here.

Point ???????????

Read only

Former Member
0 Likes
1,162

Thanks for all answers.

Ill award points for all answers.