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: 

what is the difference between occurs0 and occurs1

Former Member
0 Kudos

pls explain about the difference between occurs0 and occurs1 in sap-abap.

7 REPLIES 7

Former Member
0 Kudos

Hi,

When you give OCCURS 0,

the incremented memory in Internal table will be : 8KB

when you give occurs 1 ,

the incremented memory in Internal table will be : one record of memory.

Means,

Initially, the internal table has 8 KB of memory.

if that is filled out with data, then the memory will be incremented according to OCCURS parameter.(wat i gave in the above).

Reward points if helpful.

Regards

sandeep Reddy

Former Member
0 Kudos

Hi Suresh,

WELCOME TO SDN

Please check this link

Occurs 1 allocates 1 unit of memory(Sufficient to hold one record) and and when one record is appended, one more unit of memory is allocated.

Occurs 0 will allocate memory dynamically.It will not allocate any memory when the itab is declared.

Coming to performance: If you know that you will store only one single value in the Internal table If you use OCCURS 1. It would perform well than OCCURS 0.

Occurs 0 keeps on incrementing when there is a value. But Occurs 1 will assign a single space even though there is no value.

Lets suppose you did not get any values from the DB after a select, in this case if you write Occurs 0 it will not allocate any single space in the memory. If you write OCCURS1 it will pre allocates some memory.

Hope this helps...

Best regards,

raam

Former Member
0 Kudos

Occurs key word is used in creation of internal tables.

1)data: itab like mara occurs 1 with header line.

It allocates the memory for one record in your presentation system.

If more no.of records it automatically creates the memory those records.

2) data: itab like mara occurs 0 with header line.

In this case

first time 100 records comes to the internal table. It allocates the memory for 100 records.

Next times 10 records comes in this case also it allocates memory for another 100 records.

The allocation of memory depends on first time how many records comes to the internal table.

3) data: begin of itab occurs 1,

end of itab.

The above is also internalble with header line.

If use Begin of keyword the internal tables are by default with header line. We no need to explicitly specify the with header line keyword.

Former Member
0 Kudos

HI Frd

Occurs 0

When you declare the itab as occurs 0, the system allocates memory in multiples of 8kb as and when the the itab needs it ie depending on the number of entries in the itab.

Occurs 1

only one character system will allocates memory

Reward Me Points

By

Pari

uwe_schieferstein
Active Contributor
0 Kudos

Hello Suresh

Common to both is that the usage of OCCURS is a sign of poor programming.

Regards

Uwe

0 Kudos

I believe what Uwe is trying to say is stay away from using OCCURS - it's obsolete programming and will lead to poorer performance.

Instead, use TYPES to define your structure, DATA to declare your itab and work area.

TYPES: begin of t_tab,
.
.
.
.
.
TYPES: end of t_tab.

DATA: i_tab type standard table of t_tab,
         wa_tab like line of i_tab.

Edited by: robert phelan on May 19, 2008 11:59 PM

0 Kudos

Good answer Uwe.