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

Class-DEFERRED?

Hi,

In creation of CLASSES, we use the DEFERRED, INHERETED, LOAD and for declaring the Methods & Import paras., we use PUBLIC SECTION, PRIVATE SECTION, So What does they mean?

ThanQ.

Message was edited by:

Srinivas

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Mar 13, 2007 at 04:10 PM

    Hi,

    Here is a small example on using class deferred.

    Suppose you have 2 class ... Class1 and Class2

    Using the Class deferred, you are indicating the system that the class what you are defining is in the same context.

    For example.

    Class Class2 defination deferred.

    CLASS Class1 DEFINITION.

    DATA ABCD TYPE REF TO Class2.

    "here you can still able use the reference variable of Class 2 although you haven't declared it as yet.

    ENDCLASS.

    CLASS Class2 DEFINITION.

    DATA XYZ TYPE REF TO Class1.

    ENDCLASS.

    Otherwise, SAP would have looked for Class2 in the global library and would have given you error. So, in simple words its an indication to the system that 'Do not look in the higher level context'.

    Regards,

    Ferry Lianto

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 13, 2007 at 04:10 PM

    hi,

    chk this help

    The variant with the DEFERRED addition makes a class known provisionally in the program.

    Without the PUBLIC addition, this variant makes a local class known before its actual definition. The program must contain an actual declaration part for class at a later point in the program. You cannot access individual components of the class before it is actually defined. You need to use this statement if you want to make a reference to a local class before it is defined.

    With the PUBLIC addition, this variant makes a global class known and defers loading the class until the end of the current program unit. You can only access individual components of the class after it has been loaded. This statement can be used to prevent unwanted recursion when making references to global classes.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 13, 2007 at 04:23 PM

    hi Srinivas,

    Public components:
         -  visibile to all
    Protected components:
         - visible within class
         - visible within subclasses
    Private componets:
         - only visible within the class

    Hope this helps,

    Sajan Joseph.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 13, 2007 at 04:23 PM

    hi,

    <b>Deferred.</b>

    Used to refer to a class at some point in a code and the class is not defined before the line.

    CLASS C2 DEFINITION DEFERRED.
     CLASS C1 DEFINITION.
      PUBLIC SECTION.
        DATA O2 TYPE REF TO C2.
     ENDCLASS.
     CLASS C2 DEFINITION.
      public section.
        data : num type i value 5.
    ENDCLASS.
    start-of-selection.
     data : obj1 type ref to C1.
      CREATE OBJECT obj1.
      create object obj1->o2.
      write:/5 obj1->o2->num .

    <b>Load</b>

    The compiler normally loads the description of a global class from the class library the first time you use the class in your program . However, if the first access to a global class in a program is to its static components or in the definition of an event handler method , you must load it explicitly using the statement CLASS class DEFINITION LOAD. This variant has no corresponding ENDCLASS statement.

    <b>Visibility of Components</b>

    Each class component has a visibility. In ABAP Objects the whole class definition is separated into three visibility sections: PUBLIC, PROTECTED, and PRIVATE. One can never change component visibility via inheritance.

    <b>PUBLIC:</b> This section is made up of the subclass' own public components together with all public components of all superclasses. There is unrestricted access to the public section of the subclass.

    <b>PROTECTED:</b> This section is made up of the subclass' own protected components together with all protected components of all superclasses .

    <b>PRIVATE:</b> This section is made up of the subclass' own private components accessible only in that subclass. Each subclass works with its own private components and can't even use the private components of its superclasses. But as long as a method inherited from a superclass is not redefined, it still uses the private attributes of the superclass, not those of the subclass, even if the subclass has private attributes of the same name.

    Hope this helps.

    Regards,

    Richa

    Add a comment
    10|10000 characters needed characters exceeded

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.