Skip to Content

I have been associated with JAVA and ABAP worlds from the start. Object Orientation in programming has gained more and more importance. OO ABAP and JAVA are object oriented programming styles. ABAP/4 was extended to support OO concepts. Object oriented concepts of Java, C++, etc… are adopted in OO ABAP and some features which are specific to ABAP; it  means there are some features in ABAP which are not supported in JAVA and vice versa. One more important aspect to consider is ABAP language is meant for business software development.

Similarities:

  Deadly Diamond of Death – Both OO ABAP and JAVA allow only one class extending/inheriting option.

   Inheritance, Polymorphism, encapsulation,

Differences:

Overloading is not supported in OO ABAP

Constructor concept is handled very differently in OO ABAP

Classes/Interface in OO ABAP along with attributes and functions have events. Event concept is important feature of OO ABAP in which the one object raises event; based on the requirement; client objects can subscribe to it.

Biggest difference as per my knowledge  – Collections(ArrayList, Vector, LinkedList, Queue, Hashtable, TreeMap, LinkedHashMap, LinkedHashSet, TreeSet) play important role in Java; no equivalent in OO ABAP. Internal tables and work area can be used whenever we need collection i.e. to process basket of data.

I know above listed is points are few; will try to put some more points as and when I come across them.

To report this post you need to login first.

17 Comments

You must be Logged on to comment or reply to a post.

  1. Nishant Bansal

    Hi  Gangadharayya Hiremath,

    Thanks for Sharing this kind of block. This block help us to go  through all the OOPS concept Regrading java and ABAP.

    As per my knowledge i want to share some points with you.

    1. There is no concept of Friend Function in JAVA and but SAP ABAP OOPS provide friend Class Concept.

    2. There is no static constructor in JAVA & in Java they provide the SIB (Static initialization Block) and SAP provide the Static Constructor.

    3. There is no concept of IIB (Instance Initialization Block) in ABAP OOPS.

    4. At one point i was also surprised to see the one class can ABSTRACT as well as Final. I didn’t understand that concept till now??? How its possible. But in SAP there is no impossible word.

    5. Cloning of Object is not possible in SAP ABAP(OOPS).

    Thanks & Regards,

    Nishant Bansal.

    (0) 
    1. Gangadharayya Virupakshayya Hiremat Post author

      Hi Nishant,

        Thanks for valuable and important points

      Regarding your point 4; ABSTRACT and FINAL for the class can never go together as FINAL class cannot be inherited and ABSTRACT class cannot be instantiated as it will have abstract methods.

      Please let me know the class which is both abstract and final; let us try to understand SAP point of view on this.

      (0) 
    2. Matthew Billingham

      Nishant Bansal wrote:

                             

      Hi  Gangadharayya Hiremath,

      Thanks for Sharing this kind of block. This block help us to go  through all the OOPS concept Regrading java and ABAP.

      As per my knowledge i want to share some points with you.

      1. There is no concept of Friend Function in JAVA and but SAP ABAP OOPS provide friend Class Concept.

      2. There is no static constructor in JAVA & in Java they provide the SIB (Static initialization Block) and SAP provide the Static Constructor.

      3. There is no concept of IIB (Instance Initialization Block) in ABAP OOPS.

      4. At one point i was also surprised to see the one class can ABSTRACT as well as Final. I didn’t understand that concept till now??? How its possible. But in SAP there is no impossible word.

      5. Cloning of Object is not possible in SAP ABAP(OOPS).

      Thanks & Regards,

      Nishant Bansal.

                         

      2. SIB and Class Constructors are equivalent concepts

      3. IIB and Constructors are equivalent concepts

      5. Cloning is entirely possible – you just write a clone method.

      (0) 
    1. Nishant Bansal

      HI Matthew Billingham,

      As per my knowledge, I shared some knowledge about Constructor.

       

      In ABAP OOPS there is a concept of Class Constructor which is called only when the class is loaded into memory.There is only one Class constructor for each class.

      But in Java there is no concept of Static constructor. If we want to execute the code when the class is loaded into memory then we can use the SIB static initialization Block.

      This block is call when the class is loaded into memory. We have number of SIB block which can be call in order in which order they can define.

      2. In ABAP we don’t have the concept of Parameter constructor means we can define only one constructor for each class. But in Java we can define multiple constructor(Different Parameter) for each class.

      Correct me please if i m wrong.

      Thanks & Regards.

      Nishant Bansal

      (0) 
      1. Matthew Billingham

        Static initialisation blocks are equivalent to static constructor.

        If you want multiple parameter configurations for a constructor in ABAP, you can use optional parameters – with default values if you like.

        An important difference between Java and ABAP-OO, is that if you are in the super constructor and you call a method (abstract, redefined in your original constructor), you get a dump. You can’t do it. If the method is defined in the super, then it is the super definition that runs, not the overridden. The only workaround is to use the factory pattern.

        (0) 
        1. Gangadharayya Virupakshayya Hiremat Post author

          Hi,

          Thanks to both of you for pouring in with valuable thoughts.

          Reason for writing the statement ‘Constructor concept is handled very differently in OO ABAP

          a. Keyword constructor is used in OO ABAP where as in JAVA it is class name used for the constructor

          b. Overloaded constructors are not allowed in OO ABAP as pointed out by Nishant

          c.  Static used differently in OO ABAP and Java

          (0) 
          1. Matthew Billingham

            a) I don’t see any conceptual difference. Just different names

            b) There are workarounds if you need it

            c) as a)

            When I wanted to learn OO programming, I learned Java. I then applied what I learned to ABAP-OO. I did not find any major differences in the programming paradigm. (Except the issue with over-ridden methods in constructors as I mentioned).

            d) Collections are not properly part of the the Java language – though they are part of the common libraries. There is no reason why ABAP could not have collections – and, indeed, we find it does. In ABAP collections – and all their derivatives – can be implemented using internal tables and object references.

            (0) 
            1. Gangadharayya Virupakshayya Hiremat Post author

              Hi Matthew,

              I completely agree with your point of view.  It is nice thought JAVA OO concepts application in OO ABAP.

              I am still not understanding about work around for point b.

              For point d; i did mention in the blog ‘Internal tables and work area can be used

              (0) 
              1. Matthew Billingham

                The point is you appear to be confusing concept with implementation. There is no reason whatsoever that linked lists, vectors etc. cannot be implemented in ABAP OO (and they have been). The fact that these objects are more readily available and more used within Java is not a conceptual difference.

                The conceptual difference between ABAP and Java is that ABAP has more “basic” types, including internal tables, as a result of its non-oo heritage.

                If you want a constructor with parameters a and b, and (for the same class) a constructor with a and c, and (for the same class)  a constructor with just a, all you need to do is create a constructor with a mandatory and b,c optional. If someone supplies a b and c, then return an error as “invalid parameter usage”.

                (0) 
    1. Matthew Billingham

      Annotations are metadata about the program, not to do with the logic or the operation of the program. In Java, these allow stronger type checking (specifying exactly the type the collection holds, for example), or things like JavaDoc.

      In ABAP, we have #EC and pragmas for giving information to the extended syntax checks. ABAP doc is available – see here: http://scn.sap.com/docs/DOC-40872

      So ABAP does have annotations. Maybe not the same as Java, and perhaps with not as much utility, but nonetheless, they exist.

      (0) 
      1. Nishant Bansal

        HI Matthew Billingham,

        Thanks for  Sharing your valuable information,

        1. As per your constructor example what i understand that Function overloading concept    ABAP-OOPS overcome by giving the parameter as an Optional. Thanks for clearing        my concept.

        Question :- Why SAP provide the feature that one time class can Abstract as well as                     final. Because Concept are opposite to each other.

        (0) 
        1. Matthew Billingham

          Asking why SAP have allowed a particular feature, assumes that all features have been well thought out and deliberately decided on. I don’t think that is necessarily the case. It’s rather like looking at the way SAP code has been written and assuming it always follows best practice

          An abstract final class can be useful as a static class – i.e. one with only static attributes and methods. By defining it in this way, you make entirely sure that the class can never be instantiated. Whether this is making a virtue out of a flaw, I’ve no idea.

          (0) 
            1. Richard Harper

              I would supposed you would have to implement it yourself.  However, I’m trying to think of a situation whereby you would need to ‘lock’ a method without being able to encode it in some other way fo example enqueuing your data.

              Thniking further multithreading is handled by fucntion modules so method locking shouldn’t come into it…. I think…..

              (0) 

Leave a Reply