Skip to Content
author's profile photo Former Member
Former Member

difference

difference b/w occurs 0,occurs 1,occurs 2

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 12:10 PM

    occurs statement will raise only incase of mememory point.

    if we use occurs 1 for the internal table declaration it will occupy 8 kb memory.

    if we use occurs 2 = 2 * 8kb.like this the internal table will occupy the memory.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 12:15 PM

    Hi,

    Occurs does not limit the number of rows that can be added to the internal table. For example if you specify occurs 10, you can put upto 10 rows into internal table.The number of rows you can put into an internal table is theoritically only limited by the amount of virtual momory available on the application server.

    The system uses the occurs clause only as a guidlines to determine how much memory to allocate. The first time a row is added to the internal table, enough memory is allocated to hold the number of rows specified on the occurs clause. If you use the memory up, more is allocated as needed.

    Alternatively, you can specify occurs 0. If you do this, the system allocated 8KB pages of memory at a time. However there are no advantages to using occurs 0 other than the fact it is only a litter easier to code occurs 0 than it is to estimate the size of the internal table

    For peak performace and minimum wasted momery, choose as occurs value equal to the average maximum number of rows in the table. For Example if most of the time the internal table is filled with a maximum of 100 rows, but every once in a while it is filled with a maximum of 1000 rows, set the occurs value 100.

    Refer to the following links

    diff-bw-occurs-0-and-1

    diff-btn-occurs-0-and-occurs-n

    occurs-0-and-occurs-1

    Modify statement

    <b>Reward if usefull</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 12:17 PM

    hi Srinath,

    occurs statement will allocate memory to the internal table. This is just initialising the table. In case you want to move more number of records into the internal table at run time, the memory allocation is increased accordingly...

    occurs 1 will allocate memory sufficient to hold one table record, similary occurs 2 will allocate memory sufficient to hold 2 table records.

    Occurs 0 will not allocate any memory and will allocate memory dynamically.

    Lokesh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 12:19 PM

    hi,

    OCCURS n is obsolete in OO Context and it is advisable to use INITIAL SIZE instead. The difference between the two is that OCCURS n allocates memory to store specified number of rows in the internal table and also creates a header line, whereas INITIAL SIZE allocates memory for the specified number of rows without creating the header line.

    Occurs 0 ---> By default No Memory Allocation to the Itab. The Allocation will be Dynamically done at Run time.

    Occurs N ---> By Default it will be allocated of Size N. this is not Good Practice in case of performance.

    for Better Performance Use Occurs 0.

    occurs 0, the memory allocation is done by system,

    in case of occurs 100 memory of 100 records allocated initially ,then if records exceeds then system ll allocate memory,

    memory allocation here is known as extent and depend upon basis administrator...

    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.

    You can usually leave it to the system to work out the initial memory requirement. The first time you fill the table, little memory is used. The space occupied, depending on the line width, is 16 <= <n> <= 100.

    It only makes sense to specify a concrete value of <n> if you can specify a precise number of table entries when you create the table and need to allocate exactly that amount of memory (exception: Appending table lines to ranked lists). This can be particularly important for deep-structured internal tables where the inner table only has a few entries (less than 5, for example).

    To avoid excessive requests for memory, large values of <n> are treated as follows: The largest possible value of <n> is 8KB divided by the length of the line. If you specify a larger value of <n>, the system calculates a new value so that n times the line width is around 12KB."

    OCCURS 0 is betten than OCCURS 100 because

    OCCURS 100.

    *****************

    if you use occurs 100, the ABAP memory will allocate for 100 records memory location, some time you have only 20 records at that time the remaining 80 records memory space will waste.

    REAL TIME EXAMPLE: BUS

    ***************************

    In bus total seat is 57, some time only 20 people only will come at that time also bus should go so remaining seats will waste.

    OCCURS 0:

    **************

    OCCURS 0, the memory is not allocated previously, that is optimistic.if you have 20 records the memory will take for only 20 records.

    regards

    kish

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 12:23 PM

    occurs clause is used to define the no. of table entries maintained in the main storage area...

    for ex:

    create a Internal table itab using the TYPE statement.

    types: begin of tab,

    end of tab.

    this only creates a structure of type tab..but when u say

    data itab type tab occurs 10.

    this creates an internal table in which 10 records can be maintained in main memory.

    Extra records can be written out to paging area but can effect performance.

    so,it is advisable to create internal table using types.

    occurs n -> n records can be stored in main storage area..we can also store more than n,but they are stored secondary storage which increases fetching time..

    rewards if helps ..

    thanq.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.