Application Development and Automation 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: 
Read only

Occurs

Former Member
0 Likes
1,949

hi friends,

Could u plz tell me what is the purpose of giving

OCCURS 0??????

thanks in advance.

regards,

Priya.S

4 REPLIES 4
Read only

Former Member
0 Likes
1,701

HAI ,

By using occurs we can allocate some initial memory for internal table , like occurs 0 (it will allocate 8 kb memory) initially.

after that if needed it will allocate another 8 more and it will go on like this.

Reward if useful.

Read only

Clemenss
Active Contributor
0 Likes
1,701

Hi Priya

in ABAP editor, on OCCURS, you may press F1.

Remaining questions to be posted here.

Regards,

Clemens

Read only

Former Member
0 Likes
1,701

Hi Priya,

Basically occurs 0 means it creates a workarea or header for a internal table implicitly.

Occurs 0 means, the size of the table header for an initial table is 8 bytes. Unlike all other ABAP data objects, you do not have to specify the memory required for an internal table. Table rows are added to and deleted from the table dynamically at runtime by the various statements for adding and deleting records.

So we can call occurs X as initial size of the internal table.

Regards,

Viveks

Read only

vinod_vemuru2
Active Contributor
0 Likes
1,701

Hi Priya,

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 0 is used to allocate initial memory of 8KB to the 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 u dont know how many records u r going to get. So the system will allocate default memory of 8KB. Use OCCURS 0 only if u are sure that ur table contents crosses 8KB at some point. Otherwise it will be simply waste of resource(Memory) while executing the program.

My sugesstion is dont 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

vbeln TYPE vbap-vbeln,

posnr TYPE vbap-posnr,

matnr TYPE vbap-matnr,

END OF t_vbap.

DATA: i_vbak TYPE STANDARD TABLE OF t_vbak, "Internal table

wa_vbak TYPE t_vbak. "Explicit Work area

Hope this clarified ur doubts.

Thanks,

Vinod.