Oops in ABAP: by Pavani
Oops in ABAP: by Pavani
Oops in ABAP: by Pavani
By
Pavani
Different approaches in Programming
Unstructured Programming.
Procedural Programming.
Object Oriented Programming.
Unstructured Programming
report zdemo_01.
DATA : sal type p decimals 2,
itax type p decimals 2, Characteristics
net_sal type p decimals 2 .
sal = 3500.
Difficult to manage once the program becomes
IF sal lt 5000 . large.
itax = 0.
Same sequence of statements are repeated at
ELSE.
itax = sal * '0.01'. multiple places, if they are needed at multiple
ENDIF. locations.
net_sal = sal - itax.
write:/5 sal , itax , net_sal.
Procedural Programming
report z_demo_01.
DATA : sal type p decimals 2 ,
itax type p decimals 2 ,
net_sal type p decimals 2.
sal = 12000. Programmer combines related sequences of
PERFORM sub_calc_tax USING statements into one single place, called
sal itax net_sal. procedure.
sal = 3500.
PERFORM sub_calc_tax USING A procedure call is used to invoke the
sal itax net_sal. procedure.
After the sequence is processed, flow of
FORM sub_calc_tax USING P_SAL
P_ITAX P_NET_SAL. control proceeds right after the position where
IF p_sal lt 5000 . the call was made.
p_itax = 0.
ELSE.
p_itax = sal * '0.01'.
ENDIF.
p_net_sal = p_sal - p_itax.
ENDFORM.
Object oriented programming
Exception handling
Object
PUBLIC
Private Section:
Class C1 definition
Instances of Class C1
Types of Classes
1. Global Classes
2. Local Classes
Global Classes
1. Single inheritance
2. Multiple inheritance
3. Multilevel inheritance
4. Hierarchal inheritance
5. Hybrid inheritance
POLYMORPHISM
Operator overloading :
The mechanism of providing the operators with
a special meaning for a data type is called operator loading.
Virtual functions :
Runtime polymorphism is achieved by using
virtual functions.
Virtual functions allows programmers to declare functions in a
base class, which can be defined in each derived class.
Class A
{
Public:
......................................
......................................
}
}
Encapsulation / Data hiding :
This feature provides the facility to bind both the
data members and member functions of a single
programming construct.
Ex: Encapsulation is an example of ‘class’.
Interfaces