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

occurs

Former Member
0 Likes
921

what is the diff between OCCURS 0 and OCCURS 1 while creating internal tables?

what is the diff between OCCURS 0 and OCCURS 1 while creating internal tables?

6 REPLIES 6
Read only

sridhar_k1
Active Contributor
0 Likes
894

Occurs 0 does not reserve space for the itab at the time of declaration, and occurs 1 reserves 1 line when the itab is declared.

Regards

Sridhar

Read only

Former Member
0 Likes
894

Occurs 0 creates an internal table with no rows at the time of creation. OCCURS 1 creates a table with 1 physical row at creation time.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
894

OCCURS 1 actually allocates memory space for 1 line of the internal table. OCCURS 0 allocates no memeory space when the internal table is created. The memeory space is allocated when filling the internal table.

Really, you should not be using the OCCURS extension when defining internal tables as it is obselete. You should define a type instead.

Types: begin of ttab,
       fld1 type c,
       end of ttab.

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

REgards,

Rich Heilman

Read only

uwe_schieferstein
Active Contributor
0 Likes
894

Hello Sudharasan

As Rich Heilman already said itab's with header lines are obsolete.

For me, using itab's with header lines is worst ABAP programming possible because these programs are a mess to read and understand. Such programs are highly error-prone when it comes to maintaining.

Regards

Uwe

Read only

abdul_hakim
Active Contributor
0 Likes
894

hi

occurs 0-->No memory allocated at the time of cretion

occurs 1-->Memory alloted to a line at the time of creation.

Note:Interal table with header lines are oldest form of

internal tables.

Cheers,

Abdul Hakim

Read only

Former Member
0 Likes
894

hi

good

there is besically no difference between the occurs 0 and occurs 1 both of them acquire the same memory.If you know the exact amount of that that you r going to fetch from the database than give the same number with occurs otherwise it doesnot make any difference wheather you give occur 0 or 1, even though you r taking less amount of data it ll use the same memory area.

thanks

mrutyun