Skip to Content
author's profile photo
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 comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • author's profile photo
    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 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.