‎2007 Jun 24 6:40 AM
Hi,
what is the differnce between like and type?
ex: data:ebeln like ekko-ebeln,
ebeln type ekko-ebeln.
wt is the diff between these two statements?
regards,
ram.
‎2007 Jun 24 6:46 AM
1. difference inusing LIKE and TYPE
For all practical purpose, they are same.
When we declare a variable, with refernce to some object in memory,
we use LIKE.
for pre-defined types, we use type eg. C, N, etc.
2.Using which one is better
There is no difference, better wise.
Use like when there is an existing data type and you want to refer to the existing one.
EXAMPLE : TYPES char1 type C
(Has to be a field from the ABAP dictionary)
EXAMPLE : TYPES char2 LIKE char1
(NOTE : Here we can have ABAP dictionary types OR reference to a field created in the program)
Here char2 is created like char1
However you CANNOT create cha2 type char1
Check below threads :
Thanks
Seshu
3. Which will improve the performance
Both are same. Both finally create a variable only.
‎2007 Jun 24 7:11 AM
The syntax and meaning of the additions TYPE and LIKE are completely equal for both statements with the exception that
TYPES creates an independent reference type,
whereas DATA creates a bound reference type.
Perforamnce wise using TYPE is better than LIKE
Regards
Sri
‎2007 Jun 24 7:25 AM
what is the differnce between like and type?
we use TYPE when we are refering to data types for example
Numeric types I F P
Character types C D N T
Hexadecimal type x
we use LIKE when we are refering to dat objects
A data object is the application-specific instance of an archiving object, that is, an archiving object filled with concrete application data.
A data object incorporates all application data that is necessary to archive a business object (master data or transaction data) completely and consistently. Examples of master data objects include material masters and bills of material. Examples of transaction data objects are Financial Accounting documents, billing documents, and deliveries.
A typical data object is composed of a:
Header containing general information for identifying the data object, and a
Individual items that contain the actual application data
Regards,
Srikanth
<u><i><b>award points if helpful</b></i></u>
‎2007 Jun 24 7:37 AM
HI
If ur refering existing data dictionary object then u should use like.
If u want to use ur own data declration then u should use type statement.
Regards
Ravi
‎2007 Jun 24 8:41 AM
Hi Rambabu,
SAP recommends that while you declare a variable in your program with reference to an existing data dictionary object, you use the keyword 'LIKE'.
When you want to create a variable in your program referencing pre-defined data types like C, D, N etc, use the keyword 'TYPE'. Apart from this,if you create user-defined types in your program , say for example
types : begin of ty_data,
no(1),
name(10),
end of ty_data.
You need to use the keyword TYPE in your program to generate structures referencing the user-defined type TY_DATA.
Hope this was clear enough.
Thanks,
Venkat
P.S : Please reward points if answers are found useful