Sie sind auf Seite 1von 44
Why use ABAP Objects Horst Keller, Stefan Bresch ABAP Language, SAP AG
Why use ABAP
Objects
Horst Keller, Stefan Bresch
ABAP Language, SAP AG
Objects Horst Keller, Stefan Bresch ABAP Language, SAP AG Learning Objectives As a result of this

Learning Objectives

As a result of this workshop, you will be able to:

Explain the benefits of object oriented programming in general Explain the benefits of ABAP Objects compared to classical ABAP Understand why Unicode enabled ABAP Objects is the best language for business applications up to now

is the best language for business applications up to now  SAP AG 2003, TechED_B asel

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 2

   

Agenda

 
 
 SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch / 3

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 3

Background

Principal Features of ABAP Objects

Encapsulation Instantiation Reuse via Inheritance Interfacing Events

Benefits of ABAP Objects

Simplicity Explicitness Maintainability Purified ABAP Future Orientation

Conclusion

Events Benefits of ABAP Objects Simplicity Explicitness Maintainability Purified ABAP Future Orientation Conclusion
Next Topic Background Principal Features of ABAP Objects Encapsulation Instantiation Reuse via Inheritance
Next Topic
Background
Principal Features of ABAP Objects
Encapsulation
Instantiation
Reuse via Inheritance
Interfacing
Events
Benefits of ABAP Objects
Simplicity
Explicitness
Maintainability
Purified ABAP
Future Orientation
Conclusion
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 4
   

Background – History

 
 
 

ABAP Objects was introduced with SAP Basis, Release 4.5.

 

Classes

Interfaces

Events

 

ABAP Objects was completed with SAP Basis Release 4.6.

 

Inheritance Compound interfaces Dynamic Invoke

 

Some enhancements were added with SAP Web Application Server, Releases 6.10, 6.20,

 

Friends Object Services Shared Objects

 

Preceding TechEd Workshops (available from horst.keller@sap.com)

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 5

 SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch / 5
Background – ABAP and ABAP Objects at the WAS User Interface (SAP GUI, Web, )
Background – ABAP and ABAP Objects at the WAS
User Interface
(SAP GUI, Web,
)
ABAP
Web
Application
SELECT * FROM
Server
ABAP Objects
Persistent Data
(Database, Files,
)
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 6
Background – Object Orientation in ABAP Pure Object Oriented ABAP World ? ABAP Non-ABAP Technically
Background – Object Orientation in ABAP
Pure
Object
Oriented
ABAP
World ?
ABAP
Non-ABAP
Technically possible!
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 7
Background – Object Orientation in ABAP Objects with Application Logic ABAP  SAP AG 2003,
Background – Object Orientation in ABAP
Objects
with
Application
Logic
ABAP
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 8
Background – Object Orientation in ABAP ABAP Persistence and Transaction Services provided by Object Services,

Background – Object Orientation in ABAP

ABAP
ABAP

Persistence and

Transaction Services provided by Object Services, as of Release 6.10

Services provided by Object Services, as of Release 6.10  SAP AG 2003, TechED_B asel /

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 9

Background – Object Orientation in ABAP GUI Control Framework, Office Integration, Business Server Pages, etc.
Background – Object Orientation in ABAP
GUI Control
Framework,
Office
Integration,
Business
Server
Pages,
etc.
ABAP
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 10
Background – Object Orientation in ABAP For example JavaScript (as of Release 6.10) ABAP Non-ABAP
Background – Object Orientation in ABAP
For example JavaScript
(as of Release 6.10)
ABAP
Non-ABAP
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 11
Background – Object Orientation in ABAP System Application Classes Coding from is here! Libraries 
Background – Object Orientation in ABAP
System
Application
Classes
Coding
from
is here!
Libraries
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 12
Background – Object Orientation in ABAP Inside Objects? METHOD DATA TYPE LOOP AT itab REFERENCE
Background – Object Orientation in ABAP
Inside Objects?
METHOD
DATA
TYPE
LOOP AT itab
REFERENCE INTO
ENDMETHOD.
Purified ABAP
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 13
Background – Object Orientation in ABAP Reality CALL SCREEN CALL FUNCTION DESTINATION SELECT ABAP Non-ABAP
Background – Object Orientation in ABAP
Reality
CALL
SCREEN
CALL
FUNCTION
DESTINATION
SELECT
ABAP
Non-ABAP
ABAP + ABAP Objects
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 14
Next Topic Background Principal Features of ABAP Objects Encapsulation Instantiation Reuse via Inheritance
Next Topic
Background
Principal Features of ABAP Objects
Encapsulation
Instantiation
Reuse via Inheritance
Interfacing
Events
Benefits of ABAP Objects
Simplicity
Explicitness
Maintainability
Purified ABAP
Future Orientation
Conclusion
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 15
Encapsulation – ABAP/4 (1) Event Driven Modularization Encapsulation of global data Processes * Global Declarations
Encapsulation – ABAP/4 (1)
Event Driven Modularization
Encapsulation
of global data
Processes
* Global Declarations
DATA
No local data
PROCESS ON
MODULE
MODULE
ENDMODULE.
START-OF-SELECTION
No local data
Runtime
Environment
Dynpro
ABAP Program
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 16
Encapsulation – ABAP/4 (2) Encapsulation can be Procedural Programming Model circumvented! * Global Declarations
Encapsulation – ABAP/4 (2)
Encapsulation
can be
Procedural Programming Model
circumvented!
* Global Declarations
DATA
* Global Declarations
DATA
Encapsulation
of global data
MODULE
FUNCTION
DATA
CALL FUNCTION
Local
data
PERFORM
PERFORM
ENDMODULE.
ENDFUNCTION.
FORM
FORM
DATA
DATA
Local
data
Local data
SELECT * FROM
ENDFORM.
ENDFORM.
ABAP Program
Function Group
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 17
Encapsulation – Example ABAP/4 (1) FUNCTION-POOL account. Encapsulation of an account DATA current_amount TYPE
Encapsulation – Example ABAP/4 (1)
FUNCTION-POOL account.
Encapsulation
of an account
DATA current_amount TYPE accounts-amount.
FUNCTION deposit.
current_amount = current_amount + amount.
ENDFUNCTION.
Function
modules
work with
one account
FUNCTION withdraw.
IF current_amount > amount.
current_amount = current_amount - amount.
ELSE.
RAISE EXCEPTION TYPE cx_negative_amount.
ENDIF.
ENDFUNCTION.
No possibility
to interact
with other
accounts
Function Group
SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 18
Encapsulation – Example ABAP/4 (2) FUNCTION-POOL account. DATA account_tab TYPE SORTED TABLE OF accounts WITH
Encapsulation – Example ABAP/4 (2)
FUNCTION-POOL account.
DATA account_tab TYPE SORTED TABLE OF accounts
WITH UNIQUE KEY id.
LOAD-OF-PROGRAM.
SELECT * FROM accounts
INTO TABLE account_tab.
All data in
one table
FUNCTION deposit.
DATA account_wa TYPE accounts.
READ TABLE account_tab INTO account_wa
WITH TABLE KEY id = id.
account_wa-amount = account_wa-amount + amount.
MODIFY TABLE account_tab FROM account_wa.
ENDFUNCTION.
Function
modules
work on
shared data
Function Group
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 19
Encapsulation – Example ABAP/4 (3) FUNCTION withdraw. DATA account_wa TYPE accounts. READ TABLE account_tab INTO
Encapsulation – Example ABAP/4 (3)
FUNCTION withdraw.
DATA account_wa TYPE accounts.
READ TABLE account_tab INTO account_wa
WITH TABLE KEY id = id.
IF account_wa-amount > amount.
account_wa-amount = account_wa-amount - amount.
MODIFY TABLE account_tab FROM account_wa.
ELSE.
RAISE EXCEPTION TYPE cx_negative_amount.
ENDIF.
ENDFUNCTION.
FUNCTION transfer.
CALL FUNCTION 'WITHDRAW'
EXPORTING
Data
Data
identified by
identified by
id
= id_from
input
input
amount = amount.
parameters
parameters
CALL FUNCTION 'DEPOSIT'
EXPORTING
id
= id_to
amount = amount.
ENDFUNCTION.
Function Group
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 20
Encapsulation – ABAP Objects Classes CLASS DEFINITION. CLASS DEFINITION. PUBLIC SECTION. PUBLIC SECTION. METHODS
Encapsulation – ABAP Objects
Classes
CLASS
DEFINITION.
CLASS
DEFINITION.
PUBLIC SECTION.
PUBLIC SECTION.
METHODS
METHODS
PRIVATE SECTION.
PRIVATE SECTION.
DATA
DATA
Encapsulation
Encapsulation
of Attributes
of Attributes
ENDMETHOD.
ENDMETHOD.
ENDCLASS.
ENDCLASS.
CLASS
IMPLEMENTATION.
CLASS
IMPLEMENTATION.
METHOD
METHOD
Local data
Local data
DATA
DATA
CALL METHOD
SELECT * FROM
ENDMETHOD.
ENDMETHOD.
ENDCLASS.
ENDCLASS.
ABAP Program
Class Pool
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 21
Encapsulation – Example ABAP Objects (1) A class unites functionality with data CLASS account DEFINITION.
Encapsulation – Example ABAP Objects (1)
A
class
unites
functionality
with data
CLASS account DEFINITION.
PUBLIC SECTION.
METHODS: constructor IMPORTING id TYPE accounts-id,
deposit IMPORTING amount TYPE accounts-amount,
withdraw IMPORTING amount TYPE accounts-amount
RAISING cx_negative_amount,
transfer IMPORTING amount TYPE accounts-amount
target TYPE REF TO account
RAISING cx_negative_amount.
PRIVATE SECTION.
DATA amount TYPE accounts-amount.
ENDCLASS.
Only
data
relevant
for one
object is
needed
Class Pool
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 22
Encapsulation – Example ABAP Objects (2) CLASS account IMPLEMENTATION. METHOD constructor. SELECT SINGLE amount FROM
Encapsulation – Example ABAP Objects (2)
CLASS account IMPLEMENTATION.
METHOD constructor.
SELECT SINGLE amount
FROM accounts
INTO (amount)
WHERE id = id.
ENDMETHOD.
METHOD deposit.
me->amount = me->amount + amount.
ENDMETHOD.
METHOD withdraw.
IF me->amount > amount.
me->amount = me->amount - amount.
ELSE.
RAISE EXCEPTION TYPE cx_negative_amount.
ENDIF.
ENDMETHOD.
METHOD transfer.
me->withdraw( amount ).
target->deposit( amount ).
ENDMETHOD.
ENDCLASS.
Each object is
initialized
individually
An
object
works on its
own
data,
no
business key
needed
An object can
address other
objects
Class Pool
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 23
Next Topic Background Principal Features of ABAP Objects Encapsulation Instantiation Reuse via Inheritance
Next Topic
Background
Principal Features of ABAP Objects
Encapsulation
Instantiation
Reuse via Inheritance
Interfacing
Events
Benefits of ABAP Objects
Simplicity
Explicitness
Maintainability
Purified ABAP
Future Orientation
Conclusion
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 24
Instantiation – ABAP/4 External Procedure Calls Only one instance of each Instances of program programs
Instantiation – ABAP/4
External Procedure Calls
Only one
instance of
each
Instances of
program
programs
with global
Function group 2
data
Function group 1
CALL FUNCTION
ABAP program
No explicite
instantiation,
no control of
lifetime
Internal session of an ABAP program
External session
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 25
Instantiation – Example ABAP/4 First call DATA: id1(8) TYPE n, id2(8) TYPE n, instantiates amnt
Instantiation – Example ABAP/4
First
call
DATA: id1(8) TYPE n,
id2(8) TYPE n,
instantiates
amnt
TYPE p DECIMALS 2,
function
exc_ref TYPE REF TO cx_negative_amount,
text TYPE string.
group
TRY.
id1 =
id2 =
amnt =
CALL FUNCTION 'TRANSFER'
EXPORTING
id_from = id1
Business
keys identify
data
id_to
= id2
No static
amount = amnt.
CATCH cx_negative_amount INTO exc_ref.
text = exc_ref->get_text( ).
MESSAGE text TYPE 'I'.
type check
ENDTRY.
ABAP Program
SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 26
Instantiation – ABAP Objects Creation of Objects Many instances of one class Instances of classes
Instantiation – ABAP Objects
Creation of Objects
Many
instances of
one class
Instances of
classes with
attributes and
Explicit
an identity
instantiation,
control of
lifetime
CREATE OBJECT oref TYPE class.
oref2
oref1
ABAP program
Internal session of an ABAP program
External session
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 27
Instantiation – Example ABAP Objects Object reference DATA: account1 TYPE REF TO account, account2 TYPE
Instantiation – Example ABAP Objects
Object
reference
DATA: account1 TYPE REF TO account,
account2 TYPE REF TO account,
variables
as
amnt
TYPE p DECIMALS 2,
explicit handles
exc_ref TYPE REF TO cx_negative_amount,
text
TYPE string.
CREATE OBJECT: account1 EXPORTING id =
account2 EXPORTING id =
,
TRY.
amnt =
account1->transfer( EXPORTING amount = amnt
target = account2 ).
CATCH cx_negative_amount INTO exc_ref.
text = exc_ref->get_text( ).
MESSAGE text TYPE 'I'.
ENDTRY.
Independent
objects based
on the same
class
Static type
check
Natural
working with
instances
ABAP Program
SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 28
Next Topic Background Principal Features of ABAP Objects Encapsulation Instantiation Reuse via Inheritance
Next Topic
Background
Principal Features of ABAP Objects
Encapsulation
Instantiation
Reuse via Inheritance
Interfacing
Events
Benefits of ABAP Objects
Simplicity
Explicitness
Maintainability
Purified ABAP
Future Orientation
Conclusion
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 29
TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 29 Reuse – ABAP/4 Reuse of generalized procedures

Reuse – ABAP/4

Reuse of generalized procedures No support for specialization Typical results:

Large function groups Extensive parameter interfaces Subdividing tasks via CASE

parameter interfaces Subdividing tasks via CASE  SAP AG 2003, TechED_B asel / ABAP 256, Horst

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 30

Reuse – Example ABAP/4 (1) FUNCTION withdraw. *"--------------------------------------------------------------
Reuse – Example ABAP/4 (1)
FUNCTION withdraw.
*"--------------------------------------------------------------
*"
*" IMPORTING
REFERENCE(ID) TYPE ACCOUNTS-ID
Steering
REFERENCE(KIND) TYPE C DEFAULT 'C‚
REFERENCE(AMOUNT) TYPE ACCOUNTS-AMOUNT
*" RAISING
*"
*"
parameters
*"
CX_NEGATIVE_AMOUNT
Additional
*"
CX_UNKNOWN_ACCOUNT_TYPE
exception
*"--------------------------------------------------------------
CASE kind.
WHEN 'C'. „Checking account
PERFORM withdraw_from_checking_account USING id amount.
WHEN 'S'. "Savings account
PERFORM withdraw_from_saving_account USING id amount.
WHEN OTHERS.
RAISE EXCEPTION TYPE cx_unknown_account_type.
ENDCASE.
ENDFUNCTION.
Procedure
calls with
parameter
passing
Function Group
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 31
Reuse – Example ABAP/4 (2) FORM withdraw_from_checking_account USING l_id TYPE accounts-id l_amount TYPE
Reuse – Example ABAP/4 (2)
FORM withdraw_from_checking_account
USING l_id TYPE accounts-id
l_amount TYPE accounts-amount.
DATA account_wa TYPE accounts.
READ TABLE account_tab INTO account_wa WITH TABLE KEY id = l_id.
account_wa-amount = account_wa-amount - l_amount.
MODIFY TABLE account_tab FROM account_wa.
IF account_wa-amount < 0.
" handle debit balance
ENDIF.
ENDFORM.
Specialized
Specialized
FORM withdraw_from_savings_account
USING l_id TYPE accounts-id
procedures,
procedures,
no code
no code
l_amount TYPE accounts-amount
RAISING cx_negative_amount.
DATA account_wa TYPE accounts.
READ TABLE account_tab INTO account_wa WITH TABLE KEY id = l_id.
IF account_wa-amount > l_amount.
account_wa-amount = account_wa-amount - l_amount.
MODIFY TABLE account_tab FROM account_wa.
ELSE.
RAISE EXCEPTION TYPE cx_negative_amount.
ENDIF.
ENDFORM.
reuse
reuse
Function Group
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 32
Reuse – ABAP Objects Reuse of general classes Specialization via inheritance Benefits Small classes Minimal

Reuse – ABAP Objects

Reuse of general classes Specialization via inheritance Benefits

Small classes Minimal parameter interfaces Polymorphism (CASE-less programming) enhanced Modeling capabilities

CASE -less programming) enhanced Modeling capabilities  SAP AG 2003, TechED_B asel / ABAP 256, Horst

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 33

Reuse – Example ABAP Objects (1) General superclass CLASS account DEFINITION. PUBLIC SECTION. PROTECTED SECTION.
Reuse – Example ABAP Objects (1)
General superclass
CLASS account DEFINITION.
PUBLIC SECTION.
PROTECTED SECTION.
DATA amount TYPE accounts-amount.
ENDCLASS.
Data sharing
with subclasses
CLASS account IMPLEMENTATION.
METHOD withdraw.
me->amount = me->amount - amount.
ENDMETHOD.
General method
implementation
ENDCLASS.
Class Pool
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 34
Reuse – Example ABAP Objects (2) Special subclass CLASS checking_account DEFINITION INHERITING FROM account. PUBLIC
Reuse – Example ABAP Objects (2)
Special subclass
CLASS checking_account DEFINITION
INHERITING FROM account.
PUBLIC SECTION.
METHODS withdraw REDEFINITION.
ENDCLASS.
Method
redefinition
CLASS checking_account IMPLEMENTATION.
METHOD withdraw.
super->withdraw( amount ).
IF me->amount < 0.
" handle debit balance
Call of general
implementation
ENDIF.
ENDMETHOD.
Special method
ENDCLASS.
implementation
Class Pool
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 35
Reuse – Example ABAP Objects (3) Special subclass CLASS savings_account DEFINITION INHERITING FROM account. PUBLIC
Reuse – Example ABAP Objects (3)
Special subclass
CLASS savings_account DEFINITION
INHERITING FROM account.
PUBLIC SECTION.
METHODS withdraw REDEFINITION.
ENDCLASS.
Method
redefinition
CLASS savings_account IMPLEMENTATION.
METHOD withdraw.
IF me->amount > amount.
super->withdraw( amount ).
ELSE.
RAISE EXCEPTION TYPE cx_negative_amount.
ENDIF.
ENDMETHOD.
ENDCLASS.
Special
method
implementation
Call of general
implementation
Class Pool
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 36
Reuse – Example ABAP Objects (4) Same object DATA: account1 TYPE REF TO account, account2
Reuse – Example ABAP Objects (4)
Same object
DATA: account1 TYPE REF TO account,
account2 TYPE REF TO account,
reference
variables
as
amnt
TYPE p DECIMALS 2,
exc_ref TYPE REF TO cx_negative_amount,
before
text
TYPE string.
CREATE OBJECT: account1 TYPE checking_account
General
,
account2 TYPE savings_account
EXPORTING id =
EXPORTING id =
handles for
specialized
TRY.
objects
amnt =
account1->transfer( EXPORTING amount = amnt
target = account2 ).
CATCH cx_negative_amount INTO exc_ref.
text = exc_ref->get_text( ).
MESSAGE text TYPE 'I'.
ENDTRY.
Same usage of
objects as
before!
Polymorphism
ABAP Program
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 37
Next Topic Background Principal Features of ABAP Objects Encapsulation Instantiation Reuse via Inheritance
Next Topic
Background
Principal Features of ABAP Objects
Encapsulation
Instantiation
Reuse via Inheritance
Interfacing
Events
Benefits of ABAP Objects
Simplicity
Explicitness
Maintainability
Purified ABAP
Future Orientation
Conclusion
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 38
Interfaces – ABAP/4 Limited support for interfaces: Global data as interfaces between programs Selection screens

Interfaces – ABAP/4

Limited support for interfaces:

Global data as interfaces between programs Selection screens as interfaces for executable programs Parameter interfaces for procedures No standalone interfaces

interfaces for procedures No standalone interfaces  SAP AG 2003, TechED_B asel / ABAP 256, Horst

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 39

TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch / 39 Interfaces – ABAP Objects (1)

Interfaces – ABAP Objects (1)

The interface of a class to the outside is defined by its public section

The interface of a class allows access to data and functionality

The interface of a class is inherited from its superclasses

Interfaces can be defined standalone

from its superclasses Interfaces can be defined standalone  SAP AG 2003, TechED_B asel / ABAP

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 40

Interfaces – ABAP Objects (2) Standalone Interfaces INTERFACE if1. INTERFACE if2. METHODS: m1 METHODS: m2
Interfaces – ABAP Objects (2)
Standalone Interfaces
INTERFACE if1.
INTERFACE if2.
METHODS: m1
METHODS: m2
ENDINTERFACE.
ENDINTERFACE.
CLASS cl
INTERFACES: if1,
if2.
ENDINTERFACE.
METHOD
if1~m1.
METHOD
if2~m2.
oref1
oref2
DATA:
oref1 TYPE REF TO if1,
oref2 TYPE REF TO if2.
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 41
TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 41 Interfaces – ABAP Objects (3) Benefits of

Interfaces – ABAP Objects (3)

Benefits of standalone interfaces:

Can be defined by client Independency from implementation Polymorphism Separation of independent characteristics

Polymorphism Separation of independent characteristics  SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller,

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 42

Interfaces – Example (1) CLASS account DEFINITION. PUBLIC SECTION. INTERFACES if_serializable_object. ENDCLASS.
Interfaces – Example (1)
CLASS account DEFINITION.
PUBLIC SECTION.
INTERFACES if_serializable_object.
ENDCLASS.
Class Pool
One interface in
One interface in
different
different
classes
classes
CLASS customer DEFINITION.
PUBLIC SECTION.
INTERFACES if_serializable_object.
ENDCLASS.
Class Pool
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 43
Interfaces – Example (2) Interface reference DATA: account TYPE REF TO account, customer TYPE REF
Interfaces – Example (2)
Interface
reference
DATA: account TYPE REF TO account,
customer TYPE REF TO customer,
serializable_objects TYPE TABLE
OF REF TO if_serializable_object,
serializable_object TYPE REF TO if_serializable_object,
xmlstr TYPE string.
variables
CREATE OBJECT: account EXPORTING id =
customer.
,
Instantiation of
classes
APPEND: account TO serializable_objects,
customer TO serializable_objects.
Collection of
references to
LOOP AT serializable_objects INTO serializable_object.
CALL TRANSFORMATION id
SOURCE obj = serializable_object
RESULT XML xmlstr.
ENDLOOP.
objects of
different classes
Polymorphism
ABAP Program
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 44
Next Topic Background Principal Features of ABAP Objects Encapsulation Instantiation Reuse via Inheritance
Next Topic
Background
Principal Features of ABAP Objects
Encapsulation
Instantiation
Reuse via Inheritance
Interfacing
Events
Benefits of ABAP Objects
Simplicity
Explicitness
Maintainability
Purified ABAP
Future Orientation
Conclusion
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 45
TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 45 Events – ABAP/4 Classical Runtime Events :

Events – ABAP/4

Classical Runtime Events:

PAI, PBO Selection Screen Events Reporting Events List Events

No program defined events No triggering of events in program

program defined events No triggering of events in program  SAP AG 2003, TechED_B asel /

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 46

Events – ABAP Objects (1) Events are components of classes METHOD METHODS handler FOR EVENT
Events – ABAP Objects (1)
Events are components of classes
METHOD
METHODS handler
FOR EVENT evt
RAISE EVENT evt
METHOD handler
ENDMETHOD.
ENDMETHOD.
oref2
oref1
METHOD
SET HANDLER
oref1->handler FOR oref2.
ENDMETHOD.
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 47
TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 47 Events – ABAP Objects (2) Benefits of

Events – ABAP Objects (2)

Benefits of events in ABAP Objects:

indirect method call decoupling of caller and handler two stages of publish and subscribe explicit exporting parameters

of publish and subscribe explicit exporting parameters  SAP AG 2003, TechED_B asel / ABAP 256,

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 48

Events – Example (1) CLASS checking_account DEFINITION INHERITING FROM account. PUBLIC SECTION. METHODS deposit
Events – Example (1)
CLASS checking_account DEFINITION
INHERITING FROM account.
PUBLIC SECTION.
METHODS deposit REDEFINITION.
Allows the class
to
publish an event
EVENTS consulting_required
EXPORTING value(amount) TYPE accounts-amount.
PRIVATE SECTION.
DATA limit TYPE accounts-amount VALUE '5000.00'.
ENDCLASS.
CLASS checking_account IMPLEMENTATION.
METHOD deposit.
super->deposit( amount ).
IF me->amount > limit.
RAISE EVENT consulting_required
EXPORTING amount = me->amount.
Announces
a
state change
that requires
an
action
ENDIF.
ENDMETHOD.
ENDCLASS.
Class Pool
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 49
Events – Example (2) CLASS consultant DEFINITION. PUBLIC SECTION. METHODS constructor. Static subscription, allows
Events – Example (2)
CLASS consultant DEFINITION.
PUBLIC SECTION.
METHODS constructor.
Static subscription,
allows the class to
PRIVATE SECTION.
handle an
event
METHODS receive_notification
FOR EVENT consulting_required OF checking_account.
ENDCLASS.
CLASS consultant IMPLEMENTATION.
METHOD constructor.
Dynamic
subscription
IF
SET HANDLER me->receive_notification FOR ALL INSTANCES.
ENDIF
ENDMETHOD.
METHOD receive_notification.
" do something
ENDMETHOD.
ENDCLASS.
Event handling
Class Pool
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 50
Next Topic Background Principal Features of ABAP Objects Encapsulation Instantiation Reuse via Inheritance
Next Topic
Background
Principal Features of ABAP Objects
Encapsulation
Instantiation
Reuse via Inheritance
Interfacing
Events
Benefits of ABAP Objects
Simplicity
Explicitness
Maintainability
Purified ABAP
Future Orientation
Conclusion
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 51
Simplicity – ABAP/4 (1) ABAP/4 coding might be simple, but REPORT simple_report. NODES spfli. GET
Simplicity – ABAP/4 (1)
ABAP/4 coding might be simple, but
REPORT simple_report.
NODES spfli.
GET spfli.
WRITE: / spfli-carrid, spfli-connid
ABAP Program
who knows really what’s happening here?
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 52
Simplicity – ABAP/4 (2) This is what happens after SUBMIT: Program is loaded, start values
Simplicity – ABAP/4 (2)
This is what happens after SUBMIT:
Program is loaded,
start values are set
LOAD-OF-PROGRAM
Selection screen values are set
INITIALIZATION
In parallel,
subroutines of a
logical database
are implicitly
called!
Call of selection screen
AT SELECTION-SCREEN
START-OF-SELECTION
GET spfli
END-OF-SELECTION
Still simplified
scheme!
The exact program
flow depends on
different settings
Call of list processing for basic list
AT LINE-SELECTION,
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 53
TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 53 Simplicity – ABAP Objects ABAP Objects is

Simplicity – ABAP Objects

ABAP Objects is simple because:

There are only a few orthogonal basic concepts

Classes contain attributes and methods Objects are instances of classes Objects are adressed via references Accessibility is clearly defined by the object’s interface

Programming with objects is more natural than handling data via procedures

objects is more natural than handling data via procedures  SAP AG 2003, TechED_B asel /

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 54

Next Topic Background Principal Features of ABAP Objects Encapsulation Instantiation Reuse via Inheritance
Next Topic
Background
Principal Features of ABAP Objects
Encapsulation
Instantiation
Reuse via Inheritance
Interfacing
Events
Benefits of ABAP Objects
Simplicity
Explicitness
Maintainability
Purified ABAP
Future Orientation
Conclusion
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 55
   

Explicitness

 
 
 

ABAP/4 has many implicit features, e.g.:

 

Implicit interfaces via global data

Dynpros Logical Databases

Programs are controlled by runtime environment

Programs are driven from Dynpros Program execution via SUBMIT

 

ABAP Objects is explicit

 
 

no hidden concepts no “black magic”

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 56

 SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch / 56
Explicitness – Example (1) Classes instead of logical data bases Simple example for a class
Explicitness – Example (1)
Classes instead of logical data bases
Simple example for
a class that works
like a logical
database
with a
CLASS ldb DEFINITION.
PUBLIC SECTION.
METHODS read_spfli.
EVENTS spfli_ready EXPORTING value(values) TYPE spfli.
PRIVATE SECTION.
DATA spfli_wa TYPE spfli.
single node
ENDCLASS.
Explicit Interface
CLASS ldb IMPLEMENTATION.
METHOD read_spfli.
SELECT * FROM spfli
INTO spfli_wa.
RAISE EVENT spfli_ready EXPORTING values = spfli_wa.
ENDSELECT.
ENDMETHOD.
ENDCLASS.
Events with
parameters
Class Pool
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 57
Explicitness – Example (2)
Class instead of report program
Simple example for
a class that works
like a report
Start via an OO
Transaction
Explicit event
CLASS report DEFINITION.
PUBLIC SECTION.
METHODS start.
PRIVATE SECTION.
DATA spfli_tab TYPE TABLE OF spfli.
METHODS: get_spfli FOR EVENT spfli_ready OF ldb
IMPORTING values,
display_spfli.
handling
ENDCLASS.
Decoupling of data
display from data
handling
ABAP Program
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 58
Explicitness – Example (3) CLASS report IMPLEMENTATION. METHOD start. DATA ldb TYPE REF TO ldb.
Explicitness – Example (3)
CLASS report IMPLEMENTATION.
METHOD start.
DATA ldb TYPE REF TO ldb.
CREATE OBJECT ldb.
SET HANDLER me->get_spfli FOR ldb.
ldb->read_spfli( ).
display_spfli( ).
ENDMETHOD.
Simplicity does not
necessarily mean
less coding
METHOD get_spfli.
APPEND values TO spfli_tab.
ENDMETHOD.
METHOD display_spfli.
DATA alv_list TYPE REF TO cl_gui_alv_grid.
CREATE OBJECT alv_list
EXPORTING i_parent = cl_gui_container=>screen0.
alv_list->set_table_for_first_display(
EXPORTING i_structure_name = 'SPFLI‚
CHANGING it_outtab
CALL SCREEN 100.
ENDMETHOD.
= spfli_tab ).
ENDCLASS.
ABAP Program
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 59
Next Topic Background Principal Features of ABAP Objects Encapsulation Instantiation Reuse via Inheritance
Next Topic
Background
Principal Features of ABAP Objects
Encapsulation
Instantiation
Reuse via Inheritance
Interfacing
Events
Benefits of ABAP Objects
Simplicity
Explicitness
Maintainability
Purified ABAP
Future Orientation
Conclusion
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 60
Maintainability Programs using ABAP Objects are easier to maintain program structure better readable better navigation

Maintainability

Programs using ABAP Objects are

easier to maintain

program structure better readable better navigation

more reliable

encapsulation secure typing surprise free

reliable encapsulation secure typing surprise free  SAP AG 2003, TechED_B asel / ABAP 256, Horst

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 61

Maintainability – Program Structure Declaration CLASS DEFINITION. mandatory PUBLIC SECTION. METHODS: m1 No
Maintainability – Program Structure
Declaration
CLASS
DEFINITION.
mandatory
PUBLIC SECTION.
METHODS: m1
No declaration
PRIVATE SECTION.
of procedures
METHODS: m2
m3
FUNCTION f1.
ENDCLASS.
PERFORM s1
ENDFUNCTION.
CLASS
IMPLEMENTATION.
METHOD m1.
FORM s1
Navigation
m2(
).
PERFORM f2
ENDMETHOD.
ENDFORM.
Mixture of
METHOD m2.
FORM s2
different
m3(
).
procedures
PERFORM s3
ENDMETHOD.
ENDFORM.
METHOD m3.
FORM s3
ENDMETHOD.
Only methods
ENDFORM.
ENDCLASS.
Function Group
Class Pool
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 62
Next Topic Background Principal Features of ABAP Objects Encapsulation Instantiation Reuse via Inheritance
Next Topic
Background
Principal Features of ABAP Objects
Encapsulation
Instantiation
Reuse via Inheritance
Interfacing
Events
Benefits of ABAP Objects
Simplicity
Explicitness
Maintainability
Purified ABAP
Future Orientation
Conclusion
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 63
Purified ABAP - Syntax (1) ABAP/4 has developed over a long period of time large
Purified ABAP - Syntax (1)
ABAP/4 has developed over a long period of time
large number of obsolete statements
overlapping concepts
highly specialized concepts
surprising implicit behavior
difficult to learn
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 64
Purified ABAP - Syntax (2) ABAP Objects reduces the complexity of ABAP many obsolete statements
Purified ABAP - Syntax (2)
ABAP Objects reduces the complexity of ABAP
many obsolete statements and additions are forbidden
many implicit syntax completions must be done explicit
wrong handling of data is restricted
SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 65
Purified ABAP – Syntax Examples (1) Clean-Up in ABAP Objects No implicit work areas No
Purified ABAP – Syntax Examples (1)
Clean-Up in ABAP Objects
No implicit work areas
No internal tables with header lines explicit
specification of work areas
No TABLES work areas no data sharing between
programs, explicit specification of work areas in Open
SQL ,
Obsolete
Two data objects
with one name!
declaration!
DATA BEGIN OF itab OCCURS 10.
DATA itab TYPE TABLE OF
CLEAR itab.
CLEAR itab.
TABLES dbtab.
SELECT * FROM dbtab.
DATA wa TYPE dbtab.
SELECT * FROM dbtab INTO wa.
Inappropriate
ABAP/4
ABAP Objects
short forms
SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 66
Purified ABAP – Syntax Examples (2) Clean-Up in ABAP Objects No implicit typing of field-symbols
Purified ABAP – Syntax Examples (2)
Clean-Up in ABAP Objects
No implicit typing of field-symbols and formal
parameters
Unexpected
behavior!
FIELD-SYMBOLS <fs>.
FIELD-SYMBOLS <fs> TYPE ANY.
IF <fs> IS ASSIGNED.
IF <fs> IS ASSIGNED.
ENDIF.
ENDIF.
ABAP/4
ABAP Objects
Expected
behavior!
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 67
Purified ABAP – Syntax Examples (3) Clean-Up in ABAP Objects No wrong data handling DATA
Purified ABAP – Syntax Examples (3)
Clean-Up in ABAP Objects
No wrong data handling
DATA number TYPE i VALUE
DATA number TYPE i VALUE
TRANSLATE number
TO UPPER CASE.
TRANSLATE number
TO UPPER CASE.
ABAP/4
ABAP Objects
Syntax error
Undefined
behavior!
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 68
   

Purified ABAP - Semantics

 

Unicode-enabled ABAP

  Unicode-enabled ABAP

Static type checks specified more precisely Byte and character strings processed separately Structures handled appropriately for their type using structural equivalence rules Uncontrolled memory manipulation no longer permitted

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 69

 SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch / 69
   

Purified Semantics – Example (1)

 

Unicode-enabled ABAP

 

Structures are assigned fragment by fragment

 

DATA: BEGIN OF struc1, col1(2) TYPE c VALUE 'AB', col2(2) TYPE c VALUE 'CD', END OF struc1.

 

DATA: BEGIN OF struc2, col1(4) TYPE c,

Code page dependent representation of blanks ABCD ####
Code page
dependent
representation of
blanks
ABCD
####

col2

TYPE i,

END OF struc2.

struc2 = struc1.

struc2 in non-Unicode-enabled ABAP:

struc2 in Unicode-enabled ABAP:

ABCD 0 Type specific
ABCD
0
Type specific

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 70

 SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch / 70
Purified Semantics – Example (2) Unicode-enabled ABAP No access to memory outside a data object
Purified Semantics – Example (2)
Unicode-enabled ABAP
No access to memory outside a data object
DATA: text1(10) TYPE c,
text2(10) TYPE c VALUE 'ABCDEFGHIJ',
off TYPE i.
FIELD-SYMBOLS <fs> TYPE c.
DO 15 TIMES.
off = sy-index - 1.
ASSIGN text1+off(1) TO <fs>.
IF <fs> IS ASSIGNED.
<fs> = 'X'.
ENDIF.
ENDDO.
Memory
overwriting,
even for
references!
text2 in non-Unicode-enabled ABAP:
XXXXXFGHIJ
text2 in Unicode-enabled ABAP:
ABCDEFGHIJ
Memory protection
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 71
TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 71 Purified Syntax + Purified Semantics Unicode-enabled ABAP

Purified Syntax + Purified Semantics

Unicode-enabled ABAP Objects!

Unicode-enabled ABAP Objects is the best ABAP available up to now! If you use Unicode-enabled ABAP Objects, you program automatically according to the rules of purified syntax and semantics Even if you do not exploit the real “object oriented” features, programs written in Unicode-enabled ABAP Objects are

more robust less error prone better to maintain

are more robust less error prone better to maintain  SAP AG 2003, TechED_B asel /

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 72

Next Topic Background Principal Features of ABAP Objects Encapsulation Instantiation Reuse via Inheritance
Next Topic
Background
Principal Features of ABAP Objects
Encapsulation
Instantiation
Reuse via Inheritance
Interfacing
Events
Benefits of ABAP Objects
Simplicity
Explicitness
Maintainability
Purified ABAP
Future Orientation
Conclusion
SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 73
Future Orientation (Unicode enabled) ABAP Objects is part of an ongoing evolution Don‘t get lost!
Future Orientation
(Unicode enabled) ABAP Objects is part of an
ongoing evolution
Don‘t get
lost!
Migration
R/2 ABAP
ABAP/4
ABAP Objects
Unicode enabled
Possible future
developments
SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 74
Next Topic Background Principal Features of ABAP Objects Encapsulation Instantiation Reuse via Inheritance
Next Topic
Background
Principal Features of ABAP Objects
Encapsulation
Instantiation
Reuse via Inheritance
Interfacing
Events
Benefits of ABAP Objects
Simplicity
Explicitness
Maintainability
Purified ABAP
Future Orientation
Conclusion
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 75
TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 75 Conclusion - Summary ABAP Objects offers better

Conclusion - Summary

ABAP Objects offers

better encapsulation better interfaces better techniques for reuse more static type security support for multiple instantiation better support for dynamic programming

instantiation better support for dynamic programming  SAP AG 2003, TechED_B asel / ABAP 256, Horst

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 76

Conclusion - Recommendation Everybody programming in ABAP should use ABAP Objects for new and ongoing

Conclusion - Recommendation

Everybody programming in ABAP should use ABAP Objects for new and ongoing projects

take advantage of object oriented features use methods as far as possible, even if you stay within the procedural programming model do not use subroutines any more use function modules only when technically necessary (RFC, encapsulation of screens etc.) disentangle classical ABAP from ABAP Objects

etc.) disentangle classical ABAP from ABAP Objects  SAP AG 2003, TechED_B asel / ABAP 256,

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 77

TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch / 77 Appendix Stricter syntax in ABAP

Appendix

Stricter syntax in ABAP Objects

Stricter syntax in Unicode programs

Example for encapsulation of screens

in Unicode programs Example for encapsulation of screens  SAP AG 2003, TechED_B asel / ABAP
in Unicode programs Example for encapsulation of screens  SAP AG 2003, TechED_B asel / ABAP

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 78

   

Appendix A – Stricter Syntax in ABAP Objects (1/2)

 

Notation: No special characters in names, no length specifications <= zero, no multi-line literals Declarations: LIKE references to data objects only; no implicit lengths or decimal places in TYPES; no length specifications for data types i, f, d, or t; no operational statements in structure definitions;

FIELDS, RANGES, INFOTYPES, TABLES, NODES, COMMON PART, OCCURS, NON-

 
 

LOCAL not permitted Forbidden operations: CLEAR … WITH NULL, PACK, MOVE

 
 

PERCENTAGE, ADD-CORRESPONDING, DIVIDE-CORRESPONDING, SUBTRACT-

 

CORRESPONDING, MULTIPLY-CORRESPONDING, ADD THEN

UNTIL

,

ADD FROM

TO

,

CONVERT {DATE|INVERTED DATE}

 

String processing: Not permitted on numeric data objects Field symbols: No implicit types; FIELD-SYMBOLS … STRUCTURE,

 

 

ASSIGN

TYPE, ASSIGN LOCAL COPY OF, ASSIGN TABLE FIELD not

 

permitted Logic expressions: ><, =<, => not permitted, table used with IN must be a selection table Control structures: No operational statements between CASE and WHEN, ON-ENDON not permitted

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 79

 
 SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch / 79  
   

Appendix A – Stricter Syntax in ABAP Objects (2/2)

 

Internal tables: No headers, no implicit work areas, no redundant key specifications, compatible work areas where necessary,

 

obsolete READ variants and COLLECT

SORTED BY, WRITE TO itab,

 

PROVIDE (short form) not permitted Procedures (methods): No implicit type assignment, compatible initial values only, passing sy-subrc not permitted, raising undefined exceptions not permitted Program calls: No joint use of USING and SKIP FIRST SCREEN when calling transactions, passing formal parameters implicitly in CALL DIALOG not permitted Database accesses: No implicit work areas, no *-work areas, READ, LOOP, REFRESH FROM on database tables not permitted, VERSION addition to DELETE and MODIFY not permitted, no PERFORMING addition in Native SQL

Data cluster: No implicit identifiers, passing parameters explicitly not permitted, no implicit work areas, MAJOR-ID and MINOR-ID not permitted

Lists: DETAIL, SUMMARY, INPUT, MAXIMUM, MINIMUM, SUMMING, MARK, NEW-

 

SECTION and obsolete print parameters not permitted

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 80

 SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch / 80
 SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch / 80
   

Appendix B – Stricter Syntax in Unicode Programs

 

Offset/length accesses: Only performed on character-type or byte-type ranges, and only on flat character-type initial parts of structures Memory accesses: No access to memory outside a data object

Separation of byte string and character string processing: Explicit specification with IN BYTE MODE or IN CHARACTER MODE ; appropriate types expected – for character strings this means only c, d, n, t, string, and flat structures with purely character-type components Structures: When assigning and comparing you must take the Unicode fragment view into consideration

File interface: Implicitly opening files not permitted; access, storage, and coding type must be specified explicitly; no write access to read-only files

Conversions: TRANSLATE

CODE PAGE

,

TRANSLATE

NUMBER

 

FORMAT

not permitted

 

OPEN SQL: Stricter conditions for work areas

 

Type assignment using STRUCTURE: Stricter checks on assignments to field symbols and formal parameters typed using STRUCTURE

Function module calls: A specified formal parameter of a function module

must be available

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 81

must be available  SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch
must be available  SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch
Appendix C – Encapsulation of Screens (1) Encapsulation of screens in function groups FUNCTION-POOL flight_screens.
Appendix C – Encapsulation of Screens (1)
Encapsulation of screens in function groups
FUNCTION-POOL flight_screens.
Selection
Screen
SELECTION-SCREEN BEGIN OF SCREEN 100 AS WINDOW.
PARAMETERS: p_carrid TYPE sflight-carrid,
p_connid TYPE sflight-connid,
p_fldate TYPE sflight-fldate.
SELECTION-SCREEN END OF SCREEN 100.
Interface
data for
dynpro
TABLES sflight.
FUNCTION get_flight_parameters.
CALL SELECTION-SCREEN 100 STARTING AT 10 10.
" checks
carrid = p_carrid.
connid = p_connid.
fldate = p_fldate.
ENDFUNCTION.
Screen
Screen
handling in
handling in
function
function
modules
modules
FUNCTION get_plane_type.
sflight-planetype = plane_type.
" preparation
CALL SCREEN 200 STARTING AT 10 10.
" checks
plane_type = sflight-planetype.
ENDFUNCTION.
Further step:
Local classes in
function group as
screen handlers
Function Group
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 82
Appendix C – Encapsulation of Screens (2) Object driven usage of screens CLASS flights DEFINITION.
Appendix C – Encapsulation of Screens (2)
Object driven usage of screens
CLASS flights DEFINITION.
PUBLIC SECTION.
METHODS: constructor,
change_plane_type.
PRIVATE SECTION.
DATA flight TYPE sflight.
ENDCLASS.
Call of
Call of
functions with
functions with
parameters
parameters
CLASS flights IMPLEMENTATION.
METHOD constructor.
DATA: carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
fldate TYPE sflight-fldate.
CALL FUNCTION 'GET_FLIGHT_PARAMETERS'
IMPORTING
carrid = carrid
connid = connid
fldate = fldate.
SELECT SINGLE *
FROM sflight
INTO flight
WHERE carrid = carrid AND
connid = connid AND
fldate = fldate.
ENDMETHOD.
METHOD change_plane_type.
CALL FUNCTION 'GET_PLANE_TYPE'
CHANGING
plane_type = flight-planetype.
ENDMETHOD.
Class Pool
ENDCLASS.
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 83
Further Information ABAP Documentation: Always the first source of information Articles in Journals:
Further Information
ABAP Documentation:
Always the first source of information
Articles in Journals:
http://www.intelligenterp.com/feature/archive/heymann.shtml
http://www.intelligenterp.com/feature/archive/keller.shtml
http://www.sappublications.com/insider/article.htm?key=20248
SAP Press Books:
ABAP Objects, Introduction:
ISBN 0-201-75080-5 (English)
ISBN 3-89842-147-3 (German)
ABAP Objects, Reference:
ISBN 1-59229-011-6 (English)
ISBN 3-934358-61-6 (German)
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 84
Questions?  SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch /

Questions?

Questions?  SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch / 85

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 85

Q&A

asel / ABAP 256, Horst Keller, Stefan Bresch / 85 Q&A Feedback Please complete your session
Feedback Please complete your session evaluation and drop it in the box on your way
Feedback
Please complete your session evaluation and
drop it in the box on your way out.
Thank You !
The SAP TechEd ’03 Basel Team
 SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 86
   

Copyright 2003 SAP AG. All Rights Reserved

 

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.

Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

Microsoft ® , WINDOWS ® , NT ® , EXCEL ® , Word ® , PowerPoint ® and SQL Server ® are registered trademarks of Microsoft Corporation.

IBM ® , DB2 ® , DB2 Universal Database, OS/2 ® , Parallel Sysplex ® , MVS/ESA, AIX ® , S/390 ® , AS/400 ® , OS/390 ® , OS/400 ® , iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere ® , Netfinity ® , Tivoli ® , Informix and Informix ® Dynamic Server TM are trademarks of IBM Corporation in USA and/or other countries.

ORACLE ® is a registered trademark of ORACLE Corporation.

UNIX ® , X/Open ® , OSF/1 ® , and Motif ® are registered trademarks of the Open Group.

Citrix ® , the Citrix logo, ICA ® , Program Neighborhood ® , MetaFrame ® , WinFrame ® , VideoFrame ® , MultiWin ® and other Citrix product names referenced herein are trademarks of Citrix Systems, Inc.

HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C ® , World Wide Web Consortium, Massachusetts Institute of Technology.

JAVA ® is a registered trademark of Sun Microsystems, Inc.

JAVASCRIPT ® is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.

MarketSet and Enterprise Buyer are jointly owned trademarks of SAP AG and Commerce One.

SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies.

SAP AG 2003, TechED_Basel / ABAP256, Horst Keller, Stefan Bresch / 87

 SAP AG 2003, TechED_B asel / ABAP 256, Horst Keller, Stefan Bresch / 87