Register Login

Object Oriented Programming in ABAP

Updated May 18, 2018

Structure of an ABAP Program

Procedural Programming 

  • Information systems used to be defined primarily by their functions: data and functions were stored separately and linked using input-output relationships.
  • Direct access to data

Object-oriented Programming

Structure of an ABAP Program

Structure of an ABAP Program

 

Objects

Object Real World

Object-oriented Programming Model

Object-oriented Programming Model

Advantages of Object-oriented Approach

  • Consistency throughout the software development process
  • Encapsulation
  • Polymorphism
  • Inheritance

ABAP Objects

ABAP objects is not a new language, but has been developed as an extension of ABAP. It integrates seamlessly into ABAP syntax and the ABAP programming model. All enhancements are strictly upward compatible.

Principles

  • Objects
  • Classes
  • Attributes
  • Methods
  • Instantiation, garbage collector
  • Working with objects
  • Further principles

Classes

  • In this context, abstractions are a simplified representations of complex relationships in the real world. An actually existing object is abstracted to the significant dimensions that are to be mapped. Insignificant details are left out in order to aid understanding of the overall system.
  • This example concerns airplanes. Software for airlines and software for an airport’s hangar management contain different abstractions (classes) for these objects.
  • Important components –attributes, methods

classes

 

Important Components in a Class

 

Important Components in a Class

Attributes

  • Public and Private Attributes
  • Static Attributes and Instance Attributes

Methods

Static Methods and Instance Methods

Creating Objects

creating classes

Reference Variables

Reference Variables

Creating Objects: Syntax

Creating Objects

Garbage Collector Concept

Garbage Collector Concept

  • Object Identity
  • Assigning References
  • Object References As Attributes
  • External Access to Public Attributes
  • Calling Methods
  • Functional Methods
  • Constructor
  • Constructor: Example
  • Static Constructor
  • Encapsulation
  • Delegation Principal
  • Namespace Within Class

Generalisation / Specialisation

  • Inheritance
  • Cast
  • Polymorphism
  • Further characteristics of inheritance
  • Interfaces
  • Compound interfaces

Relationships Between Superclasses and Subclasses

Inheritance and Visibility

Inheritance and Visibility

Inheritance and the (Instance) Constructor

Parameters and Create Object

You must also consider the model described for instance constructors when using CREATE OBJECT. In this model, the constructor of the immediate superclass must be called before the non-inherited instance attributes can be initialized.

Redefining Methods

In ABAP Objects, you can not only add new components, but also provide inherited methods with new implementations. This is known as redefinition. You can only redefine (public and protected) instance methods, other components (static methods, attributes and so on) cannot be redefined. Furthermore, implementation is restricted to (re-)implementation of an inherited method; you cannot change method parameters (signature change).

Compatibility and Narrowing Cast

One of the significant principles of inheritance is that an instance from a subclass can be used in every context in which an instance from the superclass appears. This is possible because the subclass has inherited all components from the superclass and therefore has the same interface as the superclass. The user can therefore address the subclass instance in the same way as the superclass instance.

Principals of Narrowing Cast

Static and Dynamic Types

Polymorphism and Inheritance

Polymorphism: Example

Get the following explanation in brief:

  • Abstract Classes and Methods
  • Final Classes and Methods
  • Using Inheritance
  • Interfaces
  • Defining and Implementing an Interface
  • Working With Interface Components
  • Polymorphism and Interfaces
  • Differences Between Polymorphism and Inheritance and Polymorphism and Interfaces
  • Compound Interfaces
  • Compound Interfaces: Example
  • Using Interfaces
  • Events
  • Events: Characteristics and Uses
  • Triggering and Handling Events
  • Defining and Triggering Events: Syntax
  • Handling and Registering Events
  • Handling and Registering Events: Syntax
  • Event Handling Characteristics
  • Defining and Triggering Events: Syntax
  • Events and Visibility
  • Local Classes /Interfaces
  • Global Classes /Interfaces
  • Class Builder
  • Class Builder: Structure

Read Here for More SAP ABAP Books


 Download attached file.

You must be Logged in to download this file

×