Application Development 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: 

Diff between Occurs 0 and other occurs N

Former Member
0 Kudos

Hi Experts,

I could not understand the clear difference between 'occurs 0' and other occur statements like occur 9 or 'occur N'.

I wish to know how it is happening in real time.

If you know any elearning which clearly explains the difference, please post the links.

Thanks and regards,

Suresh

1 ACCEPTED SOLUTION

valter_oliveira
Active Contributor
0 Kudos

With OCCURS 0, the memory allocation will be dynamic (made by the system) and was usefull when you didn't know what would be the size of the itab. Now, if you knew previously that itab would be 500 records at a time (for example, read 3 files with 500 lines), was better to use OCCURS 500 (initial memory allocation made by you).

Most important thing: OCCURS is an obsolete statement. Instead, use itab with work area (it's faster, more memory efficient and not obsolete). Thats why I talked in the past tence.

Standard Tables Before Release 3.0

Before Release 3.0, internal tables all had header lines and a flat-structured line type. There were no independent table types. You could only create a table object using the OCCURS addition in the DATA statement, followed by a declaration of a flat structure:

DATA: BEGIN OF itab OCCURS n,

...

f1...,

f2...,

...

END OF itab.

This statement declared an internal table itabwith the line type defined following the OCCURS addition. Furthermore, all internal tables had header lines.

The number n in the OCCURS addition had the same meaning as in the INITIAL SIZE addition from Release 4.0. Entering u20180u2019 had the same effect as omitting the INITIAL SIZE addition. In this case, the initial size of the table is determined by the system.

Regards,

Valter Oliveira.

5 REPLIES 5

Former Member
0 Kudos

with occurs , the system allocates 8 kb memeory,

after that if u r rogrma needs moree sace then system allocates memory dyannmiacaly.

Better u go with occurs .

if u go with occurs n then if sace is insufficient then u might get error

Former Member
0 Kudos

occurs 0 by default sets initial size of internal table to be = 8KB

while with occurs n, no initial size is set, entire mem allocation is done dymnamically

Edited by: Amit Gupta on Oct 11, 2008 2:39 PM

valter_oliveira
Active Contributor
0 Kudos

With OCCURS 0, the memory allocation will be dynamic (made by the system) and was usefull when you didn't know what would be the size of the itab. Now, if you knew previously that itab would be 500 records at a time (for example, read 3 files with 500 lines), was better to use OCCURS 500 (initial memory allocation made by you).

Most important thing: OCCURS is an obsolete statement. Instead, use itab with work area (it's faster, more memory efficient and not obsolete). Thats why I talked in the past tence.

Standard Tables Before Release 3.0

Before Release 3.0, internal tables all had header lines and a flat-structured line type. There were no independent table types. You could only create a table object using the OCCURS addition in the DATA statement, followed by a declaration of a flat structure:

DATA: BEGIN OF itab OCCURS n,

...

f1...,

f2...,

...

END OF itab.

This statement declared an internal table itabwith the line type defined following the OCCURS addition. Furthermore, all internal tables had header lines.

The number n in the OCCURS addition had the same meaning as in the INITIAL SIZE addition from Release 4.0. Entering u20180u2019 had the same effect as omitting the INITIAL SIZE addition. In this case, the initial size of the table is determined by the system.

Regards,

Valter Oliveira.

0 Kudos

Yep. Don't use OCCURS at all. As a side point, if you did use OCCURS 0 with an inner table, you'd find that you could rapidly run out of memory. Every record in the outertable would take 8kb.

Former Member
0 Kudos

I have found the solution