‎2007 May 22 4:15 PM
When is a types keyword used n when is the data keyword used?
‎2007 May 22 4:19 PM
TYPES : used to declare structures.
DATA : used to declare internal tables and simple data declarations
types : begin of ty_itab,
matnr like mara-matnr,
maktx like makt-maktx,
end of ty_itab.
data : itab type table of ty_itab.
‎2007 May 22 4:19 PM
TYPES : used to declare structures.
DATA : used to declare internal tables and simple data declarations
types : begin of ty_itab,
matnr like mara-matnr,
maktx like makt-maktx,
end of ty_itab.
data : itab type table of ty_itab.
‎2007 May 22 4:20 PM
Hi,
TYPES key word is used declaring local types within the program...TYPES key word cannot be used to store values in the run time..
DATA key word is used to declare variable/structure or internal table..Using which you can store values in the run time..
Thanks,
Naren
‎2007 May 22 4:39 PM
hi,
LIKE means the datatype of the variable is similar to the referenced variable.
TYPE means it is a predefined data type.
Eg:
DATA int TYPE i.
Here int is of integer data type.
DATA var LIKE int.
var IS a variable having same data type of int. which in turn is integer.
You can find these helpful when you reference database table variables... You need not know what is the datatype defined.
Also it adds to FLEXIBILITY.
Whenever you make changes to your database tables and fields,
that change is REFLECTED back to your program that is,
You need not change all your program code when you change your table fields...
For TYPE
http://help.sap.com/saphelp_47x200/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm
For LIKE
http://help.sap.com/saphelp_47x200/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb367a358411d1829f0000e829fbfe/content.htm
‎2007 May 22 4:44 PM
See the diffrence :
Structure
types : begin of ty_itab,
fld1(1) type c,
end of ty_itab.
Internal table
data i_itab type standard table of ty_itab.
here i can not use types ty_itab in the program,if i use then i will get syntax error..
types is nothing but structure..
data - related to work area or internal table,variable
you can use data statemnt in anywhere in the program.
‎2007 May 22 4:51 PM
i have seen that using data also we can create a stucture with ocurrs 0
‎2007 May 22 4:53 PM
when you see occurs 0,nothing but internal table,
this is not structure.
‎2007 May 22 4:59 PM
Yes its an internal table but using both the keywords can we create a structure ?is it correct to use the data keyword to create a structure?
‎2007 May 22 5:02 PM
data wa_itab like line of itab.
this is work area also we call as structure ,it will have only one record during runtime,
where as internal table ,it will have many records during run time
when you use types statment in the data decalration and you can not use in select query.
‎2007 May 22 5:04 PM
‎2007 May 23 11:59 AM
Hi krishna,
<b>types</b> is data type which doen't have memory space to hlod data,
<b>data</b> is data object which has memory space to hold data,
<b>types</b> keywords are attributes to the <b>data</b> keywords.
regards,
seshu.