‎2007 Dec 18 4:19 AM
hi gurus
can anyone inform me what is the difference between like and type statements
regards,
kals.
‎2007 Dec 18 4:56 AM
hi
good
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.
thanks
mrutyun^
‎2007 Dec 18 4:33 AM
HI,
type describes the field 'matnr' with the dataelement defined by the user in se11.
(user can create his/her own dataelement)
for eg:
data: matnr type d_matnr.
like decribes the field 'matnr' with the help of system defined
dataelement.
for eg:
tables: mara.
data: matnr like mara-matnr.
‎2007 Dec 18 4:34 AM
Hi Kalyan,
Type is used to definethe data type .
whereas Like is used to define the dataobject.
eg. data: matnr type matnr.
eg for like
data: matnr LIKE mara-matnr.
hope got the difference.
regards,
Sana.
reward points for useful answers,
‎2007 Dec 18 4:34 AM
hi,
Type
By using this we can create our own data type using existing data types and we can create structures.
LIKE
This will points towards already existed or user defined data type.
for u r understanding
type : begin of st1,
name type c(10),
address type c(100),
end of st1.
data : per like st1.
if i want to have one more structure with similar data types then u have no need to redefine them
type : begin of st2,
per1 like st1,
phone like c(10),
end of st2.
cheers,
pavan
‎2007 Dec 18 4:40 AM
‎2007 Dec 18 4:40 AM
Hi,
Type is used to refer predefined data types, where as Like refer for user defined data types.
For example.
data:
Begin of fs_data.
c_box,
name(10) type c,
end of fs_data.
data: it_tab like table of fs_data.
whereas Type
data:
it_tab type table of mara.
Plzz reward points if it helps.
‎2007 Dec 18 4:56 AM
hi
good
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.
thanks
mrutyun^
‎2009 Dec 21 11:29 AM
thanks a lot.
means anything in the data dictionary and activated is a available as a type.
and local types we can define.
varun