10-27-2015 7:39 AM
Hi GURUs,
I recently read the book ABAP Objects by Horst Keller & Sascha Kruger. I understand the concepts of Object Orientation, but I can hardly find any practical implementation of them in my day to day ABAP programming - for example, I know what singleton class is and how to create one, but where do we use it? I don't think it'll be of any real use to us if we just know it theoretically. Is there any other book/material that explains where exactly we can implement these concepts? Or if anyone here has worked on OOABAP extensively can you please let me know? It'll be of great help.
Thanks,
Sarif
10-27-2015 7:46 AM
Dear Sarif,
There are places where we need to use OO ABAP.
One place where we use OO ABAP is in Webdynpro developments.
Regards
Shaik
10-27-2015 9:58 AM
Good day Sarif,
OO ABAP is important to know, when you have debug SAP Standard solution like SAP SRM 7.0.
The solution is webdynpro & entirely written on OO ABAP.
When you doing Exception handling as well you needs to understand the exception classes e.g. CX_ROOT,CX_SY_OPEN_SQL_DB.
Data : lv_num1 type I,lv_num2 type I,lv_sum type I.
Try.
lv_sum = lv_num1 + lv_num2.
catch cx_sy_arithmetic_overflow.
message 'Maximum for tot Exceeded' Type 'A'.
endtry.
Just few usage.
Regards,
Tumelo Modise
10-27-2015 11:18 AM
Where you'll need a singleton? In every case you need just one object of a class.
10-27-2015 11:31 AM
Hi Guys
Thanks for reply.
I'm sorry if my question was not clear. I'm not asking for hypothetical situation where I may be required to use some object oriented concept, but rather if/where you have come across situation where you have used singleton/friend/abstraction/interface/inheritance/polymorphism or any other OO concept in core ABAP(not Webdynpro).
Thanks,
Sarif
10-27-2015 11:52 AM
I'll give you an example:
I select a bunch of documents from VBAK/VBAP. To ensure, that I do not have more than one object for a single document, I use an enhanced singleton (a so called multiton), which means, I have an internal table with the columns document no. and object.
Another example you can read here. Much more examples you can get in the books/ebooks Design Patterns in Object Oriented ABAP and ABAP to the Future.
10-28-2015 7:51 AM
Hi Sarif
ABAP OO can be used to design robust custom solutions too - all the concepts like abstraction, interface, polymorphism, inheritance comes into play in such design.
Check out some of the custom OO solutions I've blogged about below.
There is also a Project Objectify with a GitHub repository of various ABAP classes that can be reused.
Rgds
Eng Swee
10-28-2015 8:57 AM
Hi,
rarly needed those - 10 years of programming
only when developing big frameworks and its getting complex the exotic types helps.
in 99,99% of developing e.g. a simple programm, a normal class is doing the job.
regards
Stefan Seeburger
10-28-2015 9:34 AM
I've occasionally converted classes with only static members to singletons. It makes extensions via polymorphism or inheritance easier.
I do use the factory pattern and multi-ton pattern quite regularly though.
10-27-2015 1:03 PM
10-28-2015 8:22 AM
You might as well ask "What's the use of procedural programming?". Object oriented programming approaches programming from the idea that we're dealing with entities that do things, rather than process flows.
Singletons, etc. are patterns that solve specific programming problems in an object oriented way. Other patterns are factory, observer, MVC, decorator etc.
We don't wake up in the morning and decide "today I'm going to use a singleton". Rather we have a specification and notice that for safety's sake, we really need to only have one instance of the class we've written. So we adjust the class (and its users) to make it a singleton.
When you start OO programming though, you just create classes, instantiate everything with CREATE OBJECT. It's only as you gain experience that you start to use design patterns, interfaces, inheritance, abstract classes and polymorphism.
10-28-2015 8:39 AM
Matt's right.
The more you use objects, the more objects you use....if you get my meaning. I find it a more natural way of programing as well.
Rich