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

what is basic difference between like and like line of

Former Member
0 Likes
3,159

Can anyone tell me the difference between ?

CQ.) What is basic difference between like and like line of ?

Can anyone tell me the difference between ?

CQ.) What is basic difference between like and like line of ?

6 REPLIES 6
Read only

Former Member
0 Likes
2,415

Hi,

The Like refer to standard structrure or Table which we are refering the Work Area..

..now from above 4.7 sap version Like is absolute ,we are using Type..

still Like is Using in when we are refering the Tabloes or srtuctures in Function modules..

The Like line of reffers to Local structure or interal table Work Area..

Regards,

Prabhudas

Edited by: Prabhu Das on May 12, 2009 4:51 PM

Read only

Former Member
0 Likes
2,415

Hi,

Like :


Data:
 w_char type c,
 w_char1 like w_char.

This will create w_char1 of type w_char.

Like Line :


Data:
 t_mara like zmara,
fs_mara like line of zmara.

Consider zmara as the table type of mara.Then t_mara is a internal table of structure mara and fs_mara is the work area for it.

Thanks,

Nithya

Edited by: Nithya Murugesan on May 12, 2009 1:44 PM

Read only

Former Member
0 Likes
2,415

Hello,

If you are declaring a variable similar to a field in a table, we use like.

data: w_bukrs like bkpf-bukrs.

Like is also used if you need to declare a work area similar to a database structure.

data: w_bkpf like bkpf.

"Like line of " is used if we declare a work area similar to an internal table defined in the program.

ex:

data: begin of t_abc occurs 0,

X1(1),

X2(2),

end of t_abc.

data: w_abc like line of t_abc.

Here w_abc is similar to work area of table t_abc.

Read only

Former Member
0 Likes
2,415

Hi Prashant,

types:

begin of type_struc,

fld1 type c,

fld2 type i,

end of type_struc.

data:

wa1 type type_struc,

wa2 like wa1. " use like to define a line obj like another line obj.

data:

itab type table of sflight,

wa3 like line of itab. " wa3 is the line obj having the structure like that of table sflight.

Regards.

Read only

Former Member
0 Likes
2,415

Hi

If you have a data object in you code,for example -

DATA:

BEGIN OF rng_str,

sign TYPE ddsign,

option TYPE ddoption,

low TYPE numc10,

high TYPE numc10,

END OF rng_str.

in this case if you would like to create a structure type rng_str, in such case you use LIKE:

data: rng_str1 like rng_str.

-


In your code if you have an internal table and you would like to declare a structure of this internal table then we use LIKE LINE OF for the data object. For example:

data: rng_tabl LIKE TABLE OF rng_str. "table type declaration

data: l_structure like line of itab. "line type or work area declaration

Hope you understood the concept.

Regards,

George

Read only

Former Member
0 Likes
2,415

hi,

like is similar to Type...

Now we use Type instead of like .

used to declare an INternal table or structure

However Like line is use to declare a work area.

eg:-

itab type standard table of zitab. -


> Declaring Internal table

wa_itab like line of itab.----


> Declaring Work area

Thanks and regards

Suraj