When ever we declare internal tables or variables or constants system will allocate memory to each one based on the size of the object while runtime. For variables and constants we can determine the size from the definition. For internal tables size will be equal to sum of sizes of all fields. i.e. size of one row equal to sum of sizes of all fields. Size of table equal to Size of each row * Number of rows. OCCURS statement is used to define an implicit work area
called header line while defining internal table.
OCCURS n, The value specified in n identifies number of expected records in the internal table. If the number of records exceeds then the system will allocate memory for next n records. If the value of n is zero then it means that you don't know how many records you are going to get. So the system will allocate default memory of 8KB. Use OCCURS 0 only if you are sure that your table contents crosses 8KB at some point. Otherwise it will be simply waste of resource (Memory) while executing the program. My sugesstion is don't go for OCCURS addition as it is already obsolete in OOPS concepts. Also If we use OCCURS then name of the internal table and header line will be same. So there will be confusion in which is work area and which is header line. So always go for explicit work areas. Check below the effective way of defining internal tables. TYPES: BEGIN OF t_vbap, "Structure
DATA: i_vbak TYPE STANDARD TABLE OF t_vbak, "Internal
table
--- Occurs statement is used to allocate the initial space to the internal table records in the program area. Basic terms : Roll Area : area in the virtual memory. usually RAM Area. the access on this area is fast. Paging Area : This is the memory allocated in the page division of hard disk. the accesses to this area is slow. When we declare Occurs 0. The system will allocate initially space for 0 records in the roll area but increases the memory by record by record. The maximum limit is 8kb in roll area, after that it will allocate in the paging area. When we declare occurs 2. The system will allocate space for initial 2 records and increases 2 records by 2 records. The maximum limit in the roll area is 8kb only and after that allocates i the paging area. When we declare occurs 100. The number that will take more space for the allocation of records than 8kb., first it will allocate the space for all this records i.e., 8kb from the roll area and other area in paging area. For performance: If we don't know how much average fields are there.
Get help for your ABAP problems
ABAP Books
More ABAP Tips
SAP Basis, ABAP Programming and Other IMG Stuff http://www.erpgreat.com All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
|