Super class methods

How to get the methods of current class and its super class using reflection. The retrieved methods should be only the methods of user-defined classes but not methods of Java APIs such as Object or any other class provided in JDK.
For ex, If Class B is inheriting Class A, i need the methods which are declared only in A & B but not from the Object Class. Similarly, If class C is extending any JDK API such as Thread, I need only the methods declared in class C.

thanku very much for the answer.
I am trying to execute the methods of another class using reflection. So I have to consider the inherited methods also. For that, I have to differentiate between standard classes & user-defined classes.Assume that u have one GUI screen where in once u select a class all its methods including inherited methods have to be displayed.
I can get the the superclass using the method getSuperClass(). But inorder to get the protected methods of superclass what is the method to be used ? If I use getMethods(), it returns only public methods, where as getDeclaredMethods() returns all the methods. Since I have to execute only public & protected methods, what is the best way to solve this ?

Similar Messages

  • Calling the super class method from the subclass

    Hi all,
    I have a question about inheritence and redefinition of methods. Is it possible to call the superclass implementation of a method which is redefined in the subclass in another method of the subclass?There are possbilities like creation of an explicit super class instance or delegating the super class method implementation to another method which is also protected etc. What i mean is, is there a direct way of calling it?We have ,me,   as the reference for the instance we have(which is the subclass instance in this case), is there also a way of pointing the superclass implementation(with super we can reference in the subclass redefinition, my question is if we have such a parameter in other methods of the subclass too)
    Thanks in advance
    Sukru

    Hi,
    The super reference can only be used in redefined methods to call superclass implementation . So probably what you can do is use upcasting and access the required superclass implementation. I can think of only this way...;-)
    Ex data lr_super type ref to cl_superclass
    lr_super = lr_subclass.
    lr_super->method().
    ~Piyush Patil

  • Is it possible to OVERLOAD a super-class method in a sub-class?

    Hi all,
    I have a query that
    Is it possible to OVERLOAD a super-class method in a sub-class?
    If it is possible, please give me an example.
    Thanks,
    Hari

    Hi,
    Is the method int Display(int a){} overloading
    the super-class's void Display() method? If
    possible, please clarify this and how it would be
    method overloading?
    hanks,
    Hari
    Hi Hari,
    Yes, it is possible. Look at this piece of code:
    class Senior
         void Display()
              System.out.println("Super class method");
    class Junior extends Senior
         int Display(int a)
              System.out.println("Subclass method: "+a);
              return(a+10);
         }> }
    class example
         public static void main(String args[])
              Junior j = new Junior();
              j.Display();
    System.out.println("Subclass method
    od "+j.Display(5));
    Is this what you were asking? Hope this helped.Hi,
    I guess you guys are confused here...
    Overloading is achieved by methods in the same class...
    Overriding is across a superclass subclass methds.

  • Overiding super class method to an abstract  method

    public class Super
    public void doSomethingUseful()
    public abstract class Sub extends Super
    public abstract void doSomethingUseful();
    What is the OO principle behind this?
    When do we need to override a super class method in subclass as an abstract?

    Lets first look at a simple design pattern called "Template Method".
    public abstract class Library
    private void collectBooks()
    // collect books here
    private void putBookInShelf()
    // put books in shelf here
    // abstract method sortBooks()
    public abstract void sortBooks();
    public void processBooks()
    collectBooks();
    sortBooks();
    putBooksInShelf();
    this class is an abstract class giving an abstract method called "sortBooks()", what is it useful for? We can make a subclass and implement sortBooks() to sort the books as we want (title wise, author wise, date wise, publisher wise) and then simply call processBooks() to process them.
    One Sub class may look like:
    public class MyLibrary extends Library
    public void sortBooks()
    // sort books by title b/c I like them sorted out by title
    Another sub-class may look like
    public class HisLibrary extends Library
    public void sortBooks()
    // sort books by Author, b/c he likes his books sorted out by author
    Now client will say:
    public static void main(String str[])
    MyLibrary mylib=new MyLibrary();
    mylib.processBooks(); // books will be processed by sorting them title wise
    HisLibrary hislib=new HisLibrary();
    hislib.processBooks(); // books will be processed by sorting them author wise
    So in Library class, method "sortBooks()" was a template method allowing subclasses to sort the books as they want while all other functionality was implemented by Library class itself.
    Now if we go back to your example, a method which is concrete in super class that you converted into an abstract method in sub class ( doSomethingUseful() ) is now a template method, which alows the sub classes of this subclass to do something useful what they think is useful or in other words you are allowing subclasses of this subclass to implement this template method as they want by using their own algorithm.
    Now why whould you do that? answer is that you don't have access to the code of super class, otherwise you must have made this method abstract in super class in the first place.
    Note that the code may not compile, I tried to come up with an exmple and did not pay attention to compiler demands.
    I think I cleared my point, It was tough to explain though.
    Good Luck.
    Khawar.

  • Can we chagne Super class method parameters in Sub class

    Hi,
    I created a super class.  In that class i created a method. That method is having 4 input parameters and 4 export parameters.
    I created a sub class for that super class. I need to use only 2 input parameters in this class rather than 4 parameters. I want to delete 2 Input parameters in the sub class of the super class method.  Is it possible.
    If possible. can we give an simple code or pseudo code?
    regards,
    krishna

    Hi,
    I think you can not.
    Because, only public attributes can be inherited and they will remain public in the subclass.
    for further detail check,
    http://help.sap.com/saphelp_nw70/helpdata/en/1d/df5f57127111d3b9390000e8353423/content.htm
    regards,
    Anirban

  • How to pass importing parameter of super class method to subclass method?

    hi all,
    i have defined  a class
    CLASS CUST_REPORT DEFINITION.
      PUBLIC SECTION.
        METHODS:DATA_RETRIVE IMPORTING  CUSTID_LOW  TYPE ZCUSTOMER-ZCUSTID
                                       CUSTID_HIGH TYPE ZCUSTOMER-ZCUSTID.
        DATA:IT_CUST TYPE TABLE OF ZCUSTOMER,
             WA_CUST TYPE ZCUSTOMER.
    ENDCLASS.                    "cust_report DEFINITION
    The method DATA_RETRIVE   in this class  has two importing parameters named CUSTID_LOW   and CUSTID_HIGH.
    then i have defined subclas of this clas.
    LASS CUST_ORD DEFINITION INHERITING FROM CUST_REPORT.
      PUBLIC SECTION.
        DATA:IT_ORD TYPE TABLE OF ZORDER.
        METHODS:DATA_RETRIVE  REDEFINITION,
               DISPLAY.
    ENDCLASS.                    "cust_ord DEFINITION
    Method DATA_RETRIVE   is redefined.
    So how to pass importing parameteres of super class method to sub class method with the same name.
    Thanks and Regards,
    Arpita

    Hi,
    I tried like this.
    METHOD DATA_RETRIVE.
    CALL METHOD SUPER->DATA_RETRIVE
          EXPORTING
            CUSTID_LOW  = I_CUSTLOW
            CUSTID_HIGH = I_CUSTHIGH.
    ENDMETHOD.
    But  parameters I_CUSTLOW and I_CUSTHIGH are not getting values after call to method.
    Thanks and Regards,
    Arpita

  • Overriding super class methods @ OIM 9x

    Hi All,
    I'm working on a requirement where I need to override superclass method in sub class.The problem is, method defined in sub class is not getting called by OIM.
    My question more looks like Pure Java related,but as it is OIM which uses Struts, calling of ActionForward methods defined in
    protected Map getKeyMethodMap()
    +{+
    +}+
    Super class is OUT OF BOX class and sub class is I m developing.Both superclass & subclass having the protected Map getKeyMethodMap() method with same declaration.
    Can any one give me a clue on this.
    Regards,
    Krish

    HI All,
    Issue resolved after deleting stage & tmp folders in weblogic instance directory and restarted weblogic instance.
    Regards,
    Krish

  • Can we call super class method from Overwrite method using SUPER keyword

    Hi All,
    For one of our requirement , I need to overwrite "Process Event" method of a feeder class  ,where process event is present is protected method. so when we are making a call , then its saying
    "Method  "process event"  is unknown or Protected  or PRIVATE ".
        But we are just copied the source code in the "Process Event" method to the Overwrite method.
    Can anyone provide me the clarification , why system behaving like this.
    Thanks
    Channa

    Hi,
    I think you can not.
    Because, only public attributes can be inherited and they will remain public in the subclass.
    for further detail check,
    http://help.sap.com/saphelp_nw70/helpdata/en/1d/df5f57127111d3b9390000e8353423/content.htm
    regards,
    Anirban

  • Super class methods not shown when Model is generated

    I have some EJB's that return a result class, that extend a common class.
    eg:
    public class Result extends AResult implements Serializable {
    method getMethodA();
    method getMethodB();
    public abstract class AResult implements Serializable{
    method getMethodC();
    This EJB has been exposed using a web services and I am trying to construct a model based on this WS.
    The in the moded, while doing the context mapping i cannot see the
    getMethodC()
    from the superclass.
    However the code for the model seems to be correct i.e. the proxy classes generated have the correct structure.
    Anyone encountered this before? Is this a bug?
    Thanks,
    Manik.

    thanku very much for the answer.
    I am trying to execute the methods of another class using reflection. So I have to consider the inherited methods also. For that, I have to differentiate between standard classes & user-defined classes.Assume that u have one GUI screen where in once u select a class all its methods including inherited methods have to be displayed.
    I can get the the superclass using the method getSuperClass(). But inorder to get the protected methods of superclass what is the method to be used ? If I use getMethods(), it returns only public methods, where as getDeclaredMethods() returns all the methods. Since I have to execute only public & protected methods, what is the best way to solve this ?

  • Accessing Super Class methods

    Hi,
    If I have a Subclass that overrides a method in a superclass, is it possible to call that method from the superclass?
    Thanks

    Hi thanks for the reply, but that works for static methods, I'm trying to figure out non-static methods. Below, I want to call the method a() from the superclass using an instance of the subclass.
    class superclassA
    void a()
    System.out.println("in method a");
    class subclassA extends superclassA
    void a()
    System.out.println("in method b");
    public class overtest
    public static void main(String [] args)
    subclassA sub = new subclassA();
    superclassA.a();//non-static method a cannot be referenced from a static context
    Thanks!

  • Need to access a parameter in a super class method

    Hi,
    I have the following setup:
    class A{
        exceptionHandler(Throwable ex, int iNeedThis);
    class B extends A{
        execute();
        func1{};
    }When execute() fails, the ecexptionHandler method is automatically called. In func1() of class B I need to access the iNeedThis variable once excute() fails. Is it possible to do this?
    Thanks.

    wow, thats about impossible to follow.
    Let me take a stab.
    If you want to save a value for later use when an exception is thrown, throw your own exception type that stores this info in the exception.
    Or perhaps you are asking something completely different.

  • Weird one..  i can't return a variable from the extended to the super class

    Hey everyone, i hope i'm not annoying you guys :)
    So today's problem is to return a variable (int) from a method of the extended class and print it ont the super class.
    I'm just testing the super class , if it works fine.
    So the extended class ( FileIO) just read the file txt and return the integer or string ( from the txt file)
    I already did a main method to that class and tested it, it works fine.
    So now the problem is to print the integer ( that the extended class gets from the txt. ) inside the Super class. I mean , is the same thing but now im testing the Super class , just have to do the same thing, a super class method calls the extended class method and receive the integer from the txt file.
    i think the problem is when i create the instance of the FileIO object , maybe its constructor ...i don't know.
    The name of the txt file is passed from the super class to the extended class, but i think the error is not from there.
    this.aero_le = new BufferedReader(new FileReader(super.ficheiroleitura_aero()));  //  super calls ficheiroleitura_aero()  and receive the name of the txt file ( e.g "temp.txt")  so i think that is correct.
    here's the code of the Super class public class Aeroporto {
         private String filereader_voo = "temporary.txt";
         private String filereader_aero = "temp.txt";
         private String siglaAero = "";
         public FileIO file;
         public Aeroporto(){};
         public Aeroporto(String filereader_voo, String filereader_aero) throws IOException{
              this.filereader_voo = filereader_voo;
              this.filereader_aero =filereader_aero;     
              file = new FileIO();
         public String siglaAero() {
              return siglaAero; }
         public String filereader_aero(){
              return filereader_aero;
    public int nrLines() throws IOException{   // it was supose to retunr the number of lines ( integer) from the txt file .
              return Integer.parseInt(file.lerLinhaN(1,1));
    // main() {
    Aeroporto a = new Aeroporto();
              int v = a.nrLines();
              System.out.print(v);
    // ***********************************************************+
    // Extended Class
    public class FileIO extends Aeroporto{
         private String ficheiroescrita;
         private PrintWriter vooescreve, aeroescreve ;
         private BufferedReader voo_le, aero_read;
         public FileIO(){}
         public FileIO(String filereader_voo, String filereader_aero, String ficheiroescrita) throws IOException {
              super(filereader_voo, filereader_aero);
              this.ficheiroescrita = ficheiroescrita;
              //If file does not exists , create one.
              try{
                   this.aero_read = new BufferedReader(new FileReader(super.filereader_aero()));
                   aero_read.close();
              catch(IOException ex){
                   this.aeroescreve = new PrintWriter(new FileWriter(ficheiroescrita));
                   aeroescreve.close();
    public String lerLinhaN(int line, int column) throws IOException{  // this method works fine , i already tested this class.
              this.aero_read = new BufferedReader(new FileReader(super.filereader_aero()));
              for(int i = 0; i != line-1; ++i) aero_read.readLine();
              String linha = aero_read.readLine();
              String [] words = linha.split(" ");
              return words[column-1];
    Maybe the error is that i use to test the Super class a default contructor on both classes... i don't know where the error is, i also did two small classes ( super and another that extends ) and get the string "Hello" from the super and print it inside the extended..and it works, that's why i think the error is when i call the extended class .. need help.
    thanks.

    Ok,
    This one might actually work... atleast it compiles.import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.File;
    import java.io.PrintWriter;
    import java.io.FileWriter;
    import java.io.IOException;
    public abstract class FileIO {
         public static boolean CreateOutputFileIfNotExists(
              String outputFilename //the name of the file to ensure exists.
         ) throws IOException
              final String functionName = "FileIO.CreateOutputFileIfNotExists";
              boolean retVal = false;
              //If the output file does does not exist then create it.
              //post condition: output file exists or an IOException has been thrown.
              BufferedReader infile = null;
              try{
                   infile = new BufferedReader(new FileReader(outputFilename));
                   retVal = true;
              } catch(IOException ex) {
                   PrintWriter outfile = null;
                   try {
                        outfile = new PrintWriter(new FileWriter(outputFilename));
                        retVal = true;
                   } catch(IOException ex2){
                        throw new IOException(functionName + ": cannot create output file " + outputFilename, ex2);
                   } finally {
                        outfile.close();
                        if (outfile.checkError()) {
                             throw new IOException(functionName + ": error on output stream " + outputFilename);
              } finally {
                   try {
                        infile.close();
                   } catch(IOException ex){
                        throw new IOException(functionName + ": cannot close output file " + outputFilename, ex);
              return(retVal);
         public static String readLine(
                   String  inputFilename //the name of the file to read.
              , int     lineNumber    //1 based number of the line to read from.
         ) throws IOException
              final String functionName = "FileIO.readLine";
              String outputLine = null;
              // reads the numbered "lineNumber" from "inputFilename".
              BufferedReader infile = null;
              try {
                   infile = new BufferedReader(new FileReader(new File(inputFilename)));
                   for(int i=1; i<lineNumber; ++i) infile.readLine();
                   outputLine = infile.readLine();
              } catch(IOException ex){
                   throw new IOException(functionName + ": cannot read input file " + inputFilename, ex);
              } finally {
                   try {
                        infile.close();
                   } catch(IOException ex){
                        throw new IOException(functionName + ": cannot close input file " + inputFilename, ex);
              return(outputLine);
         public static String readWord(
                   String inputFilename  //the name of the file to read.
              , int lineNumber        //1 based number of the line to read from.
              , int wordNumber        //0 based number of the word to read.
         ) throws IOException
              final String functionName = "FileIO.readWord";
              String outputWord = null;
              // reads the numbered space-seperated "wordNumber" from the numbered "lineNumber" of "inputFilename"
              try {
                   String[] words = FileIO.readLine(inputFilename, lineNumber).split(" ");
                   if (wordNumber>0 && wordNumber<words.length) outputWord = words[wordNumber-1];
              } catch(IOException ex){
                   throw new IOException(functionName + ": cannot read input file " + inputFilename, ex);
              return(outputWord);
    }Design notes... FileIO is a generic helper class... there is nothing specific to Airports, flights, or any other "domain" specific stuff in it... so it's re-usable... you can keep it and reuse it on other projects, or even share it with your friends.
    So... The airport class will just call the static methods on FileIO like this    ....
        int lineNumber=1;
        int wordNumber=1;
        String airportCode = FileIO.readWord(airportsFilename, lineNumber, wordNumber);
        ....How's that?
    corlettk: my now mandatory edit.

  • Regarding Super classes

    Hi,
    I have created one class in SE24. This class will be used as a super class for other classes.
    When subclasses are derived from this superclass, i want to make sure that some of the methods of superclasses are redefined by the subclasse compulsarily.
    So i want to force the subclasses to redefine complusarily some of the methods of its super class.
    Is this feasible. If so please let me know the corresponding approach.
    Thanks in advance !
    Pramod

    Hi,
    Check this out this will help you.
    Inheritance is the concept of passing the behavior of a class to another class.
    1.You can use an existing class to derive a new class.
    2.Derived class inherits the data and methods of a super class.
    3.However they can overwrite the methods existing methods and also add new once.
    4.Inheritance is to inherit the attributes and methods from a parent class.
    Inheritance:
    Inheritance is the process by which object of one class acquire the properties of another class.
    Advantage of this property is reusability.
    This means we can add additional features to an existing class with out modifying it.
    Go to SE38.
    Provide the program name.
    Provide the properties.
    Save it.
    Provide the logic for inheritance.
    *& Report  ZLOCALCLASS_VARIABLES                      *
    *&----------------------------------------------------*REPORT  ZLOCALCLASS_VARIABLES.
    *OOPS INHERITANCE
    *SUPER CLASS FUNCTIONALITY
    *DEFINE THE CLASS.
    CLASS CL_LC DEFINITION.
    PUBLIC SECTION.
    DATA: A TYPE I,
          B TYPE I,
          C TYPE I.
    METHODS: DISPLAY,
             MM1.
    CLASS-METHODS: MM2.
    ENDCLASS.
    *CLASS IMPLEMENTATION
    CLASS CL_LC IMPLEMENTATION.
    METHOD DISPLAY.
    WRITE:/ 'THIS IS SUPER CLASS' COLOR 7.
    ENDMETHOD.
    METHOD MM1.
    WRITE:/ 'THIS IS MM1 METHOD IN SUPER CLASS'.
    ENDMETHOD.
    METHOD MM2.
    WRITE:/ 'THIS IS THE STATIC METHOD' COLOR 2.
    WRITE:/ 'THIS IS MM2 METHOD IN SUPER CLASS' COLOR 2.
    ENDMETHOD.
    ENDCLASS.
    *SUB CLASS FUNCTIONALITY
    *CREATE THE CLASS.
    *INHERITING THE SUPER CLASS.
    CLASS CL_SUB DEFINITION INHERITING FROM CL_LC. "HOW WE CAN INHERIT
    PUBLIC SECTION.
    DATA: A1 TYPE I,
          B1 TYPE I,
          C1 TYPE I.
    METHODS: DISPLAY REDEFINITION,     "REDEFINE THE SUPER CLASS METHOD
             SUB.
    ENDCLASS.
    *CLASS IMPLEMENTATION.
    CLASS CL_SUB IMPLEMENTATION.
    METHOD DISPLAY.
    WRITE:/ 'THIS IS THE SUB CLASS OVERWRITE METHOD' COLOR 3.
    ENDMETHOD.
    METHOD SUB.
    WRITE:/ 'THIS IS THE SUB CLASS METHOD' COLOR 3.
    ENDMETHOD.
    ENDCLASS.
    *CREATE THE OBJECT FOR SUB CLASS.
    DATA: OBJ TYPE REF TO CL_SUB.
    START-OF-SELECTION.
    CREATE OBJECT OBJ.
    CALL METHOD OBJ->DISPLAY. "THIS IS SUB CLASS METHOD
    CALL METHOD OBJ->SUB.
    WRITE:/'THIS IS THE SUPER CLASS METHODS CALLED BY THE SUB CLASS OBJECT'COLOR 5.
    SKIP 1.
    CALL METHOD OBJ->MM1.     "THIS IS SUPER CLASS METHOD
    CALL METHOD OBJ->MM2.
    *CREATE THE OBJECT FOR SUPER CLASS.
    DATA: OBJ1 TYPE REF TO CL_LC.
    START-OF-SELECTION.
    CREATE OBJECT OBJ1.
    SKIP 3.
    WRITE:/ 'WE CAN CALL ONLY SUPER CLASS METHODS BY USING SUPER CLASS OBJECT' COLOR 5.
    CALL METHOD OBJ1->DISPLAY. "THIS IS SUPER CLASS METHOD
    CALL METHOD OBJ1->MM1.
    CALL METHOD OBJ1->MM2.
    This example will help you to solve your problem.
    For more detailed information GOTO -> SAPTECHNICAL ->Tutorials -> Object Oriented Programming.
    Regards Madhu.
    Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 12:13 PM

  • Error while calling a super class public method in the subclass constructor

    Hi ,
    I have code like this:
    CLASS gacl_applog DEFINITION ABSTRACT.
      PUBLIC SECTION.
        METHODS:
                create_new_a
                   IMPORTING  pf_obj       TYPE balobj_d
                              pf_subobj    TYPE balsubobj
                              pf_extnumber TYPE string
                   EXPORTING  pfx_log_hndl TYPE balloghndl
                   EXCEPTIONS error
    ENDCLASS.
    CLASS gacl_applog IMPLEMENTATION.
      METHOD create_new_a.
        DATA: ls_log TYPE bal_s_log.
      Header aufsetzen
        MOVE pf_extnumber TO ls_log-extnumber.
        ls_log-object     = pf_obj.
        ls_log-subobject  = pf_subobj.
        ls_log-aluser     = sy-uname.
        ls_log-alprog     = sy-repid.
        ls_log-aldate     = sy-datum.
        ls_log-altime     = sy-uzeit.
        ls_log-aldate_del = ls_log-aldate + 1.
        CALL FUNCTION 'BAL_LOG_CREATE'
             EXPORTING
                  i_s_log      = ls_log
             IMPORTING
                  e_log_handle = pfx_log_hndl
             EXCEPTIONS
                  OTHERS       = 1.
        IF ( sy-subrc NE 0 ).
          MESSAGE ID      sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH    sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
                  RAISING error.
        ENDIF.
      ENDMETHOD.
    CLASS gcl_applog_temp DEFINITION INHERITING FROM gacl_applog.
      PUBLIC SECTION.
        DATA: log_hndl   TYPE balloghndl READ-ONLY
            , t_log_hndl TYPE bal_t_logh READ-ONLY
        METHODS: constructor
                   IMPORTING  pf_obj       TYPE balobj_d
                              pf_subobj    TYPE balsubobj
                              pf_extnumber TYPE string
                   EXCEPTIONS error
               , msg_add      REDEFINITION
               , display      REDEFINITION
    ENDCLASS.
    CLASS gcl_applog_temp IMPLEMENTATION.
      METHOD constructor.
        CALL METHOD create_new_a
               EXPORTING  pf_obj       = pf_obj
                          pf_subobj    = pf_subobj
                          pf_extnumber = pf_extnumber
               IMPORTING  pfx_log_hndl = log_hndl.
        IF ( sy-subrc NE 0 ).
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
                  RAISING error.
        ENDIF.
      ENDMETHOD.
    A public method of Super class has been called from the constructor of the sub class. we are getting the syntax error :
    ' In the constructor method, you can only access instance attributes, instance methods, or "ME" after calling the constructor of the superclass…'
    Can you please suggest how to change the code with out affecting the functioanlity.
    Thank you ,
    Lakshmi.

    Hi,
    Call that method by instance of Subclass.   OR
    SUPER-->method.
    Read very useful document
    Constructors
    Constructors are special methods that cannot be called using CALL METHOD. Instead, they are called automatically by the system to set the starting state of a new object or class. There are two types of constructors - instance constructors and static constructors. Constructors are methods with a predefined name. To use them, you must declare them explicitly in the class.
    The instance constructor of a class is the predefined instance method CONSTRUCTOR. You declare it in the public section as follows:
    METHODS CONSTRUCTOR
            IMPORTING.. [VALUE(]<ii>[)] TYPE type [OPTIONAL]..
            EXCEPTIONS.. <ei>.
    and implement it in the implementation section like any other method. The system calls the instance constructor once for each instance of the class, directly after the object has been created in the CREATE OBJECT statement. You can pass the input parameters of the instance constructor and handle its exceptions using the EXPORTING and EXCEPTIONS additions in the CREATE OBJECT statement.
    The static constructor of a class is the predefined static method CLASS_CONSTRUCTOR. You declare it in the public section as follows:
    CLASS-METHODS CLASS_CONSTRUCTOR.
    and implement it in the implementation section like any other method. The static constructor has no parameters. The system calls the static constructor once for each class, before the class is accessed for the first time. The static constructor cannot therefore access the components of its own class.
    Pls. reward if useful....

  • Calling a method from a super class

    Hello, I'm trying to write a program that will call a method from a super class. This program is the test program, so should i include extends in the class declaration? Also, what code is needed for the call? Just to make things clear the program includes three different types of object classes and one abstract superclass and the test program which is what im having problems with. I try to use the test program to calculate somthing for each of them using the abstract method in the superclass, but its overridden for each of the three object classes. Now to call this function what syntax should I include? the function returns a double. Thanks.

    Well, this sort of depends on how the methods are overridden.
    public class SuperFoo {
      public void foo() {
         //do something;
      public void bar(){
         //do something
    public class SubFoo extends SuperFoo {
       public void foo() {
          //do something different that overrides foo()
       public void baz() {
          bar(); //calls superclass method
          foo(); //calls method in this (sub) class
          super.foo(); //calls method in superclass
    }However, if you have a superclass with an abstract method, then all the subclasses implement that same method with a relevant implementation. Since the parent method is abstract, you can't make a call to it (it contains no implementation, right?).

Maybe you are looking for

  • New Fields For Free Goods Determination

    Hi everyone.  We need to add a new field for FG determination.  According to the documentation in SPRO, the new field should be added in SE11 KOMK under include KOMKZ for free goods.  However there is no KOMKZ include in KOMK.  How is this supposed t

  • How to enable recommended settings in the Firewall in my network

    Situation: we are using Windows 7 Pro on client machines in a domain environment. Windows Firewall is turned on by default. But we install Symantec Endpoint Protection which has a built-in firewall. Every time we install new version of Symantec Windo

  • Process Chain Terminates without errors

    Hi Experts, I'm facing a strange situation; my process chain terminates half way though. Loops are not completed till the end. e.g. it runs the Info Package and DTP then stop there, in some loops only the Info Package is run. There are no error messa

  • Issue with fragmentation

    I have an issue with fragmentation of indexes on my production server. on one of the production server database avg_fragmentation_in_percent column value of the non clustered indexes of many tables is nearly 100% and the client wants to know if this

  • FM to retrieve data from IT0589

    Dear Friends: I'm looking for a Function Module to fetch data recorded in Infotype 0589. Is there any such function module available? I have tried using this FM: HR_SPA_RETRIEVE_FROM_IT0589 but it is not fetching data. regards, Sreekanth Reddy