Saturday, June 23

Function groups and now Objects in the new ABAP Objects language

The center of ABAP Objects are Objects. Any object oriented language focuses on objects and hence maps objects with the real world entities. After release 3.1 of SAP WAS ABAP, BOR or the business object repository contains objects. Examples of objects are customers, invoice, order etc. These are contained in the BOR as examples. 


Function Groups and function modules were like objects in ABAP versions before ABAP objects was introduced. Function groups contain function modules. FMs can be treated as services or functions of the objects. Also the global data of function groups formed the attributes of the objects. For example: an FG which processes Sales orders has many FMs within it and global data declared. Global data can be accessed by the FMs within the FG. This ensures encapsulation. The data (global data) and the services (FMs) are combined within a FG.

ABAP programs hold a specific amount of memory art runtime. Similarly when a FM is called, it loads its corresponding FG and global data into memory. One ABAP program can call multiple FMs from several FGs and hence multiple internal ABAP sessions can run and memory occupied. 

As already said, When a FM is called, its FG with global data is loaded into memory. This instance of FG can be treated as Object when we look at this from the Object orientation perspective. So the instance of function group is an interface between the user and function module. Function groups global data can be accessed via function modules only. If Function groups and function modules can be used for object orientation of a program then why ABAP Objects was introduced? The answer is below.

In classical ABAP, a program can work with many instances of different function groups.
But it is not possible to work on many instances of a single function group at a time.
ABAP Objects allow the user to work with many instances of a class.
For example : You are supposed to develop a ABAP program which can process many sales orders at the same time. It is not possible to do so with function groups philosophy. You would instead need a class and several objects of that class. Each object at that time would represent a Sales Order.

So now with the new ABAP objects, you can load multiple instances of the same Class using CREATE OBJECT statement. ABAP accesses the interface of the instance using Object’s reference.

No comments:

Post a Comment

You are welcome to express your views here...