Abap Oo Basics
-
Upload
srihariram20 -
Category
Documents
-
view
246 -
download
3
Transcript of Abap Oo Basics
-
8/11/2019 Abap Oo Basics
1/20
BBS 2:
ABAP OO Basics
-
8/11/2019 Abap Oo Basics
2/20
ABAP OO Basics
An object is a self-contained entity having a state, a behavior, and an identity.
-
8/11/2019 Abap Oo Basics
3/20
ABAP OO Basics
THE MINDSET
-
8/11/2019 Abap Oo Basics
4/20
Classical ABAP: Declaration
Internal Table Declaration:
TYPES: BEGIN OF ty_out,num TYPE i,
END OF ty_out.
TYPES: ty_tt_out TYPE STANDARD TABLE OF ty_out,ty_ts_out TYPE SORTED TABLE OF ty_out,ty_th_out TYPE HASHED TABLE OF ty_out.
DATA: i_out TYPE ty_tt_out,is_out TYPE ty_ts_out,ih_out TYPE ty_th_out.
-
8/11/2019 Abap Oo Basics
5/20
Classical ABAP: Modularization
For maintainability and reusability There should be NO direct access to global
variables, internal tables, and work areas
directly Subroutine interface parameters:
USING
CHANGING
-
8/11/2019 Abap Oo Basics
6/20
-
8/11/2019 Abap Oo Basics
7/20
Classical ABAP: Function Modules Are processed blocks with a defined
interface
transparent, separate, independent Have source codes that come between
the ABAP stmts: FUNCTION ENDFUNCTION.
Belong to FUNCTION GROUPS Are called using the ABAP statement:
CALL FUNCTION .
-
8/11/2019 Abap Oo Basics
8/20
Classical ABAP: Examples
Function Module Geeky Example #1
TABLES are not used
-
8/11/2019 Abap Oo Basics
9/20
Object Templates: Classes
InstancesInstances
Class Flight Class Hotel
-
8/11/2019 Abap Oo Basics
10/20
ABAP OO: Classes
Class Components: ATTRIBUTES
define the internal state of an object store an objects properties which can be public,
private, or protected
METHODS
the objects means of performing operations have an interface similar to function modules
-
8/11/2019 Abap Oo Basics
11/20
ABAP OO: Classes{DATA | CLASS-DATA} attr TYPE type
[ VALUE val ][ READ-ONLY ][ VIRTUAL [ SET-METHOD set-method ][ GET-METHOD get-method ] ]``.
CONSTANTS const TYPE type VALUE val.
{METHODS | CLASS-METHODS} method
[ IMPORTING ] [ EXPORTING ] [ CHANGING ] [ EXCEPTIONS ] [ RETURNING result TYPE t ].
-
8/11/2019 Abap Oo Basics
12/20
ABAP OO: ClassesCLASS DEFINITION.
* INHERITING FROM -- available in a later 4.0 version
PUBLIC SECTION. definition of components visible outside the class
PROTECTED SECTION.
definition of components only visible to subclasses ofthis class.
PRIVATE SECTION. definition of components only visible within the class
ENDCLASS.
CLASS IMPLEMENTATION. method implementations
ENDCLASS.
-
8/11/2019 Abap Oo Basics
13/20
ABAP OO: Example
LOCAL Class version of Geeky Example #1
GLOBAL Class version of Geeky Example #1
-
8/11/2019 Abap Oo Basics
14/20
ABAP OO: Example
Modularized Geeky Example #2
Retrieve material numbers from table MSEG andthen display these material numbers and theircorresponding descriptions. Includevalidations on the material and plant.
-
8/11/2019 Abap Oo Basics
15/20
-
8/11/2019 Abap Oo Basics
16/20
ABAP OO: Definitions Constructor
Instance constructors - executed every time an object(instance) is created with the CREATE OBJECT statement
Class constructors - executed exactly once before youfirst access a class
Interfaces are implemented in addition to, and independently of
classes will only have a declaration part are listed in the definition part of the class, and must
always be in the PUBLIC SECTION
-
8/11/2019 Abap Oo Basics
17/20
ABAP OO: Definitions Events
Model state changes for an object Are triggered with the RAISE EVENT statement which
would call all event handlers that have been registeredfor this event using the SET HANDLER statement
Event Handlers Methods to handle events raised by other objects
-
8/11/2019 Abap Oo Basics
18/20
ABAP OO: Definitions Inheritance
an existing class is used to derive a new class (childclass).
the new class contains the attributes of the parent classplus the new attributes and methods added to it.
the child class derives all the attributes and methodsdeclared in parent class as PUBLIC.
the child class cannot inherit private members.
the protected members in parent class are derived inchild class but their visibility changes to private.
-
8/11/2019 Abap Oo Basics
19/20
-
8/11/2019 Abap Oo Basics
20/20
Brown Bag Sessions Schedule29Jun: Basic Optimization Techniques
12Jul : ABAP OO Basics
19Jul : Webdynpro for ABAP Basics26Jul : Possible Topics:
Basic Optimization Techniques II
SAP Adobe Interactive Forms