on 06-10-2005 11:10 AM
Hi All,
We all know that a global class creation is very helpful wherein the class can be reused by multiple programs.In contrast when is it best to use a local class within the program...?
Can anyone please share the sample scenarios where we need to make use of a local class...?
Cheers
Nishanth
Hi Nishanth,
I make the analogy between local classes and global classes and subroutines (forms) and function modules (not perfect, but it builds a picture in your mind).
Local classes are useful when you want to code using the object oriented paradigm, but the classes that you require are only of local relevance.
Having said, that, I am not a big user of local classes, as my feeling is that the overhead in developing them is not justified by any substantial benefits. Although, perhaps this view could be challenged now with new object specific functionality such as TRY/ENDTRY and so on.
It would be interesting to hear other people's opinion on this topic.
Cheers,
Brad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the viewpoints Brad..As quoted by you and as faced in practical applications i still haven't been able to figure out the competency of local classes against sub-routines.I wrote the same program in both the classical way and then by using only object-oriented approach.Neither do i see any significant performance difference nor any weighted reason of using local classes.That's why i was looking for possible practical applications or samples which justify it's use.
Cheers
Nishanth
Hi Nishanth,
First of all, there will be a few cases when creating a local class in your program is mandatory. For example,
if you're using an ALV Grid on your screen using the OO Approach, then you <b>must</b> declare a class locally in
your program if you want to handle the events. You cannot use a subroutine in this case.
Secondly, if you are looking for an explanation that is more introductory in nature, then the ABAP Programming
help has got some good documentation. Here are the links which explain the concepts with an example as a
transition from function groups to classes -
http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
Regards,
Anand Mandalika.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nishanth,
well I think you will not be very satisfied with my answer, but I use local classes always for
a) event handling of standard classes like ALV, SPLITTER, DOCKING-Container ... As Anand mentioned there is no other way to do it and
b) in case I am developing a more or less unique abap for which in the past (about 5 years ago) i would have used form routines. And in case of form routines I am using the methods of my local class. This keeps me trained on abap objects as my 'normal' business is BW consulting and not abap programming.
regards
Siggi
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.