From SAP Technical
Understanding the concepts of Object Oriented Programming
What is Object Orientation? In the past, information systems used to be defined primarily by their functionality: Data and functions were kept separate and linked together by means of input and output relations. The object-oriented approach, however, focuseson objects that represent abstract or concrete things of the real world. These objects are first defined by their character and their properties, which are represented by their internal structure and their attributes (data). The behavior of these objects is described by methods (functionality). Comparison between Procedural and Object Oriented Programming Features Emphasis Procedure Orientedapproach Emphasis on tasks Object Oriented approach Emphasis on things that does those tasks.
Programs are divided into Programs are organized into smaller programs known classes and objects and the as functions functionalities are embedded into methods of a class. Most of the functions Data can be hidden and share global data cannot be accessed byexternal sources. Relatively more time New data and functions can consuming to modify for be easily added whenever extending existing necessary functionality.
Object Oriented Approach - key features
1. 2. 3. 4. 5. Better Programming Structure. Real world entity can be modeled very well. Stress on data security and access. Reduction in code redundancy. Data encapsulation and abstraction.What are Objects and Classes? Objects: 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 softwaresolution on a one-toone basis. Classes: Classes describe objects. From a technical point of view, objects are runtime instances of a class. In theory, you can create any number of objects based on a single class. Each instance (object) of a class has a unique identity and its own set of values for its attributes.
Local and Global Classes
As mentioned earlier a class is an abstract descriptionof 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 anABAP program (Transaction SE38) and can only be used in the program in which they are defined. Global Class Any program In the Class Repository Created using transaction SE24 Must begin with Y or Z Local Class Only the program where it is defined. Only in the program where it is defined. Created using SE38 Can begin with any character
Accessed By Stored In Created By Namespace
Local ClassesEvery class will have two sections. (1) Definition. (2) Implementation
Definition: This section is used to declare the components of the classes such as attributes, methods, events .They are enclosed in the ABAP statements CLASS ... ENDCLASS. CLASS DEFINITION. ... ENDCLASS. Implementation: This section of a class contains the implementation of all methods of the class. The implementation partof a local class is a processing block. CLASS IMPLEMENTATION. ... ENDCLASS.
Structure of a Class The following statements define the structure of a class: 1. A class contains components 2. Each component is assigned to a visibility section 3. Classes implement methods
1. Components of a Class are as follow:
Attributes:- Any data,constants,types declared within a class form the...