Table of Contents
SAP OOABAP provides different types of classes to handle different types of scenarios. Some of the classes are the part of SAP Design patterns to perform a specific type of workflow, whereas others are there to perform core functions. In this article we will compare two of them. Let us discuss the difference between Singleton Class and Persistent Class in SAP ABAP.
Sometimes there is a need to instantiate an object at a time, that means only one instance is required at one point of time. This is a very common requirement while designing an application. To achieve such a scenario, there is one concept of ‘Singleton Pattern’ or ‘Singleton Class’ in OOABAP.
A class is said to be a singleton class if it can have the utmost one instance only.
Before going for persistent class, let’s first discuss the meaning of ‘persistent’. A data is said to be persistent if it can be preserved beyond the runtime of program.
For a session, ABAP program stays in local ABAP memory till the runtime of that program. To store it permanently, we use persistence service (implemented by persistence class).
Difference between Singleton Class and Persistent Class
|Singleton Class||Persistent Class|
|It can have only one instance.||It can have multiple instances.|
|It cannot store data beyond runtime.||Data can still persist beyond runtime.|
|It is used for functions like single sign-on and logger.||It is used for functions like booking system where particular transaction blocks a seat/item.|