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

protected method

Former Member
0 Likes
508

Hi experts

how to call a protected method .

thanks

priyank

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
480

Hi,

You can call a protected method in a class if the class is a subclass of that super class.

for that use inheritance.

class super_class definition.
 protected section.
 methods protected_method.
endclass.

class super_class implementation.
 method protected_method.
  ...............
...............
end method.
endclass.

Class sub_class inheriting from super_class.

endclass.


Class sub_class implementation.
 method protected_method.   " If you are redefining
  ............
...........

end method.

endclass.

start-of-selection.

data: ref_sub type ref to sub_class. " referenec variable

create object ref_sub.   "creating instance or object

call method ref_sub->protected_method.  " calling the protected method

like that

check out this link-

http://www.sapbrainsonline.com/ARTICLES/TECHNICAL/OBJECTS/objects.html

Regards,

Sujit

3 REPLIES 3
Read only

Former Member
0 Likes
481

Hi,

You can call a protected method in a class if the class is a subclass of that super class.

for that use inheritance.

class super_class definition.
 protected section.
 methods protected_method.
endclass.

class super_class implementation.
 method protected_method.
  ...............
...............
end method.
endclass.

Class sub_class inheriting from super_class.

endclass.


Class sub_class implementation.
 method protected_method.   " If you are redefining
  ............
...........

end method.

endclass.

start-of-selection.

data: ref_sub type ref to sub_class. " referenec variable

create object ref_sub.   "creating instance or object

call method ref_sub->protected_method.  " calling the protected method

like that

check out this link-

http://www.sapbrainsonline.com/ARTICLES/TECHNICAL/OBJECTS/objects.html

Regards,

Sujit

Read only

Former Member
0 Likes
480

Hi

create the instance for the subclass then you can call that method.

Regards

Manjari.

Read only

Former Member
0 Likes
480

Hi,

Create the subclass to the class from which the protected method should be invoked. Then use that subclass and call that protected method.