Skip to Content
author's profile photo Former Member
Former Member

Calling privated methods of a standar class from other zclass

Hi all.

I trying to call a privated method of a STANDAR_YYYY standar class(this class have all its methods privated). I see that this Class have a interface IF_STANDARD_YYY.

I have other ZXXXX class and it have one attribute YYYY_ATTR TYPE REF TO STANDAR_YYYY. In a method i instance the standar class (create object YYYY_ATTR...) but when i try to call a method <b>YYYY_ATTR->method1</b> i have a error activing the object ("you cannot access privated method YYYY_ATTR->method1). I was thinking that maybe using the interface IF_STANDAR_YYY in my ZXXXX class i will to call the private methods of the standar class STANDAR_YYY but when i did it obtanin this error "Before the IF_STANDARD_YYY statment, the interface in question must be fully defined". <b>What is wrong ?????</b>. If anybody can help me please!!!

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Mar 14, 2004 at 10:23 AM

    Usually, in Object Oriented Programming, you can't access private methods out side the class that defines them.

    If you want to access these methods, you MUST use the class that defines them, using interfaces don't makes an private method to be accessed from another class and you can't access a private method from a class that inherites from the private class.

    There is no other way that use the class that defines them, or to make a manual copy of them :).

    Maybe it will be helpfull for you to read Design Patterns in Object Oriented, I think Composition Pattern (I think this is the name of the pattern) is the one you must refer to.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Specials thanks to Sancho and Scott.

      I was testing and the only way to do that is modifying the SAP interface with the methods that i will use or maybe inserting my ZCLASS like a friend in the SAP standard class. I will to ask SAP to consider changing the interface of the class.

      Thanks a lot friends.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.