06-23-2008 5:32 AM
Hi all
I know that TYPES is used to allocate a work area and it doesnt allocate MEMORY and DATA is used to create a internal table and it allocates MEMORY.Now in the below scenario we had created a work area using TYPES and then we create a INTERNAL TABLE using DATA through the t_026 work area.My doubt is anyways memory is alloted when we are giving it as DATA why are we using the work area(I mean the TYPES).Please help.
TYPES:BEGIN OF t_s026,
matnr TYPE s026-matnr,
enmng TYPE s026-enmng,
sptag TYPE s026-sptag,
mcomp TYPE s026-matnr,
werks TYPE s026-werks,
END OF t_s026.
DATA:it_s0206 TYPE STANDARD TABLE OF t_s026 WITH HEADER LINE.
With Regards
Vijay
06-23-2008 5:53 AM
Hi Vijay,
The declaration you have done i.e.
TYPES:BEGIN OF t_s026,
matnr TYPE s026-matnr,
enmng TYPE s026-enmng,
sptag TYPE s026-sptag,
mcomp TYPE s026-matnr,
werks TYPE s026-werks,
END OF t_s026.
This type of declaration do not allocate any memory allocation.
Using TYPES her of this type you are declaring the structure of your memory.
When you declare with DATA then it allocated memory.
For e.g. If i do like this
DATA :WA_TS026 type T_S026.
This creates a work area type of memeory allocation whose type is of type t_s026.
DATA:it_s0206 TYPE STANDARD TABLE OF t_s026.
This type of declaration creates a memory area of type table whose structure is of type t_s026.
DATA:it_s0206 TYPE STANDARD TABLE OF t_s026 WITH HEADER LINE.
This type of declaration creates an internal table as well as a work area of the same name IT_S026.
I hope this will clear your doubts.
Help children of U.N World Food Program by rewarding points and encourage others to answer your queries.
06-23-2008 5:35 AM
Hi,
If you declare it as TYPE then memory is not allocated but LIKE will allocate the memory.
06-23-2008 5:36 AM
06-23-2008 5:42 AM
hi,
I think TYPES is used for reusability of the same structure more than one time.
regards,
raghul
06-23-2008 5:45 AM
Types will declare a structure for the internal table that you have declared.
Types is used so that you can include the fields u want for the internal table....that is to structure columns.
Also u can directly declare internal table using data and occurs clause.
But declaring types gives you the flexibility to assign the same structure to a different internal table if need arises.
It does'nt affect the performance anyhow, but reduces the lines of code if the same structure is to be assigned to different internal table and also makes program readable.
06-23-2008 5:53 AM
Hi Vijay,
The declaration you have done i.e.
TYPES:BEGIN OF t_s026,
matnr TYPE s026-matnr,
enmng TYPE s026-enmng,
sptag TYPE s026-sptag,
mcomp TYPE s026-matnr,
werks TYPE s026-werks,
END OF t_s026.
This type of declaration do not allocate any memory allocation.
Using TYPES her of this type you are declaring the structure of your memory.
When you declare with DATA then it allocated memory.
For e.g. If i do like this
DATA :WA_TS026 type T_S026.
This creates a work area type of memeory allocation whose type is of type t_s026.
DATA:it_s0206 TYPE STANDARD TABLE OF t_s026.
This type of declaration creates a memory area of type table whose structure is of type t_s026.
DATA:it_s0206 TYPE STANDARD TABLE OF t_s026 WITH HEADER LINE.
This type of declaration creates an internal table as well as a work area of the same name IT_S026.
I hope this will clear your doubts.
Help children of U.N World Food Program by rewarding points and encourage others to answer your queries.