|Home • Trainings • Quiz • Tips • Tutorials • Functional • Cert Q's • Interview Q's • Jobs • Testimonials • Advertise • Contact Us|
Understanding the concepts of Object Oriented Programming
By Jaya Vani B, YASH Technologies
is Object Orientation?
between Procedural and Object Oriented Programming
Object Oriented Approach - key features
What are Objects and Classes?
An object is a section of source code that contains data and provides services.
The data forms the attributes of the object. The services are known as methods
(also known as operations or functions). They form a capsule which combines the
character to the respective behavior. Objects should enable programmers to map a
real problem and its proposed software solution on a one-to-one basis.
Local and Global
As mentioned earlier a class is an abstract description of an object. Classes in ABAP Objects can be declared either globally or locally.
Global Class: Global classes and interfaces are defined in the Class Builder (Transaction SE24) in the ABAP Workbench. They are stored centrally in class pools in the class library in the R/3 Repository. All of the ABAP programs in an R/3 System can access the global classes
Local Class: Local classes are
define in an ABAP program (Transaction SE38) and can only be used in the program
in which they are defined.
class will have two sections.
Definition. (2) Implementation
This section is used to declare the components of the classes such as
attributes, methods, events .They are enclosed in the ABAP statements CLASS ...
This section of a class contains the implementation of all methods of the
class. The implementation part of a local class is a processing block.
of a Class
following statements define the structure of a class:
1. Components of a Class are as
· Attributes:- Any data,constants,types declared within a class form the attribute of the class.
· Methods:- Block of code, providing some functionality offered by the class. Can be compared to function modules. They can access all of the attributes of a class.
Methods are defined
in the definition part of a class and implement it in the implementation part
using the following processing block:
Methods are called using the CALL METHOD statement.
· Events:- A mechanism set within a class which can help a class to trigger methods of other class.
Interfaces are independent structures that you can implement in a class to
extend the scope of that class.
Instance and Static Components:
§ Instance components exist separately in each instance (object) of the class and are referred using instance component selector using ‘à’.
§ Static components only exist once per class and are valid for all instances of the class. They are declared with the CLASS- keywords
§ Static components can be used without even creating an instance of the class and are referred to using static component selector ‘ =>’ .
2. Visibility of Components
Each class component has a visibility. In ABAP Objects the whole class definition is separated into three visibility sections: PUBLIC, PROTECTED, and PRIVATE.
· Data declared in public section can be accessed by the class itself, by its subclasses as well as by other users outside the class.
· Data declared in the protected section can be accessed by the class itself, and also by its subclasses but not by external users outside the class.
· Data declared in the private section can be accessed by the class only, but not by its subclasses and by external users outside the class.
We shall see an example on Visibility of Components once we become familiar with attributes of ABAP Objects.
The yellow block of code is CLASS Definition
The Green block of code is CLASS Implementation
The Grey block of code is for object creation. This object creation includes two steps:
Step1 is Create a reference variable with reference to the class.
DATA : <object name> TYPE
REF TO <class name>.
Step 2 : Create an object from the reference variable:-
Syntax: CREATE OBJECT <object name> .
Output for the above code is
Please send us your feedback/suggestions at webmaster@SAPTechnical.COM
©2006-2007 SAPTechnical.COM. All rights reserved.
product names are trademarks of their respective companies. SAPTechnical.COM
is in no way affiliated with SAP AG.
Graphic Design by Round the Bend Wizards