2016 Jan 11 4:24 AM
Hi all,
i created a local structure using types statement in the program and i declared an internal table of structure type using like keyword
. An error occurred and i changed the declaration using type keyword, i know that we cannot use like keyword when referring a data type.
data: itab like table of st_name. then changed to data: itab type table of st_name.
Then i created a global structure at data dictionary. i used that structure in my program and declared an internal table using like keyword.No error has been thrown.
data: itab like table of st_name. --global structure.
i want to know the reason behind that? somebody explain me
2016 Jan 11 9:38 AM
2016 Jan 11 9:56 AM
Thank you.
Since structure comes under data type, how it takes LIKE keyword for global structure but not for local structure.
2016 Jan 11 10:26 AM
The TYPES statement for local types was introduced later than global structures. The behavior is OK for local types declared by TYPES.
Before release 3.0 there were no local types and no TYPE addition and LIKE did either refer to local data objects or to global structures. Since release 3.0 one should restrict the usage of LIKE to data objects and use the TYPE addition for referring to local and global types.
2016 Jan 11 10:37 AM
Type is used for only Data types.
like is used for Data Objects not for data types.
example:
data:lv_str type String. " this data Type by sap.
data:lv_str2 like lv_str. "this data object already declared above.
this is difference between like and type.