‎2008 Jun 23 5:33 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
‎2008 Jun 23 5:40 AM
hi,
This sort of declaration you find from ECC5.0 onwards it is same as how you declare occurs 0 of an internal table .... this is OOPS approach of programming and the memory gets allocated only at run time and i am not sure as how much memory gets allocated i guess it is 8KB of memory ...Guyz correct me if i am wrong
Regards,
Santosh
‎2008 Jun 23 5:43 AM
hi,
Types is used to create user defined data types, you can also create the internal table data type (check SLIS ) but memory will not be allocated unles we use them with data statemnt
It helps in reusability, so that if we have multiple declatations you can use this types statement
in OOABAP we cannot acess internal tables with header line
also if we have deep structures there we cannot have implicit header line
It helps you when passing variables to Subroutienes with USING and Changing as tables stament is obselete, We must give datatype which we declared in types statemnt
check the below example
PERFORM build_layout CHANGING wa_layout .
FORM build_layout CHANGING pw_layout TYPE slis_layout_alv .
<CODE>
ENDFORM.
here in the form you cannot give your layout declared with type you must use data type declared using types statement
regards
prasanth
Edited by: prasanth kasturi on Jun 23, 2008 10:17 AM
‎2008 Jun 23 10:46 AM
Hi Vijay krishna,
Types declaration is used to declare the work area with different data elements from same or different database tables, we are preferred to use types.
Bu using data , we can't create this type of work area with fields from different db tables.
If it useful, reward points.
Bye
Prasad G.V.K
‎2008 Jun 23 11:13 AM
hiii
when you use types here..it gives you only structure of that type.& you make internal table of that type of structure.structure never take memory..so its not related with memory.but when you create internal table with that structure.then at run time it will allocate memory as per data types that you have defined in structure.
reward if useful
thx
twinkal
‎2008 Jun 24 6:07 AM
Hi,
'Types' Is used to create local data Types in your Program.
Using Types You Can Create Elementary Data Type ,reference Type,Structure Type, Complex Type And Internal Table Type.
Again Using 'Data' You Can Create The Above Mentioned Data
Object Not Type,Because Types Keyword Is Used To Create
User Defined Data Type But Data Keyword Is Used To Create
User Defined Data Object.
As you know That When You are using Types It Does Take Any Memory For Defined Data Type.But Using Data Whatever Data Object You Create It Allocate Some Memory Of Its Type.
We Generally use Type To Create The Data Type Of Our Own So That Later We Can Take reference Of That Data Type To create Our Object.
Reward if it seems Helpful.
‎2008 Jun 24 11:08 AM
hi vijay
TYPES keyword is used to define the local Data type. But Using this keyword doesnt mean the allocation of the memory.
To Allocate Memory ie to create a work variable you have to define it with DATA keyword with type TYPES. That will create the data object having type TYPES and also contain memory.
Regards
Sumit Agarwal
‎2008 Jun 24 1:51 PM
hi Vijay,
Actualy TYPES statement is used to create the local data type of a structure,which is your work area here.
Whereas, DATA statement creates the data object of type refer to it by TYPE statement. The concecept is exactly similer to our old lesson in C language with structure.
Reward if found helpful.
Allthe best.
Anirban Bhattacharjee