‎2007 Jan 22 12:56 AM
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.
‎2007 Jan 22 1:41 AM
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
‎2007 Jan 22 1:15 AM
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
‎2007 Jan 22 1:41 AM
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
‎2007 Jan 22 4:08 AM
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
‎2007 Jan 22 5:07 AM
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.