satya
satya

Reputation: 31

when to use TYPE and LIKE in ABAP

Why is this error

NAME must a flat structure you can not use internal table,string referenceses or structure as component

raised when I am using type in place of like in line no 2) dosen't show any error, when I am using like shows error.

What is the difference between LIKE and TYPE?

Code:

TYPES name(20) type c.    
data student_name like name.   "<=============== like or type
student_name = 'satya'.   
write student_name.

Upvotes: 0

Views: 3190

Answers (1)

shree.pat18
shree.pat18

Reputation: 21757

You have created name as a type. Therefore, if you declare a variable of type name, you need to write the statement as data student_name type name..

Now if you want to create another variable like the variable student_name, you would use the like keyword in the declaration as data student_name2 like student_name.

For a more detailed explanation, refer to the documentation

Upvotes: 8

Related Questions