Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

OOABAP - Preactical Use

Former Member
0 Kudos

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

11 REPLIES 11

shaik_sajid
Active Contributor
0 Kudos

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

former_member186660
Participant
0 Kudos

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

ralf_wenzel_heuristika
Active Participant
0 Kudos

Where you'll need a singleton? In every case you need just one object of a class.

Former Member
0 Kudos

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

0 Kudos

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.

0 Kudos

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

0 Kudos

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

matt
Active Contributor
0 Kudos

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.

peter_langner
Active Contributor
0 Kudos

Hi Sarif,

have a look e.g. at CL_SALV_TABLE.

Cheers,

Peter

matt
Active Contributor
0 Kudos

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.

0 Kudos

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