Skip to Content
avatar image
Former Member

OOABAP - Preactical Use

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Oct 28, 2015 at 08: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.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 27, 2015 at 01:03 PM

    Hi Sarif,

    have a look e.g. at CL_SALV_TABLE.

    Cheers,

    Peter

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 27, 2015 at 07: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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 27, 2015 at 09: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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 27, 2015 at 11:18 AM

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 27, 2015 at 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

    Add comment
    10|10000 characters needed characters exceeded

    • 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.