Вы находитесь на странице: 1из 34

Thanks,

Object Oriented Programming with ABAP

Compare car parts with assembled car ; which is better to understand ?

Thanks,

Abstraction and Encapsulation

Thanks,

OOPs Concepts !

Classes Objects/ Instances Constructors Inheritance Polymorphism Interface Abstract Class Final Class Events

Class
Its a template or blue-print of a Object which contains

attributes, methods and events.

Syntax

Thanks,

Object
Instance of a class Its a variable of a type class Objects can be created and addressed using reference variables.
Syntax

If car is a Class ,then SUV, Hatch back, Sedan, Convertible are objects

Thanks,

Attributes
Attributes describe the data that can be stored in the objects in a class. Types
Instance attributes Class attributes

Visibility
Private Public

Thanks,

Attributes and visibility

Thanks,

Attributes and visibility

Thanks,

Attributes
Attributes describe the data that can be stored in the objects in a class. Types
Instance attributes Class attributes

Visibility
Private Public

Thanks,

Methods
Methods are internal procedures in classes that determine the behavior of an object Methods have a parameter interface Types
Instance method Class method

Visibility
Private Public

Thanks,

Methods -visibility

Calling Methods :Syntax

Thanks,

Methods Instance/class

Thanks,

Calling a Method

Calling Methods :Syntax

Thanks,

Calling a Method

Thanks,

Constructor

Thanks,

Static Constructor

Named as CLASS_CONSTRUCTOR Called automatically before the class is first accessed.


Before any of the following actions
CREATE OBJECT Addressing static attribute cl_sample=>name. Addressing static method CALL METHOD cl_sample=>set_name Before registering static event handler using SET HANDLER <class name>=><handler method> FOR obj

Thanks,

Inheritance
Inheritance is a relationship in which one class (the subclass) inherits all the main characteristics of another class (the superclass). The subclass can also add new components (attributes, methods, and so on) and replace inherited methods with its own implementations. The inheritance relationship is often described as an is-a relationship: a passenger plan is an airplane.

Thanks,

Inheritance Visibility

The constructor of the super class must be called within the constructor of the subclass. For static constructors, unlike instance constructors, the static constructor in the super class is called automatically.

Thanks,

Polymorphism

Ability to take multiple forms Same method name with different functionality Achieved using the keyword REDEFINITION Same method name is not allowed use in the sub classes.

Thanks,

Polymorphism Tips

The REDEFINITION statement for the inherited method must be in the same SECTION as the definition of the original method.

(It can therefore not be in the PRIVATE SECTION, since a classs private methods are not visible and therefore not redefinable in subclasses!)
If you redefine a method, you do not need to enter its interface again in the subclass, but only the name of the method. The reason for this is that ABAP Objects does not support overlaying (see notes to previous slide).

Thanks,

Interface

Basis for polymorphism Achieve Multiple Inheritance Independent structures that allow you to enhance the class The class which implements this interface will provide a implementation to this method

Thanks,

Abstract Class

Cannot be instantiated Used in incomplete blueprint The subclass needs to redefine the undefined methods Can have abstract or instance methods Classes with at least one abstract method are themselves abstract Static methods and constructors cannot be abstract (they cannot be redefined).

Thanks,

Final Class

A final class cannot have subclasses, and can protect itself in this way against (uncontrolled) specialization. A final method in a class cannot be redefined in a subclass, and can protect itself in this way against (uncontrolled) redefinition. Some characteristics: A final class implicitly only contains final methods. You cannot enter FINAL explicitly for these methods in this case. Methods cannot be both final and abstract. Classes, on the other hand, can usefully be both abstract and final: only static components can be used there.

Thanks,

Events

Event Registration

Triggering an event

Handling event

Thanks,

Global Class vs Local Class

Global

Global Class Class Builder

Class Edior Step by Step Demo

Class Edior Most important thing in programmers life

Copy /Convert Local Class to Global Class Copy Super class to Sub class Copy class methods/attributes among associated class Demo :

Show me The Code !!!!

Program Name
ZKENDRE_OOABAP_ATTRIBUTE

Concept
Class Attribute

Source Code

ZKENDRE_OOABAP_METHOD

Class Method

ZKENDRE_OOABAP_CONSTRUCTOR

Class Constructor and Constructor

ZKENDRE_OOABAP_INHERITANCE

Inheritance

ZKENDRE_OOABAP_POLYMORPHISM

Polymorphism

ZKENDRE_OOABAP_INTERFACE

Interface

Show me The Code !!!!

Program Name
ZKENDRE_OOABAP_FINAL
ZKENDRE_OOABAP_ABSTRACT ZKENDRE_OOABAP_EVENT

Concept
Final Class
Abstract Class Event Concept

Source Code

Editable ALV using OO ABAP ZKENDRE_OOABAP_EVENT_EDITALV events ZKENDRE_OOABAP_GLOBAL_CLASS Global class ZKENDRE_OOABAP_LOCAL_T_GLOB Convert local class to Global

Lets have some hands on on system

There is lot to dig!!!!

Binding : http://www.saptechnical.com/Tutorials/OOPS/Binding/Procedure.htm Casting : Garbage collector Friend classetc !!!

Thanks,

Вам также может понравиться