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 b/w TYPE and LIKE

Former Member
0 Likes
598

please have a look at the following piece of code.

itab1 & itab2 both are structures but

itab1 has two components "KEYPART" & "FUNCPART"

while itab2 has "NAME" & "SURNAME".

can anybody please explain what is this keypart & funcpart. and why we are getting different components for two structures.

DATA: BEGIN OF itab OCCURS 0,

name(10),

surname(10),

END OF itab.

data: itab1 type itab.

data: itab2 like itab.

please have a look at the following piece of code.

itab1 & itab2 both are structures but

itab1 has two components "KEYPART" & "FUNCPART"

while itab2 has "NAME" & "SURNAME".

can anybody please explain what is this keypart & funcpart. and why we are getting different components for two structures.

DATA: BEGIN OF itab OCCURS 0,

name(10),

surname(10),

END OF itab.

data: itab1 type itab.

data: itab2 like itab.

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
571

The reason is that in the data statement for ITAB1 you are referening a TYPE called ITAB that exists in the ABAP dictionary, double click on the word ITAB in this statement and you will see the defintion in the ABAP dictionary. The other statement is referencing the ITAB in your program because you are using LIKE.

REgards,

Rich Heilman

Read only

Former Member
0 Likes
571

Hi Yogesh,

Check

Regards,

santosh

Read only

Former Member
0 Likes
571

hi

good

the reason behind this is,

they have store two different value for the two different structures,

and as you have mentioned KEYPART and FUNCPART are two standard values store in the itab1 like that NAME and SURNAME are two values store in the table itab2.

thanks

mrutyun^

Read only

Former Member
0 Likes
571

hi,

<b> TYPES and DATA have separate namespaces.</b> So, we can declare 2 variables with the same, out of which one can be done using TYPES and other using DATA.

ex: TYPES : name type i.

DATA : name type c.

DATA: V_new type name,

V_sec like name.

Now, v_new is of type I where as v_sec is of type C.

In your case also, check if itab is declared twice, one in TYPES and other in DATA. The one which you have shown is in DATA. So, check for the other in TYPES.

REgards,

Sailaja.