Introduction to Object Oriented Programming in ABAP

 

  • OOPS stands for Object Oriented Programming System.

  • Object-Oriented Programming (OOP) is a programming paradigm used in Advanced Business Application Programming (ABAP) that enables programmers to design software components known as objects. These objects may include the functions (or methods) that manipulate the data as well as the data itself. Large codebases can be managed and maintained more easily using the more modular and structured approach to software development that OOP in ABAP offers.

  • ABAP OOPS is based upon two things :-

    1. Class :-

    • A class is a blueprint for creating objects.
    • It defines the properties (data) and behaviors (methods) that objects of that class will have.
    • A Class consists of Methods, Attributes, Events, Interfaces.

    2. Objects :-

    • Object is an instance of a class.

Types of Classes :-

a) Global Class :-

  • A global class is a class that can be accessed from any ABAP program within the same system.

  • Global classes are defined in the global class pool and are available for use throughout the system.

  • We create Global Classes in SE24 ( Class Builder ) transaction code.



    Types of Global Classes :-

    1. Usual ABAP Class :-

    • A usual ABAP class is a fundamental programming construct in SAP systems, written in the ABAP language. It encapsulates data and functionality, following object-oriented programming principles. Typically, an ABAP class comprises attributes (data), methods (functions), constructor and destructor methods, events, interfaces, and visibility sections. These classes facilitate the creation of modular and reusable code for SAP applications, promoting efficient development and maintenance.

    • It’s purpose is to write the logic.



    2. Exception Class :-

    • An exception class in ABAP is a special type of class used for defining custom exceptions. These exceptions represent specific error conditions or situations that can occur during program execution.
    • Exception classes encapsulate error handling logic and can be raised (signaled) within ABAP programs to indicate abnormal conditions.


    3. Persistence Class :-

    • In the context of ABAP programming and SAP systems, a persistence class refers to a class that facilitates the interaction with persistent storage, such as a database.
    • These classes are responsible for handling data retrieval, storage, and manipulation operations, ensuring that data is effectively managed and maintained within the system.


    4. Unit Test Class :-

    • A unit test class in ABAP is used for testing the functionality of individual units of code, typically methods or functions, in isolation.
    • These tests verify that each unit of code behaves as expected under various conditions and inputs.



b) Local Class :-

  • In ABAP programming, a local class is a class that is defined within the scope of another ABAP program or function module.
  • Unlike global classes, which are defined independently and can be accessed from any part of the system, local classes are confined to the program or function module in which they are declared.
  • Dedicated to one program only. We can create local classes with the help of SE38 transaction code.

Class Definition : Declaration Part

Class Implementation : Logic

Comments

Popular posts from this blog

Understanding Different Types of SAP Function Modules: Normal, RFC, and Update

Unlocking SAP ABAP Secrets: Interactive Classical Reports with GET CURSOR, At User Command, and a Comparison of HIDE Statements

Mastering ABAP: A Step-by-Step Guide to Function Modules and Groups for Modularized Programming