ABAP Objects – Pros and Cons

2

ABAP Objects establishes a different level of data encapsulation. In procedural programming, the state of an application is held by global variables. In object-oriented programming, however, the state is kept inside separate classes and/or dynamically created objects, and the distinction between public and private components further helps to separate what should be externally visible from internal implementations. Even without in-depth object-oriented modeling, you can easily benefit from these features in your application programs

With ABAP Objects, you get multiple insatiability for free. Together with ABAP Object’s automatic garbage collection, this means that you as a developer neither have to deal with associating data and functionality nor need to explicitly control the lifetime of your objects

ABAP Objects gives you the freedom to work with (standalone) interfaces. This relieves you of the burden of knowing exactly how certain functionality is implemented. It also enables you to exchange an implementation later on without the need for modifications in the code that uses the interface

ABAP Objects makes it easy to incorporate event-driven programming models. Through a “publish and subscribe” model, application components can be loosely coupled. This allows greater flexibility than with the procedural approach, where the coupling is much tighter and the flow of program control is more predetermined.ABAP Objects Pros

  • ABAP Objects is more explicit and therefore simpler than classical ABAP. Examples of pitfalls arising from implicit behavior in classical ABAP are the realization of important interfaces via global data or the dependence of submitted programs on events triggered by the runtime environment. In comparison, ABAP Objects is based on a few basic and orthogonal concepts and is – therefore – more reliable and less error-prone
  • ABAP Objects has cleaner syntax and semantics rules. Classical ABAP is an evolutionary-grown language, containing obsolete statements and overlapping concepts. In ABAP Objects, that is in classes and methods, many obsolete statements and additions are forbidden, many implicit syntax completions must be made explicit, and potentially incorrect handling of data is detected and obviated
  • ABAP Objects is the only way to use new ABAP technology, such as services for GUI Controls, BSPs, or Web Dynpro. Therefore, you will inevitably be confronted with ABAP Objects when using these technologies. In such cases, it is highly recommendable to switch to ABAP Objects completely. Try to avoid a mix of classical and object-oriented techniques within an application.

ABAP Objects Cons

  • In general, object-oriented programming always means overhead, on the one hand in the implementation and on the other in the declaration of objects.
  • Performance objects are normally always used to keep an object (eg. material). SAP is based on the bulk processing. Due to that, if you are processing 1000 materials, 1000 objects need to be generated or you need to enhance the object with some workaround which might not be state of the art. Fact: To keep data among more instances, it might become very tricky.
  • At the time there are too less skilled and experienced resources available, e.g. to maintain the code
  • To search for bugs in the code might be very challenging, inheritance makes an effective bug fixing almost impossible.
  • The much-lauded maintenance decrease, comes only to its positive result if the bugs have the same root cause. The reality shows that SAP is mostly effected by self-contained problems.
  • The explicit higher programming effort does not effect a better result.
  • Re usability is given by function modules as well.

So, what is your opinion of ABAP Objects. SAP has come a long way from ABAP Procedural Programming to Object Oriented ABAP Programming.

ABAP Procedural Programming Drawbacks

  • Program Maintenance is complicated
  • Difficulty in program management as program size  increases
  • No data Hiding
  • Very difficult to model real world entity
  • Lack of extensibility

The Approach of ABAP Procedural Programming

  • Emphasis on tasks
  • Large programs are divided into smaller programs known as functions
  • Most of the functions share global data
  • Data move openly around the system from function to function

The Approach of ABAP Object Oriented Programming

  • Emphasis on things that does those tasks
  • Programs are divided into objects
  • Data structures are designed such that they characterized the objects
  • Functions that operate on the data of an object are tied together in the data structure
  • Data can be hidden and cannot be accessed by external functions
  • New data and functions can be easily added whenever necessary

Should I use Instance Method or Static Method?

Instance methods are called using the following syntax:
CALL METHOD instance_name->instance_method_name

A static method which is also called as class method can be called using the class and does not require an Instance. Static methods are called using the following syntax:
CALL METHOD class_name=>instance_method_name

Class Methods are similar to instance methods but can only use static components.

2 thoughts on “ABAP Objects – Pros and Cons

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: