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

report

hi gurus i am new in abap plz tell me the some ques. answer.

wht is diff b/w occurs 0 and occurs 1.why we use it.

why we use read statements.

why we use loop statement.

thankx. jay

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 Jan 30, 2008 at 05:44 AM

    Hi Jayant-

    The OCCURS parameter n specifies how many table lines of storage is required. This storage reservation process does not happen until the first line is inserted in the table. The value n of the OCCURS specification has no effect on type checking, i.e. data objects which have types with different OCCURS specifications are type-compatible.

    if are specifying 10 then initially 10 lines of storage is reserved. once 10 lines completed then again 10 lines will be reserved.

    0 means no specific reservation of lines. depends on the requirement the storage will be reserved.

    Refer to the following links

    diff-bw-occurs-0-and-1

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

    occurs-0-and-occurs-1

    READ statement is used to read a internal table entry based on the KEY u put in the READ syntax..For more details on READ statement, you can enter keyword as "READ" in ABAPDOCU transaction code and look for documentation!

    LOOP is used to loop the inernal table and do the processing for each and every table entry. You can refer to LOOP statement in ABAPDOCU tcode..

    Award points,

    Shakir

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 05:46 AM

    occurs 0 It alooactes 8K memory to itab

    occurs 1 It alooactes memory equal to 1 row of itab

    READ to read a single line from iTAB

    loop to read all lines from iTAB

    Award points if useful

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 05:48 AM

    Hi,

    read statement is for reading a record from the internal table.

    loop...endloop is for accessing all the internal table contents one by one

    rgds,

    bharat.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 05:53 AM

    HI

    occurs 0

    in the data definition, occurs 0 will indicate that a memory of 8 kbytes is allocated to the internal table which was declared by you of the data base table type which was specified. Here, if u dont give with heade line option, it will create only the body area and there will not be any header. The internal table can have the header line with the extention ' with header line ' .

    For more detailed explanation, go through the following.

    data: wa like kna1. --> wa is a structure of the type kna1 table. it can store only

    one record of data.

    data: itab like kna1 occurs 0. --> Here itab is the internal table which has 8 kb of

    memory allocated for the body area. Here it

    doesnt have header. if the data loaded in the itab

    exceeds 8 kb, another 8 kb of memory is

    allocated and the process continues.

    we can also give 1, 2, .... in place of 0. Here the

    memory allocated will be that required to store

    one record of data, 2 records of data .....

    respectively. If more records are to be

    populated, extra memory of 1, 2, ..... records

    will be generated. Thus, the memory allocated

    will be generic and not constant.

    data: itab like kna1 occurs 0 with header line --> Everything is same as earlier

    except that header line is also generated and

    it will be in addition to the actual memory

    located to body.

    Note: to populate data into itab without header line we have to define a work area of the structure of the itab.

    data: itab like kna1 occurs 0.

    data: wa like line of itab.

    Then populate data into wa and append to itab ( append wa to itab ). Where as in case of an internal table with header line, we can populate data directly to header of itab and append it to its body. ( append itab. )

    hope this will give a clear picture of the way in which data is allocated based on our statement.

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 06:02 AM

    if we define internal table with occurs 0 then intially it will allocate 8kb memory latter on it will increase the size depending on the records.

    if we define itab with occurs 1 i will allocate memory required for one record.

    read is used to read the particular record in the internal table depending on the condition or index. better to use binary search in case of read. to use binary search we have to sort the internal table first.

    loop will loop through all the records in the internal table.

    we can also where condition for loops.

    below is the document regarding memory allocation.

    You can specify the initial amount of main memory assigned to an internal table object when you define the data type using the following addition:

    INITIAL SIZE <n>

    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.

    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.

    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.