OO Concepts

Naimesh Patel | Last Updated on April 6, 2016

ABAP Objects: Overriding (Redefinition)

Lets check out how we can implement Overriding in ABAP Objects. This is also known as the Redefinition of the method. When do we need to use the Overriding: Overriding is useful, when we want to extend the functionality of the inherited method. For example: we have a generic class of CAR and it has…

ABAP Objects: Narrowing Cast

Important principal of the Inheritence is that an instance of the Subclass can be used in all the contexts where the Superclass can be used. This is possible because the Subclass contains all the attributes of the Superclass, because Subclass has been inhertied from the Super. When we assign the instance of the Subclass back…

ABAP Objects: Widening Cast

When we assign the instance of the Superclass to the Subclass, than it is called the Widening Cast, because we are moving to the “More Specific View” from the “Less specific view”. Everytime it is not possible to move the Superclass reference to the Subclass, because subclass will(or might) have always more functionality compare to…

Persistent Object Services – Basics

Some basics used in the Persistent Objects Today we will see some basics about the Persistent Object Services. Why do we need Persistent Object Service:To better understand the need of the persistent objects we need to first understand the concept of the transient data. The local data for the program like Attributes of the class,…

Persistent Object Service – Example

Shows how to use the Persistent object in the Application. Previously, we have seen . Today we will see how to use the Persistent Object services in the test application. You can find all these under . To use the persistent objects, we need to:Get the Agent Object by accessing the public attribute AGENT in…

CLASS_CONSTRUCTOR and CONSTRUCTOR: Who comes before whom?

Today we will see how the constructor and class-constructor triggers at runtime. What is Constructor? Lets see what is CONSTRUCTOR and CLASS_CONSTRUCTOR CONSTRUCTOR Whenever we instantiate the object using the statement CREATE OBJECT statement, CONSTRUCTOR would be called. System creates an object before it calls the CONSTRUCTOR method. CLASS_CONSTRUCTOR This type of constructor is the…

READ-ONLY attribute vs GETTER methods

READ-ONLY is something different for the people who have worked on the OOP in the past. Like JAVA doesn’t have the read only addition. So, there is a hot discussion going on in SAP ABAP Objects world, why READ-ONLY is there and what is the purpose of it. Let’s unleash the READ-ONLY (and its power…

ABAP Objects Concepts – Friends

In any Object Oriented programming language, the access to private or protected components – both methods and attributes – would be prohibited. If someone try to access them, compiler would generate syntax error. Sometimes, it would be advantageous to give the access to these protected and private attributes to other classes. This can be achieved…

Class-based Exceptions I – Basics

Class based exceptions are realized based on the instances of the exception class. Lets explore them.

Class-based Exceptions II – Design Time consideration

In the series of the Class-Based exception raising & handling exceptions, today we’ll see design time considerations. Checkout all post related to Exception Raising & handling: Main classes All Exception classes are inherited from the global exception class’s CX_ROOT these subclasses: CX_STATIC_CHECK – If the exception is defined as a subclass of CX_STATIC_CHECK, it has…

Class based Exceptions III – Runtime flow

Lets continue exploring more about Class based exceptions by checking out the runtime flow when an exception is being raised. Checkout all post related to Exception Raising & handling: Flow .. with code lines To understand it better we’ll use the demo example of Class-based Exceptions I – Basics. I have given the related code…

Class based Exceptions IV – CLEANUP

In the series of Class based Exceptions, lets check out the addition CLEANUP within the TRY..ENDTRY block. Checkout all post related to Exception Raising & handling: TRY .. ENDTRY block also should have a CLEANUP block. This code block should contain cleaning up activity before leaving the TRY .. ENDTRY block. This block would gets…

Become a JAVAPER – is overloading possible in ABAP?

We all know it is a lie, but I will try to prove there are huge similarities b/w both languages in this matter, which eventually can form opinion that overloading in ABAP is possible.   What Java says In Java overloading is very common and useful. Within one class you can have same named methods…

Override (Redefine) Static Method?

We all know that we can’t redefine Static Method. We’ll try to explore the reasoning and alternatives to achieve the similar behavior.

Abstract Class vs Interface – Which to use when?

Abstract Class and Interface – both has there own usages. Lets explore when to use which in ABAP while developing an application in SAP.

When to use Local Class and when not to!

In SAP ABAP, we can create Local Class as well as Global Classes in class builder. We can create them in the class builder as well. Lets see when it is OK to use Local Class and when we should refrain using it. What is Local Class Local classes are defined within an ABAP program….

Become a JAVAPER – “overriding” an attribute

Recently I have discovered very interesting feature in Java. Below I will try to compare this with what ABAP can do about it. Quick jump in Overriding a method in ABAP and Java is simple. In the former we use REDEFINITION keyword in a subclass, in the latter we rewrite method with the same signature…

ABAP Objects – Achieve Multiple Inheritance using Interfaces

ABAP Objects doesn’t support Multiple Inheritance – Inheriting from more than one Super class, but similar functionality can be achieved using the interfaces.

ABAP Protected Section – Is it really Protected?

Few days back, I came across this challenging question on SCN about Inheritance within ABAP Objects specifically to the Protected Section.

ABAP Static vs Instance method – Which to use when?

We all debate over when to use Static methods or Instance methods. Most of the times we go for simplest approach, but that may not be the correct one. Lets try to explore and see what should be possibly the best approach when deciding Static or Instance.