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

diff between type and like

Former Member
0 Likes
447

hi gurus,

diff between type and like

3 REPLIES 3
Read only

former_member189059
Active Contributor
0 Likes
428

TYPE

You use the TYPE addition in various ABAP statements for defining data types and specifying the types of interface parameters or field symbols. The TYPE addition can have various meanings depending on the syntax and context.

LIKE

You use the LIKE addition, similarly to the TYP E addition , in various ABAP statements for defining data types and specifying the types of interface parameters or field symbols. The addition

LIKE <obj>

can be used in the same ABAP statements as the TYPE addition to refer to any data object <obj> that is already visible at that point in the program. The expression <obj> is either the name of the data object or the expression.

You use LIKE to make the new object or type inherit the technical attributes of an existing data object.

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.

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.

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]

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

Hope this helps to solve ur problem....

Read only

Former Member
0 Likes
428

Hi,

The Additions TYPE and LIKE

The additions TYPE type and LIKE dobj are used in various ABAP statements. The additions can have various meanings, depending on the syntax and context.

· Definition of local types in a program

· Declaration of data objects

· Dynamic creation of data objects

· Specification of the type of formal parameters in subroutines

· Specification of the type of formal parameters in methods

· Specification of the type of field symbols

Regards,

Prasanna

Read only

Former Member
0 Likes
428

hi

DATA:

name TYPE string,

surname TYPE string,

roll_no TYPE i,

age TYPE i.

DATA: BEGIN OF itab OCCURS 0,

matnr LIKE mara-matnr,

maktx LIKE makt-maktx,

END OF itab.

show this two exp if you use system fields then you declare it with LIKE.

if you give your own variable then you must give its data-type that time TYPE is use.

i hope it will helpful to u.

Rewards if helpful.

prashant.