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: 

difference between LIKE and TYPE...........

Former Member
0 Kudos

Dear all experts,

I am bw certified, learning abap at my own,

I have gone thr. sams abap in 21 days. still i am having some confusions.

1) Can anybody please tell exact difference of using LIKE and TYPE in case of tables…

I am getting confused, exactly what to use and when to use.

Is there any relation to work area, of above point ?

How these are concerned to with header and without header.

2) how to pass internal table to routines and function ?

can you give any example or link to example, showing difference between, pass by value, refrence and value & result.

Surely, points will be assigned to your appropriate help.

Waiting....

regards....

Vinay.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi vinay,

Try to post ur question once in any one of this forum. Avoid posting it in multiple forums.

the difference between in type and like is :

when defining or declaring the object is that type is used to refer existing data type.

while like is used to declare data objects with reference to existing data objects.

type is mostly used for defining a new object.

for ur second question, u can find a chapter in the 21 days book itself under the chapter modularization techniques. Kindly go thro that one. u can get a clear picture from that.

Regards....

Arun.

Reward points if useful.

2 REPLIES 2

Former Member
0 Kudos

hi vinay,

Try to post ur question once in any one of this forum. Avoid posting it in multiple forums.

the difference between in type and like is :

when defining or declaring the object is that type is used to refer existing data type.

while like is used to declare data objects with reference to existing data objects.

type is mostly used for defining a new object.

for ur second question, u can find a chapter in the 21 days book itself under the chapter modularization techniques. Kindly go thro that one. u can get a clear picture from that.

Regards....

Arun.

Reward points if useful.

Former Member
0 Kudos

Hi,

<b>TYPE:</b> You use the TYPE addition in various ABAP statements for defining data types and specifying the types of interface parameters or field symbols.

to refer to any data type <type> that is already known at this point in the program

<b>LIKE :</b> 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

<b>Subroutines example:</b>

TYPES: BEGIN OF LINE,
        COL1,
        COL2,
      END OF LINE.

DATA: WA TYPE LINE,
      ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1,
      KEY(4) VALUE 'COL1'.

WA-COL1 = 'X'. INSERT WA INTO TABLE ITAB.
WA-COL1 = 'Y'. INSERT WA INTO TABLE ITAB.

PERFORM DEMO USING ITAB.

FORM DEMO USING P TYPE ANY TABLE.
  ...
  READ TABLE P WITH TABLE KEY (KEY) = 'X' INTO WA.
  ...
ENDFORM.

In the Function module, you have the TABLE option to declare the tables and pass the tables to a function module

Regards

Sudheer