Application Development 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: 

Type and Like

Former Member
0 Kudos
149

What is th edifference between Type and Like?

1 ACCEPTED SOLUTION

Former Member
0 Kudos
110

Hi kotireddy,

type is used for declaring built-in variables like integer,float..

for eg if u r creating a internal table itab it should be like another table itab2..

then syntax is

data itab1 like itab2 occurs 0 with headre line...

10 REPLIES 10

Former Member
0 Kudos
110

Hi,

type we can use to refer system defined or user defined data types and data dictionary objects..

like we will use in case of refering data dictionary objects only.

rgds,

bharat,

0 Kudos
110

type is to declare variables using other data types defined in the dictionary or in ur program(using the TYPES keyword).

like is to declare variables using all declared variables

Hope this will solve ur problem..

<b><u>Dont forget to reward all the useful replies</u></b>

Sudheer

Former Member
0 Kudos
110

DATA x TYPE zzzzzz

Here zzzzzz is either :

1. A standard ABAP type ( i,c,d,p,n etc)

2. A data element,domain,structure,table type in data dictionary.

DATA y LIKE wwwww.

Here wwwww is another variable/constant that is previoulsy declared/avaiable in your report.

eg : DATA ucomm LIKE sy-ucomm.

former_member588853
Active Contributor
0 Kudos
110

hi koti reddy,

look at this,,

*This is type definition do not hold any data its just a structure..

types : begin of itab,

f1 type c,

f2 type c,

end of itab.

Now you can use <b>TYPE</b> not <b>LIKE</b> for this because this is just a structure.defining an internal table/ <b>DATA OBJECT</b>

data : it_itab <b>TYPE</b> STANDARD TABLE OF itab. "you are using type to structures

Now another table

data ITAB2 <b>LIKE</b> it_itab. "you can use <b>LIKE</b> to data Objects

you can 't do like this

data itab2 like itab. "this is wrong

rewards if understood

regards,

nazeer

Former Member
0 Kudos
110

Hi,

Diff bn TYPE N LIKE.

Go through the link.

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm

TYPE - Type is used to tell the system what is the type of data object(variable) you want to create .

LIKE: If there is already a data object declared and you want to declare a similar data object you can just refer to the previous data object using like.

Check this thread.

https://forums.sdn.sap.com/click.jspa?searchID=711746&messageID=2270752

https://forums.sdn.sap.com/click.jspa?searchID=711746&messageID=512214

Regards,

Priyanka.

Former Member
0 Kudos
110

hi,

type is generally used for declaring variables, parameters for existing data types in abap

for ex: to declare a inter value and character variable of length 10 is as,

data: i1 type i,

c1(10) type c.

like generally refers to existing data objects in abap.

for ex:

data: matnr like mara-matnr,

vbeln like vbap-vbeln.

creating variables matnr, vbeln from existing fields of tables mara, vbap.

when user creates a user defiend structure for work areas, internal tables we generally use type keyword as

types: begin of itab,

.........

.........

........

end of itab.

data: itab1 type itab occurs 0 [with header line]

.............

if helpful reward some points.

with regards,

suresh babu aluri.

Former Member
0 Kudos
111

Hi kotireddy,

type is used for declaring built-in variables like integer,float..

for eg if u r creating a internal table itab it should be like another table itab2..

then syntax is

data itab1 like itab2 occurs 0 with headre line...

Former Member
0 Kudos
110

Hi kotireddy,

type is used for declaring built-in variables like integer,float..

for eg if u r creating a internal table itab it should be like another table itab2..

then syntax is

data itab1 like itab2 occurs 0 with headre line...

Reward if it's useful..

Reg'

Zeemaaaaa...

Former Member
0 Kudos
110

Hi,

TYPE is used to refer a data type in the ABAP dictionay i.e., a predefined data type whereas LIKE is used to refer to the data type of a local data object in the program.

Reward if useful.

Regards

Sayee

0 Kudos
110

U need to <b><u>award points for all the useful replies</u></b>, and also u nees to <b><u>mark it as Answered if ur problem is solved</u></b>.

Regards

Sudheer