cancel
Showing results for 
Search instead for 
Did you mean: 

Difference Between INITIAL SIZE and OCCURS N

Former Member
0 Kudos

Hi friends,

Can u please clear me with the "Difference Between INITIAL SIZE and OCCURS N"

Expecting Your answers

Thanks & Regards,

R.Kripa.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hai kripa,

<b>1. Difference between INITIAL SIZE and OCCURS?

OCCURS is obsolete and is no longer valid in OO ABAP. It defines an internal table with memory allocated to store a specified number of rows of the internal table in the main memory. It also provides you with a header line by default.

INITIAL SIZE will also allocate the initial memory but will not define your header line. The only thing is that it cannot be used with generic table types like ANY TABLE or INDEX TABLE.

2. When should I use INITIAL size. Are there any specific cases?

If you are in newer versions, it may be advisable to start using it in every case.

3. Is there any performance issue if I use INITIAL SIZE?

Using initial sze you are telling the system to allocate a certain portion of the available memory for this internal table. Unless you are very confident about the size of your internal table, it is not advisable to reserve this memory. This will be useful only if you know that you will have a specific number of records in your internal table, like preloading all the material types into the table.

4. Why OCCURS is not recommended?

We only know that it is not allowed in ABAP objects, why I don't know. May be any implicit header work area is not in line with object oriented programming.

5. Is it true that if I use OCCURS then the internal table is created with header line? With INITIAL SIZE header line is not created?

As explained above, YES.

6. What is the difference between INITIAL SIZE 0 and INITIAL SIZE 10?

Exaplained above in 3.

If these answers helped you, please reward and close the post.</b>

Regards,

Srikanth.

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks everyone ......

Different approach to same problem really iam finding it better to understand now ...

Thanks

Cheers

R.Kripa.

Former Member
0 Kudos

Hi Kripa

In earlier versions of SAP , we couldnt define internal table without occurs addition like occurs 0 or occurs 10 etc. Here we are allocating a memory space for the internal table.

While in latter versions of SAP.. we can define internal tables with addition 'type table of ' and here we use Initial siz addition to allocate expected memory space for internal table.

But hree evenif we do not use initial size addtion.. we can define internal table ..this is not the case with occurs addtion.

In case of 'type table of' addtion ..if we don use initial size addtion ..system will automatically assign/allocate memory dynamically depending on number of records available whereas in case of occurs addition ..at the starting itself.. initial extent of size is reserved for the internal table.

So this is the <b>basic difference between two</b>.

I hope you got the point.

Thnaks

Former Member
0 Kudos

Hi Kripa,

INITIAL SIZE specifies how many table lines are to be created initially.

OCCURS n determine the initial number of table lines created.

The only difference is that INITIAL SIZE is used when you define internal table with TYPES and OCCURS is used when you define with DATA.

Rgds,

Prakashsingh

Former Member
0 Kudos

Hello,

When you user INITIAL SIZE <n>,you can specify the initial amount of main memory assigned to an internal table object when you define the data type using the INITIAL SIZE

This size does not belong to the data type of the internal table, and does not affect the type check. You can use the above addition to reserve memory space for <n> table lines when you declare the table object.

When this initial area is full, the system makes twice as much extra space available up to a limit of 8KB. Further memory areas of 12KB each are then allocated.

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>,

...

<fi> ...,

...

END OF <itab>.

The effect of the OCCURS addition is to construct a standard table with the data type <linetype>.

Former Member
0 Kudos

Hi,

Both have the same meaning.

<b>INITIAL SIZE is used when you define internal table TYPES and DATA.

OCCURS is used when you define DATA and not in TYPES.</b>

DATA: BEGIN OF itab OCCURS 0,

f1 TYPE i,

END OF itab.

Declaration of internal deep structures

TYPES: BEGIN OF ty_tab,

f1 TYPE i,

tab TYPE STANDARD TABLE OF vbak

WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0,

END OF ty_tab.

See http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3646358411d1829f0000e829fbfe/content.htm