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

Global structure-basics

Former Member
0 Likes
2,740

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

4 REPLIES 4
Read only

retired_member
Product and Topic Expert
Product and Topic Expert
0 Likes
1,620

You stumbled over an obsolete feature ...

LIKE - obsolete

Horst

Read only

0 Likes
1,620

Thank you.

           Since structure comes under data type, how it takes LIKE keyword for global structure but not for local structure.

Read only

0 Likes
1,620

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.

Read only

former_member241258
Active Participant
0 Likes
1,620

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.