‎2008 May 16 8:09 AM
HI Friends,
What is the Difference between Declaring Itab with DATA & TYpe Statement?
‎2008 May 16 8:20 AM
Hi,
You use TYPES to declare a work area(typically holds one record only) But if you declare using DATA and OCCURS statement it will create an internal table....
TYPES: Begin of itab
-
end of itab.
In above case a work area is created...
DATA : begin of itab OCCURS 0,
-
end of itab.
Inabove case an internal table is created and 0 bytes of memory is allocated...
Reward if useful
Regards
Shiva
‎2008 May 16 8:18 AM
Hi,
if you declare structure by using TYPES and then declare internal table using TYPE TABLE OF it will provide better performance and by using TYPES it doesnot hold any memory and store as template only but by using DATA it will occupy memory by turn decreases the performance and also if u use OCCURS in declaration of internal table it is obselete and throughs EPC error.
‎2008 May 16 8:19 AM
Hi,
The Statements TYPES and DATA
Each ABAP program define its own data types using the statement.
TYPES dtype TYPE type ...
and declare its own variables or instance attributes of classes using the statement
DATA var {TYPE type} ...
Within the program or a class, you can also define local data types and variables within procedures. Local variables in procedures obscure identically-named variables in the main program or class.
When creating data types and data objects, there are a number of naming convention that also apply for other local program definitions, such as procedures. These are described in detail in the keyword documentation.
The Additions TYPE and LIKE
The additions TYPE type and LIKE dobj are used in various ABAP statements. The additions can have various meanings, depending on the syntax and context.
· Definition of local types in a program
· Declaration of data objects
· Dynamic creation of data objects
· Specification of the type of formal parameters in subroutines
· Specification of the type of formal parameters in methods
· Specification of the type of field symbols
TYPES: BEGIN OF struct,
number_1 TYPE i,
number_2 TYPE p DECIMALS 2,
END OF struct.
DATA: wa_struct TYPE struct,
number LIKE wa_struct-number_2,
date LIKE sy-datum,
time TYPE t,
text TYPE string,
company TYPE s_carr_id.
This example declares variables with reference to the internal type STRUCT in the program, a component of an existing data object wa_struct, the predefined data object SY-DATUM, the predefined ABAP type t and STRING, and the data element S_CARR_ID from the ABAP Dictionary.
Reward Points if found helpfull..
Cheers,
Chandra Sekhar.
‎2008 May 16 8:20 AM
Hi,
You use TYPES to declare a work area(typically holds one record only) But if you declare using DATA and OCCURS statement it will create an internal table....
TYPES: Begin of itab
-
end of itab.
In above case a work area is created...
DATA : begin of itab OCCURS 0,
-
end of itab.
Inabove case an internal table is created and 0 bytes of memory is allocated...
Reward if useful
Regards
Shiva
‎2008 May 16 8:21 AM
Hi Dheeraj,
Welcome To SDN!!.
like -> used for refering existing data elements in data dictionary or in sap
type -> used for refering existing data types in sap.
types: used for creating used defined structure of tables which has fields from more tahn one table.
diff b/w types and type in creation of internal tables is that when u create a table with types then u can use same for work area creation also.
Regards
Kiran Sure
‎2008 May 16 8:21 AM
hi,
TYPES and DATA:
types doesn't allocate memory for the variables or structures.
where as data allocates memory.
when u create itab with DATA the initial memory will be allocated for the internal table.(here the object is created).
but with TYPES it just stores the type of the table.(here the object is not yet created)
thanks,
raji
Edited by: raji ch on May 16, 2008 9:21 AM