Application Development 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: 

OOABAP-How to access the protected methos from a class

Former Member
0 Kudos

How to access the protected methos from a class..There is a built in class..For tht class i have created a object..

Built in class name : CL_GUI_TEXTEDIT

method : LIMIT_TEXT.

How to access this..help me with code

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

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.

We can access the Protected components by inheriting the class.

<REMOVED BY MODERATOR>

Cheers,

Chandra Sekhar.

Edited by: Alvaro Tejada Galindo on Feb 19, 2008 2:22 PM

4 REPLIES 4

Former Member
0 Kudos

hi,

If inheritance is used properly, it provides a significantly better structure, as common components only

need to be stored once centrally (in the superclass) and are then automatically available to subclasses.

Subclasses also profit immediately from changes (although the changes can also render them invalid!).

Inheritance provides very strong links between the superclass and the subclass. The subclass must

possess detailed knowledge of the implementation of the superclass, particularly for redefinition, but also in

order to use inherited components.

Even if, technically, the superclass does not know its subclasses, the

subclass often makes additional requirements of the superclass, for example, because a subclass needs

certain protected components or because implementation details in the superclass need to be changed in

the subclass in order to redefine methods.

The basic reason is that the developer of a (super)class cannot

normally predict all the requirements that subclasses will later need to make of the superclass.

Inheritance provides an extension of the visibility concept: there are protected components. The visibility of

these components lies between that of the public components (visible to all users, all subclasses, and the class itself), and private (visible only to the class itself). Protected components are visible to and can be used by all subclasses and the class itself.

Subclasses cannot access the private components particularly attributes) of the superclass. Private

components are genuinely private. This is particularly important if a (super)class needs to make local

enhancements to handle errors: it can use private components to do this without knowing or invalidating

subclasses.

Create your class inse24 and inherit this CL_GUI_TEXTEDIT

class in yours. You can then access the protected methods.

Hope this is helpful, <REMOVED BY MODERATOR>

Edited by: Runal Singh on Feb 8, 2008 1:08 PM

Edited by: Alvaro Tejada Galindo on Feb 19, 2008 2:19 PM

Former Member
0 Kudos

Hi,

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.

We can access the Protected components by inheriting the class.

<REMOVED BY MODERATOR>

Cheers,

Chandra Sekhar.

Edited by: Alvaro Tejada Galindo on Feb 19, 2008 2:22 PM

rainer_hbenthal
Active Contributor
0 Kudos

If the programmer does not want that a certain method can be accessed he is setting the attribut protected to that method.

You can only use this method from inside the class.

There is no way to get access to that but do a modification on that class. Either you change the attribut or if you want to access that method from another metod you can set a friendship between both classes.

Former Member
0 Kudos

Thanks