Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

regarding data declaration

Former Member
0 Likes
696

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.

5 REPLIES 5
Read only

Former Member
0 Likes
625

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.

Read only

Former Member
0 Likes
625

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

Read only

Former Member
0 Likes
625

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>

Read only

Former Member
0 Likes
625

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

Read only

Former Member
0 Likes
625

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