2008 Sep 18 2:37 PM
Hi,
i inheritance to subclass from super ( global- se24)
and i have 2 constructors
1. CONSTRUCTOR - from the super
2.CLASS_CONSTRUCTOR - of the sub
i want to add parameters to Class constructor and i cant i get this Error (Class constructors and destructors do not have parameters and exceptions) way? the CONSTRUCTOR of the super have parameters .
Regards
2008 Sep 18 2:55 PM
CONSTRUCTOR could have the Importing parameter but the CLASS_CONSTRUCTOR will not have any parameter.
CLASS_CONSTRUCTOR is a static class and parameters to that method are not supported.
Check online help on the class_constructor.
Example from the help:
CLASS some_class DEFINITION.
PUBLIC SECTION.
CLASS-METHODS class_constructor.
PRIVATE SECTION.
CLASS-DATA access_program TYPE sy-repid.
ENDCLASS.
CLASS some_class IMPLEMENTATION.
METHOD class_constructor.
access_program = sy-repid.
ENDMETHOD.
ENDCLASS.
Regards,
Naimesh Patel
Hi,
i inheritance to subclass from super ( global- se24)
and i have 2 constructors
1. CONSTRUCTOR - from the super
2.CLASS_CONSTRUCTOR - of the sub
i want to add parameters to Class constructor and i cant i get this Error (Class constructors and destructors do not have parameters and exceptions) way? the CONSTRUCTOR of the super have parameters .
Regards
2008 Sep 18 2:55 PM
CONSTRUCTOR could have the Importing parameter but the CLASS_CONSTRUCTOR will not have any parameter.
CLASS_CONSTRUCTOR is a static class and parameters to that method are not supported.
Check online help on the class_constructor.
Example from the help:
CLASS some_class DEFINITION.
PUBLIC SECTION.
CLASS-METHODS class_constructor.
PRIVATE SECTION.
CLASS-DATA access_program TYPE sy-repid.
ENDCLASS.
CLASS some_class IMPLEMENTATION.
METHOD class_constructor.
access_program = sy-repid.
ENDMETHOD.
ENDCLASS.
Regards,
Naimesh Patel
2008 Sep 19 11:22 AM
HI Naimesh Patel ,
thanks ,
if i want to put parameters in constructor of sub class where i do that?
i ask it becouse i in the sub class i have
1. constructor - of the super class.
2. ClassConstructor - of the sub and i cant put in that parmaters .
so if i want to create object with parameters of type ref to the subcalss with export (to the constucor) how i do that?
Regards
2008 Sep 19 12:22 PM
Hi Ricardo,
Please check the CONSTRUCTOR section in this link
http://help.sap.com/saphelp_nw70/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
Stated that no parameters can be passed to CLASS CONSTRUCTOR.
Hope this would help you.
Good luck
Narin
2008 Sep 19 1:59 PM
Go to SE24.
Open your SubClass
And press the "Create Constructor" button
It will ask if you want to include the parameters from the Super class.
If you need than press Yes, else press NO.
So, when you create a reference of this class.
It will first call the Super's Constructor
Than Subclass's construtor.
Regards,
Naimesh Patel
2008 Sep 19 10:03 AM
Hi Ricardo,
CLASS_CONSTRUCTOR's are nothing but Static constructors. They do not have any parameters as
normal Constructors do.. In general these are used to instantiate a class.
In a CLASS_CONSTRUCTOR IMPLEMENTATION specify CREATE OBJECT <obj1>
Obj1 may be the ref of anyother class in your program.
So when ever the program is executed the Object is created for the class its referred.
Hope this would help you.
Good luck
Narin
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |