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

abap objects

Former Member
0 Likes
723

hi,

wat is the difference betn public and private and protected in aba objects.

thanks,

ganesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
695

hi,

Public Section:

  • main class can access

  • sub class can access

  • friend class can access

Protected Section:

  • main class can access

  • sub class can access

  • friend class can access

Private Section:

  • main class can access with the help of public mehod

  • sub class cannot access

  • friend class can access

6 REPLIES 6
Read only

Former Member
0 Likes
695

Public Section

All of the components declared in the public section are accessible to all users of the class, and to the methods of the class and any classes that inherit from it. The public components of the class form the interface between the class and its users.

Protected Section

All of the components declared in the protected section are accessible to all methods of the class and of classes that inherit from it. Protected components form a special interface between a class and its subclasses. Since inheritance is not active in Release 4.5B, the protected section currently has the same effect as the private section.

Private Section

Components that you declare in the private section are only visible in the methods of the same class. The private components are not part of the external interface of the class.

Read only

Former Member
0 Likes
696

hi,

Public Section:

  • main class can access

  • sub class can access

  • friend class can access

Protected Section:

  • main class can access

  • sub class can access

  • friend class can access

Private Section:

  • main class can access with the help of public mehod

  • sub class cannot access

  • friend class can access

Read only

Former Member
0 Likes
695

Hi ganesh,

Basically the idea of sections(public, protected and private) is to restrict the access to those variables/itabs, etc that you declared in a given section. Here are its description:

Public Section

All of the components in the public sections are visible to all users of the class, and to the methods of the class and its subclasses. The public components form the external interface between the class and its users.

Protected Section

All of the components in the protected section are visible to the methods of the class and its subclasses. This section forms a special interface between the class and the classes that inherit from it.

Private Section

The components that you declare in the private section are only visible in the methods of the class itself. They are not visible at all externally. The private components form no part of the external interface between the class and its users.

Regards,

pankaj singh.

edited by pankaj singh.

Read only

former_member508729
Active Participant
0 Likes
695

Hi Ganesh,,

No Matter which technology we are going to use,the OOPs concepts are going to remain same, so as in ABAP also.

regards

Ashutosh

reward point if helpfull.

Read only

Former Member
0 Likes
695

THANKS FOR ALL UR ANSWERS

Read only

Former Member
0 Likes
695

hi ganesh,

Of the three Access Specifiers,

components declared as,

PUBLIC -> is accessable by any other class, also the base class, sub class and as well the friend class can access that component.

PROTECTED -> can be accessed by both base class and sub class, but by declaring a public method.A friend class say B can access the protected componenet of class A , as its taken as public(ie class A gives the permission for class B to take it as public.)

PRIVATE -> this can be accessed only by the class in which the component is declared. here again, a friend class say B can access the private componenet of class A , as its taken as public(ie class A gives the permission for class B to take it as public.)

Also, to access a private component, it can be done with thehelp of the public component of the same class,where in protected component is declared.

hope this info would be of help to u.

all the best.