‎2008 Aug 04 6:57 PM
Hi,
Iam new to OOPS ABAP.
I had one doubt,
Can we define and implement a new class inside a method... end method (like below)
Method M1
-
-
-
Class C1 Defination.
Class C1 Implementation
Method
Endmethod
-
-
-
Endmethod
Please suggest me on this how to proceed.
Regards
Srinivas
‎2008 Aug 04 7:04 PM
‎2008 Aug 04 7:05 PM
It is not possible.
Which requirment leads you to think to create class inside a class.?
Regards,
Naimesh Patel
‎2008 Aug 04 8:00 PM
Hi Rich Heilman/Naimesh
The requirement is
In XI Proxy(XI proxy is related to creation of materials in SAP),there are macros defined, and my client told us to find out wheather is it possible to replace the macros with the classes and methods.
Can i define a global class and call that method inside the class.
Method M1
-
-
-
Define a global class oref
create object.
Call method oref->m2.
-
-
-
Endmethod
Can i do it in the above way.Please suggest.
Regards
Srinivas
‎2008 Aug 04 8:04 PM
Sure, you can add private methods to the class, and call these private methods within that method. Or you can create another global class, with methods, and create an object of this class inside your method, and call the appropriate methods of this other global class.
There is no way to create an "inner class" in ABAP.
Regards,
Rich Heilman
‎2008 Aug 07 3:20 PM
‎2008 Aug 07 9:29 PM
Actually there's a third option: Inside your global class you can create as many local classes as you need. Not inside any method, but in the specific Local class Definition and Implementation sections (SE24 -> menu Goto -> Class Local-Types).
Then, somewhere in your class, you should create instances of those classes and you can call their methods.
Have in mind though, those local classes (as their name implies) are visible to your global class only. There's no external access.
Regards