Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Unstructured Programming.
Procedural Programming.
Object Oriented Programming.
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
report ysubdel.
DATA : sal type p decimals 2,
itax type p decimals 2,
net_sal type p decimals 2 .
sal = 12000.
IF sal lt 5000 .
itax = 0.
ELSE.
itax = sal * '0.01'.
ENDIF.
net_sal = sal - itax.
write:/5 sal , itax ,
net_sal.
sal = 3500.
IF sal lt 5000 .
itax = 0.
ELSE.
itax = sal * '0.01'.
ENDIF.
net_sal = sal - itax.
write:/5 sal , itax ,
net_sal.
2005Intelligroup,Inc.
07/09/15
proprietary
Characteristics
Consists of only one main program.
Data access done always globally
Disadvantages
Difficult to manage once the program
becomes large.
Same sequence of statements are
repeated at multiple places.
Confidential and
report ysubdel.
DATA : sal type p decimals 2 ,
itax type p decimals 2 ,
net_sal type p decimals 2.
sal = 12000.
PERFORM sub_calc_tax USING
sal itax net_sal.
sal = 3500.
PERFORM sub_calc_tax USING
sal itax
net_sal.
07/09/15
proprietary
Confidential and
proprietary
Confidential and
Rajas Maruthi,
Prasads Maruthi,
Ramanis Maruthi
Customer
Pepsi,bike,samsung,tv
SalesOrder
OR2643789, OR2643799
OR2643776, OR9999999
Cricket Team
IndianTeam, Australian
Team, SrilankanTeam
Your Desktop PC
IGA51097 etc.
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Attributes
Methods
CricketTea
m
Captain,
VC, WC,
FB1,FB2,FB3
SP1,SP2,SUB
DoSingle,DoDouble
DoBowl,DoCatch
DoRunout,HitSix,
Doplay,HitBowndary
ICICI S.A.
Account
Number,
Balance,
CreditLimit
CheckBooks
ATM_Transfer,
E_transfer, Withdraw,
Check_Credit_limit,
Issue_check_book,
Track_transactions
Production
PO#,SSD,SE Start_Production,End
D,ASD,AED,C _production,Start_opr
omp,CoOptn ,Send_to_WS Etc
,Oper,Workc
enter
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Basic Object-oriented
Principles
Abstraction
Encapsulation
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Abstraction
Abstraction is used to manage complexity
proprietary
Confidential and
Encapsulation
Wrapping of data and methods into a single unit
(called class) is known as encapsulation.
The data is not acceseble to the outside world
only those methods ,Which are wrapped in the
class can only access it by using following
visibility sections.
Public,
Protected and
Private,
are the basis for one of the important features of
object orientation - encapsulation.
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Classes
Class describes an object
components of the class describe the state
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Classes
Global Class
Local Class
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
A Class basically contains the following:-
Events:- A mechanism set within a class which can help a class to trigger
methods of other class.
proprietary
Confidential and
Classes
Defining Local Classes:
A complete class definition consists of a
proprietary
Confidential and
Classes
If you declare methods in the declaration part of
proprietary
Confidential and
REPORT
YSUBOOPS17
CLASS c1 DEFINITION.
PUBLIC SECTION.
data : w_num type i value 5.
methods : m1.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD M1.
WRITE:/5 'I am M1 in C1'.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA : oref1 TYPE REF TO c1 .
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
REPORT
YSUBOOPS17
CLASS c1 DEFINITION.
PUBLIC SECTION.
data : w_num type i value
5.
methods : m1.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD M1.
proprietary
Confidential and
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Constructors:
Special Methods:
CONSTRUCTOR:
Cannot call with CALL METHOD statement.
Called automatically when you create an object
CLASS_CONSTRUCTOR:
Called when you first access the components of a class
Events:
Objects or classes can use events to trigger event
proprietary
Confidential and
visibility areas:
CLASS <class> DEFINITION.
PUBLIC SECTION.
...
PROTECTED SECTION.
...
PRIVATE SECTION.
...
ENDCLASS.
They define the external interface of the class to its users
Encapsulation :
The public components of global classes may not be changed
once you have released the class.
As well as defining the visibility of an attribute, you can also
protect it from changes using the READ-ONLY addition.
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
CLASS C1
DEFINITION.
PUBLIC
SECTION.
DATA:
METHODS:
EVENTS:
PROTECTED
SECTION.
DATA:
METHODS:
EVENTS:
PRIVATE
SECTION.
DATA:
METHODS:
EVENTS:
ENDCLASS.
2005Intelligroup,Inc.
07/09/15
proprietary
Subclass
of the
class
Class
itself
REPORT YSUBOOPS17 .
CLASS c1 DEFINITION.
PUBLIC SECTION.
data : w_num type i value 5.
methods m1.
ENDCLASS.
method m2.
method m1.
endmethod.
endmethod.
endclass.
2005Intelligroup,Inc.
proprietary
DATA :
oref2 type ref to c2 .
endclass.
ENDCLASS.
07/09/15
START-OF-SELECTION.
oref1 TYPE REF TO c1 ,
methods : m2.
class c2 implementation.
CLASS c1 IMPLEMENTATION.
Externa
l user
Confidential and
Self-Reference
Internally, each method has an implicit
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Inheritance
Inheritance allows you to derive a new class from an
existing class.
CLASS <subclass> DEFINITION INHERITING FROM
<superclass>.
The new class <subclass> inherits all of the
components of the existing class <superclass>.
However, only the public and protected components of
the super class are visible in the subclass.
You can declare private components in a subclass that
have the same names as private components of the
super class. Each class works with its own private
components.
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Inheritance
You can add new components to the subclass.
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Inheritance
Redefining Methods: you can use the REDEFINITION
07/09/15
proprietary
Confidential and
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
CLASS c1 DEFINITION.
PUBLIC SECTION .
CLASS-DATA : num TYPE I VALUE 5 .
ENDCLASS.
CLASS c1 IMPLEMENTATION.
ENDCLASS.
CLASS c2 IMPLEMENTATION.
ENDCLASS.
START-OF-SELECTION.
c2=>num = 7.
write:/5 c1=>num .
Output :
7
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
class c1 definition.
. . . . . . .
endclass.
class c1 implementation.
. . . . . .
endclass.
class c2 definition inheriting from c1.
. . . . . .
endclass.
class c2 implementation.
. . . . . . .
endclass.
start-of-selection.
data : oref1 type ref to c1,
oref11 type ref to c1,
oref2 type ref to c2.
create object oref1 type c2 .
create object oref2.
oref11 = oref2.
write:/5 oref1->num ,
oref11->num .
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Inheritance
Inheritance Overview:
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Inheritance
Inheritance and Reference Variables
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Interfaces
Interfaces are independent structures that you can
INTERFACE <intf>.
...
ENDINTERFACE.
The definition contains the declaration for all components
(attributes, methods, events) of the interface.
They automatically belong to the public section of the class
in which the interface is implemented.
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
CLASS-EVENTS <evt>...
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
TRY.
< code to be checked for
exception>
START-OF-SELECTION.
TRY.
i = i / 0.
ENDTRY.
CATCH cx_sy_zerodivide.
write:/5 'Divide by zero caught'.
ENDTRY.
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
5 Reasons OO Programming is
better than
Procedural Programming
Data Encapsulation
Instantiation
Code Reuse
Interfaces
Events
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
prone
because :
Classes contains attributes and methods.
Objects are instances of Classes.
Objects are addressed via references.
Objects have clearly defined interfaces.
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
Procedural ABAP
Contains Obsolete
Prohibits obsolete
Statements.
Supports Overlapping and
and some specialized
objects.
Shows Implicit Behavior.
Appears difficult to learn.
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and
methods.
Use function modules only when technically
necessary.
Disentangle procedural ABAP from ABAP Objects.
Decouple screen programming from application
programming.
Never uncheck the Unicode checks active
checkbox.
2005Intelligroup,Inc.
07/09/15
proprietary
Confidential and