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

Internal Table vs Workarea

Former Member
0 Likes
712

Hi all

My question is simply. But I always get this confusing.

1) data : it_vbak type vbak occurs 0.

2) data : wa_vbak type vbak

The 1st one is declaring for internal table? May I know what is the purpose of occurs 0? The 2nd one is declaring for workarea?

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
618

Also, pls remeber that the 2 declaration i.e. workarea holds only one record for each iteration of loop endloop.

you can also declare the workarea as:

data: wa_vbak like line of it_vbak.

Yes, in OO concept of ABAP, system does not allow you to declare OCCURS clause instead you should declare workarea.

Thanks,

Santosh

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
618

The first one is a declaration of an internal table, but the OCCURS extension is obselete. I would suggest to not use. Instead declare like so. This is an internal table without a header line, so you will need a work area in which to read the data into when using LOOP or READ.

data: it_vbak type table of vbak.
data: wa_vbak like line of vbak.

You can also define the work area as you have done in number 2.

The OCCURs extension is an old way of defining the internal table and the 0 is saying that the memory area will be initialize to 0 rows. You could set this to 10 or whatever. But using 0, simply says, do not allocation any memory yet. Once a record is written to it, it will then allocate for that row.

So, in conclusion, define your internal tables and work areas as I have in the example above.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
619

Also, pls remeber that the 2 declaration i.e. workarea holds only one record for each iteration of loop endloop.

you can also declare the workarea as:

data: wa_vbak like line of it_vbak.

Yes, in OO concept of ABAP, system does not allow you to declare OCCURS clause instead you should declare workarea.

Thanks,

Santosh

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
618

Hi,

Also note the use of CLEAR and REFRESH in this.

CLEAR on it_vbak will only clear the work area of the internal table,

where as

REFRESH it_vbak will clear the internal table and will keep the workarea intact.

you need to use both to clear both internal table and workarea.

Both CLEAR and REFRESH will work the same in the case of wa_vbak.

Regards,

Sesh

Read only

Former Member
0 Likes
618

Hi Hui,

First statement will create a internal table with 0 rows allocated to it in advance(occurs), if it is occurs 10 then 10 rows will be allocated to the internal table in the memory. But dont use the occurs statement or the header line statement as it is obselete now.

correct way will be data: it_vbak type table of vbak,

wa_vbak type vbak.

when you are not giving "table of", it will create a work area.