‎2008 Feb 02 4:52 AM
‎2008 Feb 02 4:59 AM
Hi,
ABAP distinguishes between types and objects. Types are descriptions that do not occupy memory. Objects are instances of types, and do occupy their own memory space. A type describes the technical attributes of all of the objects with that type.
You can use the addition
TYPE <type>
to refer to any data type <type> that is already known at this point in the program.
DATA <f> TYPE <type>.
The data object <f> has a data type corresponding to the type <type>.
DATA <f> LIKE <obj>.
The data object <f> inherits all of the technical attributes of the data object <obj>.
Take an example :
types : begin of ty_tab,
name(30),
pwd(10),
end of ty_tab.
data : itab like ty_tab.
See here we declared the structure of ty_tab, which do not occupy memory. So if we run this, we will get compile time error like this : Field TY_TAB is unknown. It is neither in one of the specified tables nor defined by a DATA statement.
So in this case u need to correct the error with "TYPE" statement...like this.
types : begin of ty_tab,
name(30),
pwd(10),
end of ty_tab.
data : itab type ty_tab.
Refer these
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm
Thanks
‎2008 Feb 02 5:00 AM
hi
ABAP distinguishes between types and objects. Types are descriptions that do not occupy memory. Objects are instances of types, and do occupy their own memory space. A type describes the technical attributes of all of the objects with that type.
You can use the addition
TYPE <type>
to refer to any data type <type> that is already known at this point in the program.
DATA <f> TYPE <type>.
The data object <f> has a data type corresponding to the type <type>.
DATA <f> LIKE <obj>.
The data object <f> inherits all of the technical attributes of the data object <obj>.
Take an example :
types : begin of ty_tab,
name(30),
pwd(10),
end of ty_tab.
data : itab like ty_tab.
See here we declared the structure of ty_tab, which do not occupy memory. So if we run this, we will get compile time error like this : Field TY_TAB is unknown. It is neither in one of the specified tables nor defined by a DATA statement.
So in this case u need to correct the error with "TYPE" statement...like this.
types : begin of ty_tab,
name(30),
pwd(10),
end of ty_tab.
data : itab type ty_tab.
Refer these
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm
reward point if helpful.
Regards
Prajwal K .
‎2008 Feb 02 5:00 AM
Here is a simple main difference ..
Type : it will allocate memory during execution (object type).
Like : it will allocate memory immediatly.
---type will improve performance.
---p is packed type wherein we can restrict decimal values.
var type p decimals 2.
---float can hold more value than packed data type
Reward if helpful.
‎2008 Feb 02 5:01 AM
Hi,
data field(18) type c. "here c is a predefined 'data type'
data field type matnr . "here matnr is a 'data element'
data field like mara-matnr. "here mara-matnr is a 'data object'
'type' is used to refer a data type / data element.(ie given type is the data type of our obj)
'like' is used to refer a data obj(ie copy the data type of that obj to our obj)
Cheers,
Will.
‎2008 Feb 02 5:03 AM
Hi Suguna
In short to understand just think like :
if you declare some thing with LIKE memory is taken/allocated
if you declare some thing with TYPE memory is given only at runtime.