0% found this document useful (0 votes)
2 views

05_ABAP Basics - Object Oriented Programming

The document provides an overview of Object Oriented Programming (OOP) concepts, including class definitions, visibility sections, and the components of a class. It explains how OOP allows for data segregation and functionality grouping, emphasizing the importance of class accessibility and method implementation. Additionally, it covers the principles of inheritance for reusability and the structure of classes in programming.

Uploaded by

Nancy Gaber
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

05_ABAP Basics - Object Oriented Programming

The document provides an overview of Object Oriented Programming (OOP) concepts, including class definitions, visibility sections, and the components of a class. It explains how OOP allows for data segregation and functionality grouping, emphasizing the importance of class accessibility and method implementation. Additionally, it covers the principles of inheritance for reusability and the structure of classes in programming.

Uploaded by

Nancy Gaber
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Object Oriented Programming

1
 Object Oriented
Programming
 Class
 Visibility Sections
 Components of a
Class
 Consuming Class
 Define Own Class
 Decide Accessibility
 Reuse existing Class
 Redefine
Functionality
 Consume Class
before
Implementing
2
ect Oriented Programming: Data Model
Object Oriented Programming allows to segregate the data in the application based on its usage and group the
functionality applying on segregated data

Representing data in Relational Model Representing data in Object Model

Order Custom Amount Cur Delivery Date

1
er
CUST1 100
r
US 01.01.2019 SalesOrder#1 Sales Orders#2
D Sales
2 CUST1 200 US 01.08.2019 Sales Header
D 10 CUST 100 US 01.01.2019
Header
10 CUST 100 US 01.01.2019
2
1 D
1
1 D Total Gross Blocked
Order Item Product Quantity Uo Delivery Date Total Gross Blocked
M 10000 USD X
1 10 PRD1 100 EA 01.01.2019 10000 USD
20
Delive
1 PRD2 200 EA 01.08.2019
Deliver X r
1 30 PRD1 100 EA 01.01.2019 Sales Items
1 40 PRD2 200 EA 01.08.2019 Sales Items
10 PR51 100 EA 01.01.2019
2 10 PRD1 100 EA 01.01.2019 20 PRD9 200 EA 01.08.2019
10 PRD1 100 EA 01.01.2019
2 20 PRD2 200 EA 01.08.2019
20 PRD2 200 EA 01.08.2019

30 PRD3 100 EA 01.20.2019

40 PRD4 400 EA 01.31.2019

3
ct Oriented Programming: Functionalities
When Performing the action, it applies to only specific
SalesOrder#1
instance Create Sales
Program Flow Header
10 CUST 100 US 01.01.2019
1
1 D

…. Total Gross Blocked


…. 10000 USD
Change
…. Deliver X
Obj1->Block Sales Items
..
.. Get 10 PRD1 100 EA 01.01.2019

Obj2->Block 20 PRD2 200 EA 01.08.2019

01.20.2019
30 PRD3 100 EA
… 40 PRD4 400 EA 01.31.2019


… Deliver
Obj1->Release
…. Sales Orders#2
…. Sales
Block Header
Obj1->Deliver 10
2
CUST
1
100 US
D
01.01.2019

…. Total Gross Blocked


…. 10000 USD X

…. Delive
Release r
Obj2->Get Sales Items
…. 01.01.2019
10 PR51 100 EA
20 PRD9 200 EA 01.08.2019

Get Items

4
Define Class by Observing all the Data and Actions on the Data

Sales Order#1 Sales Order#2 Sales Order#3 Sales Order#n

Sales Order Data to Sales Order Order No: 121 Order No: 122 Order No: 123 Order No: NNN
Customer: CUST1 Customer: CUST2 Customer: CUST1 Customer: CUSTN
Sales Org: 1000 Sales Org: 1000 Sales Org: 5000 Sales Org: 1000
Currency: USD Currency: USD Currency: USD Currency: USD
Amount: 1000 Amount: 5000 Amount: 5000 Amount: NNNN
Blocked: No Blocked: Yes Blocked: No Blocked: No
Delivered: Yes Delivered: No Delivered: No Delivered: No
Billed: Yes Billed: No Billed: No Billed: Yes
Item|Prod|Qun|UoM Item|Prod|Qun|UoM Item|Prod|Qun|UoM Item|Prod|Qun|UoM
10 |PRD1 |10 |EA 10 |PRD3 |10 |EA 10 |PRD1 |100 |EA 10 |PRDN |90 |EA
20 |PRD2 |20 |EA 20 |PRD4 |20 |EA
Class

Sales Order Class

Data Activity Events

Order Create Order Order Created


No Change Order Order Changed
Custome Display Order Order Blocked
r Block Order Order Released
Sales Release Order Order Delivered
Org Delivery Order Order Billed
Currenc Bill Order
y Get Items
Amount Get Item
Blocked
Delivere
d
Billed
5
Data in SAP
Purchase Physical Material Subcontracti Warehouse
Sales Order Work Centre
Order Inventory Master ng Order

Purchase Purchase Vendor Service


Routing Storage Bins Cartanization
Order Requisition Master Master

Outbound Request for Bill of Storage Customer Transportatio


Data in SAP
Back Orders
Delivery Quotation Material Units Master n Unit
Customer
Purchasing Stock Purchase Business
Inquiry Material Replenishme
Contract Transfer Info Records Partner
nt
Inbound Accounting Customer Proof of Characteristi
Quotation Customer
Delivery Data Material Delivery cs

Goods Cost
Goods Issue Vendor G/L Accounts Invoice List Capacity
Receipt Elements

Inspection
Shipment Invoice JIT Call Equipment JIT Call Forecasting
Lot

Billing Quality Requisition


Debit Note Control Cycle Control Cycle Profile
Document Notification Note

Production Cost Shipping Posting Planned Ind


Credit Note Work Order
Lot Estimate Document Change Requirement

Scheduling Production Transfer Customer


Sales Order Reservation Wave
Agreement Order Requirement Requirement

Planned Transfer Stock Warehouse And Many


Contracts Sales Order
Order Order Transfers Task More……

6
Class

Class Relation between Classes


A Set of Functionalities on Logically Functionalities of each class are independent of other
related data Classes
Class

Data Product Class

Customer Vendor Class


Functionality Events Class

Sales Order Delivery Class Billing Class Purchase


Class Order Class

7
omponents in the Class
Types
Types can be declared inside the class and can be accessible
with in the class or outside of the Class
Components of Class
Types | Attributes | Methods | Events Attributes
Attribute can be elementary variable, Work area, internal or Ref
Class
to Other Class. Attributes generally defined in the Private
Components of a Class
Section to disable direct access from outside of the class
Attribute
Types Methods Events
s Methods
Methods are actual functionality. Methods work on attributes.
Generally methods can be defined in Public Section then called
from Class Consumers. Method defined in DEFINTION section of
the Class and Implemented in the IMPLEMENTATION Section.
During the definition all the Interface parameters can be
specified

Events
Events generally passing the current status of the class to the 8
ass and Its Consumers
Class
Data and Logic

Componen

Accessibili
Instances Static

Class

ty
Component

ts
Instance#1 Instance#1 Instance#1
s
Consum

Program Function Other Class


er

Module

9
isibility Sections
Note: Within the class there is no restriction. All components in the class can freely access other components
irrespective of Visibility Section
Visibility Sections
PUBLIC PUBLIC | PROTECTED | PRIVATE
 Public components can be accessed from outside of the class Class
 Methods generally declared in the Public Section.
Visibility
 If any data needs to accessed without need to call method then Sections

declare such data in Public Section PRIVATE

 All types generally declared in Public Section


Sub Class PROTECTE
D
Sub Class can see
PROTECTED PROTECTED and
PUBLIC PUBLIC Consumer
 Protected components can be accessed from the Subclass.
Components of Consume can see
Class only PUBLIC
Components
PRIVATE
 Private components can be accessed within the same class only
 If Consumer or Subclass can access the Private Attributes via Public
Methods
 Generally all the declared in the Private Section
10
bility Sections: Screen Shot TBD
Visibility Sections
PUBLIC | PROTECTED | PRIVATE

11
ccessing Components

Consumer: Program | Class


Function Module | Other
Class | Subroutine Public Private and
Components Protected
Components
Class Level
Class Level Class Level
Components of Class
Components Components
with Class Name

Instance Level Instance Instance


Components of Class Level Level
with Object Components Components
Reference

Syntax:
Static Components:
Attributes: CLASS_NAME=>ATTRIBUTE_NAME
Methods: CLASS=>METHOD( <Interface Parameters> )

Instance Components:
Attributes: Object_ref->Attribute_Name
Methods: Object_Reference->Method( < Interface Paramters> )

Note: For accessing Instance Components, Prerequisite is Object Reference declared and Class is instantiated

12
ic Attributes and Static Methods

Static Attributes and Static Methods


Accessing Public Static Attributes Accessing Private Static Attributes

Consumer: Class
Program | Function
Module | Other Class | Public Private and
Subroutine Components Protected
Components
Access Class Level
Static Static
Components( Attribu
Attributes Attributes
tes or Methods ) of
Class with Class
Name
Static Static
Methods Methods

Note: Public Static attributes can be accessed directly. Private Static attributes can be accessed via Public Static
methods of the Class. Private Static methods can’t be accessed from Outside. Private static attributed generally
used for modularization purpose

13
ing Static Attributes and Methods: Syntax and An Example

14
ance Attributes and Instance Methods
Actions
Instance#1
Create Sales
Program Flow Header
10
1
PRD1 100 EA 01.01.2019

…. Total Gross Blocked


…. 10000 USD
Change
…. Deliver X
Obj1->Block
Sales Items
..
.. Get 10 PRD1 100 EA 01.01.2019

Obj2->Block 20 PRD2 200 EA 01.08.2019


30 PRD3 100 EA 01.20.2019

40 PRD4 400 EA 01.31.2019



… Deliver
Obj1->Release Instance#2
…. Sales
…. Header 01.01.2019
Block 100 EA
10
PRD1
2

Obj1->Deliver Total Gross Blocked


…. 10000 USD X

…. Delive
…. r
Release Sales Items
Obj2->Get
…. 100 EA 01.01.2019
10 PR51
20 PRD9 200 EA 01.08.2019

30 PRD7 100 EA 01.20.2019

Get Items 40 PRD6 400 EA 01.31.2019

15
sing Instance Attributes and Methods: An Example
TBD

16
Define Class
Class can be defined in the Class builder SE24 as well as Locally. Global class can be accessed globally where are
local classes can be accessed within the program where class is defined.

Syntax: Define Class Syntax: Implement Class


CLASS <Class Name> DEFINITION INHERITING FROM <Super Class Name> CLASS <Class Name>
ABSTRACT FINAL IMPLEMENTATION.
CREATE [ PUBLIC | PROTECTED | “Method Implementations
PRIVATE ] ENDCLASS>
GLOBAL FRIENDS [class1 class2 ….]
[interface1 interface2…].
PUBLIC SECTION.
[Components]
PROTECTED SECTION.
[Components]
PRIVATE SECTION.
[Components]
ENDCLASS.

17
ate Class and Attributes: An Example
Static and Instance

18
sume Class and Attributes: An Example
Static and Instance

19
hod Definition and Implementation
Syntax: Static Method
CLASS <Class Name>… DEFINITION…..
 Method can be defined in the Definition section of the

Class. During the Method definition, all the interface CLASS-METHODS <Method Name> [ IMPORTING
parameters( Importing | Exporting | Changing ) with full <Parameters> |

type specification.
EXPORTING <Parameters> |
 If VALUE addition is specified for Parameter then it is Pass
By Value. Else it is Pass by Reference
CHANGING <Parameters> |
 Returning parameters always Pass By Value only
RETURNING <Parameters>]
Method can be implemented in the section of the Class. Syntax: Instance Method Definition

During the method Implementation no additions can be METHODS <Method Name> [ IMPORTING <Parameters> |

specified.
EXPORTING <Parameters> |
Syntax: Static Method | Instance Method
Note: CLASS <Class Name> IMPLEMENTATION.
 Static Methods can access only Static Attributes CHANGING <Parameters> |
METHOD <Method Name>.
 Instance Methods can access both Static and Instance “ Application Logic
RETURNING <Parameters>]
ENDMETHOD. …
Attributes ….
ENDCLASS
ENDCLASS.
20
te Public Method and Implement: An Example
Implement and Consume TBD

21
ate Private Method and Implement
Static and Instance:

Implement and Consume TBD

22
heritance: Reusability
 Inheritance allows to derive new classes from existing
classes. With the help of inheritance, we can add Super Class
extra functionality in the subclass. Private
Public Protected
 Addition INHERITING FROM of the Component Component Component
s s s
statement CLASS ... DEFINITION can be used.
 The new class adopts or inherits all components of
the existing class from PUBLIC and PROTECTED.
The new class is called a subclass and the existing
class is called a superclass.

Compone
nts From
Super
Class
Public Private
Component Component
s s

Sub Class
Compone

Declared
Public Protected Private

in the
nts
Component Component Component
s s s
Sub Class

23
heritance: Reusability

Super Class Consumer Super Class

Static Components: With help of Class name Public Protected Private


Consumer can access all the Public Components of the Component Component Component
Class s s s

Instance Components: With help of Object


reference Consumer can access all the Public

Compone
Components of the Class

nts From
Super
Class
Sub Class Consumer Public Private
Component Component
Static Components: With help of Class name s s
Consumer can access all the Public Components of the
Super Class as well as Sub Class

Sub Class
Compone

Declared
Public Protected Private

in the
nts
Instance Components: With help of Object Component Component Component
reference Consumer can access all the Public s s s
Components of the Super Class as well as Sub Class
Sub Class

24
omponents in the Class

Syntax:
CLASS <Class Name> DEFINITION INHERITING FROM <Super Class Name>
Components of Class
ABSTRACT FINAL
Types | Attributes | Methods | Events
CREATE [ PUBLIC | PROTECTED |
PRIVATE ] Class
GLOBAL FRIENDS [class1 class2 ….] Components of a Class
[interface1 interface2…].
Attribute
PUBLIC SECTION. Types Methods Events
s
[Components]
PROTECTED SECTION.
[Components]
PRIVATE SECTION.
[Components]
ENDCLASS.

25

You might also like