You are on page 1of 37

SAP TechEd ‘03 Las Vegas

ABAP Language
News

Andreas Blumenthal
VP ABAP Server Technology & I18N
SAP AG

Learning Objectives

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

Know about SAP's commitment to ABAP as a programming


language of choice for SAP NetWeaver
Know about the general direction of ABAP language
improvements in 6.20 and 6.40
Get an general overview of the latest ABAP language
improvements
Know about the most important new features in more detail

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 2

© 2003 SAP Labs, LLC Session ID, Speaker 1


SAP TechEd ‘03 Las Vegas

Agenda

Shared Objects

Activatable Checkpoints:
Assertions & Breakpoints

Generic Programming

ABAP Objects & Class-Based Exceptions

Miscellaneous

Summary

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 3

Coming next

Shared Objects

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 4

© 2003 SAP Labs, LLC Session ID, Speaker 2


SAP TechEd ‘03 Las Vegas

Shared Objects - Motivation

With 64-bit architectures address space is no longer limited

Buffering data in shared memory is much longed for by


application development

Current workarounds
Long running transactions
EXPORT / IMPORT
Data must be copied before access (time and memory costs)
Data and object references not allowed
EXPORT / IMPORT TO SHARED BUFFER (since 4.0)
Automatic displacement (needs fallback strategy)
EXPORT / IMPORT TO SHARED MEMORY (since 6.10)
Displacement strategy to be implemented by application
Special solutions integrated into the kernel

New kinds of applications implementable 


via shared objects

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 5

Shared Objects - What ABAP Developers Demand

Fast (copy free) access to shared memory

Support for arbitrary (data) objects, including references

Easy to use and robust programming model

Smooth integration into the ABAP language

Design time and monitoring support

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 6

© 2003 SAP Labs, LLC Session ID, Speaker 3


SAP TechEd ‘03 Las Vegas

Shared Objects - What we Deliver

Simple 4GL like programming model

Complexity hidden by descriptive approach for powerful features

Robustness by type safety and complete control of references


into shared memory

Instantiation of arbitrary (data) objects in shared memory

Identical source code for classes to be instantiated in roll area or


shared memory

Support for high availability (24 hours)

High flexibility due to customizable properties

Focus on important use cases, not on generality

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 7

Shared Objects - Usage Scenarios

Shared buffers
Low update frequency (once a day to once per hour)
(Very) large amounts of data
Single provider (writer)
Many parallel readers
Examples: catalogues, meta data repositories

Exclusive buffers
Access by a single writer / reader
Buffer contents are kept across transactions
Example: shopping baskets, caches with single point of access

Ä Coarse granular locking concept


Only a complete buffer can be locked
Sufficient for the above scenarios
Rare updates (shared buffer)
Readers and writers know each other (exclusive buffer)

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 8

© 2003 SAP Labs, LLC Session ID, Speaker 4


SAP TechEd ‘03 Las Vegas

Shared Objects - Areas and Area Instances 1

The shared objects memory is a


reserved part of the shared memory Shared Memory
Size customizable by profile
parameter Shared Objects Memory

The organizational units are called


areas Area Area
Defined at design time I
n I
Identified by unique name s I n
t n s
(checked at design time) a s t
n t a
c a n
Contents are stored in area instances e n
c
c
e
at runtime e

Identified by a unique name within


the area
The instance of a single-instance
area is generally addressed by a
default name

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 9

Shared Objects - Areas and Area Instances 2

Basics about area instances


Roll Area
All (data) objects in an area instance
are reachable via references
Each area instance has a root object
An area instance must be self-contained, Area Instance
i.e. no outgoing references after build-up
to
Roll area Root
Other areas
Inner references are allowed
References from roll area to an area
instance
Allowed as long as the area instance is
attached
Otherwise runtime error at access

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 10

© 2003 SAP Labs, LLC Session ID, Speaker 5


SAP TechEd ‘03 Las Vegas

Shared Objects Example: A Simple Catalogue

Catalogue (area instance)

Active version

Reader
Reader
 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 11

Shared Objects Example: A Simple Catalogue

Catalogue (area instance)

Active version Version under


construction

Reader
Reader Writer

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 12

© 2003 SAP Labs, LLC Session ID, Speaker 6


SAP TechEd ‘03 Las Vegas

Shared Objects Example: A Simple Catalogue

Catalogue (area instance)

Version Active version


out-of-date

Reader
Reader
 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 13

Shared Objects Example: A Simple Catalogue

Catalogue (area instance)

Version Active version


out-of-date

Reader
Reader Reader

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 14

© 2003 SAP Labs, LLC Session ID, Speaker 7


SAP TechEd ‘03 Las Vegas

Shared Objects Example: A Simple Catalogue

Catalogue (area instance)

Version Active version


out-of-date

Reader
Reader

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 15

Shared Objects Example: A Simple Catalogue

Catalogue (area instance)

Version Active version


expired

Reader

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 16

© 2003 SAP Labs, LLC Session ID, Speaker 8


SAP TechEd ‘03 Las Vegas

Shared Objects Example: A Simple Catalogue

Catalogue (area instance)

Active version

Reader

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 17

Shared Objects - Design Time Support

An area is defined at design time with


transaction SHMA

The specified area name corresponds


to a class to be generated as a
subclass of the abstract area root
class CL_SHM_AREA Area: cl_my_area

Instance
The name of a root data class must be
Root: cl_my_root
specified (static type safety)

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 18

© 2003 SAP Labs, LLC Session ID, Speaker 9


SAP TechEd ‘03 Las Vegas

Shared Objects – Design Time Support via


Transaction SHMA

An area is a special
class generated with
transaction SHMA

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 19

Shared Objects - Area Properties – Different Kinds

Basic (static) properties


Changes let expire all area instances and require developer’s rights
Current readers or changers are canceled

Dynamic properties
Changes apply to new area instance versions only, but still require
developer’s rights
Current readers or changers are not interrupted

Runtime (customizable) properties


As for dynamic properties
Changes apply to new area instance versions only
Current readers or changers are not interrupted
No developer’s rights required

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 20

© 2003 SAP Labs, LLC Session ID, Speaker 10


SAP TechEd ‘03 Las Vegas

Shared Objects - Area Properties – Summary (1)

Basic (static) properties:


Area name (i.e. name of generated area class)
Root data class (i.e. type of root object)
Area instance binding:
Application server
(Single) user session
ABAP memory
Versioning (off, on, fine-tuning via corresponding runtime
property)
Preloading (off, on, fine-tuning via corresponding runtime
property)
Transactionality (off, on)
Propagation (i.e. synchronization across application servers)
(off, on)
Client dependency (off, on)

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 21

Shared Objects - Area Properties – Summary (2)

Dynamic properties:
Loader class
Displacement (off, on, w/ serialization)

Runtime (customizable) properties:


Maximum number of versions (2, 3, …)
Kind of preloading:
on read request
on read request & invalidation
on server start & invalidation
Refresh time (automatically trigger creation of new version)
Invalidation time (invalidate version after some time)
Idle time (free version when not being used any more)
Memory limits (per version, per area)

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 22

© 2003 SAP Labs, LLC Session ID, Speaker 11


SAP TechEd ‘03 Las Vegas

Shared Objects - Monitoring Support via


Transaction SHMM

Overview on areas, area instances, and versions

Locks and lock holders

Memory consumption per area, area instance, and version

Area contents viewer

Area properties overview

Hooks for user defined tracing

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 23

Monitoring Transaction SHMM

Living areas

Lock overview

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 24

© 2003 SAP Labs, LLC Session ID, Speaker 12


SAP TechEd ‘03 Las Vegas

Shared Objects - Sneak Code Preview – Write Access

DATA:
...
Open default instance
myShmHandle TYPE REF TO cl_my_area, for write
myRoot TYPE REF TO cl_my_root.

myShmHandle = cl_my_area=>attach_for_write( ). Create arbitray (data)


objects in shared
CREATE OBJECT myRoot AREA HANDLE myShmHandle. memory
myRoot->name = 'My first area instance'.
APPEND wa TO myRoot->itab.
...
CREATE OBJECT oref AREA HANDLE myShmHandle.
myRoot->struc->oref = oref.
... Set root object and
Coding typically encapsulated within the loader commit changes
IF ...
myShmHandle->set_root( myRoot ).
myShmHandle->detach_commit( ). Rollback changes
ELSE.
myShmHandle->detach_rollback( ).
ENDIF.

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 25

Shared Objects - Sneak Code Preview – Read Access

DATA:
Open default instance
myShmHandle TYPE REF TO cl_my_area.
for read

myShmHandle = cl_my_area=>attach_for_read( ).
Access root object
components

READ TABLE myShmHandle->root->itab


INTO wa INDEX i.

... Release lock

myShmHandle->detach( ).

Coding typically encapsulated by the broker

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 26

© 2003 SAP Labs, LLC Session ID, Speaker 13


SAP TechEd ‘03 Las Vegas

Coming next

Activatable Checkpoints:
Assertions & Breakpoints

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 27

What are Assertions Good For ?

Two aspects of software reliability:

Robustness
React reasonably to a wide variety of circumstances and
possibly unexpected conditions
Example: Check for invalid file formats when handling files
Provide a mechanism to detect exceptional conditions and
handle them in specific code blocks
Ä Exceptions (already provided by ABAP Objects)

Correctness
Adhere to some specification
Example: Load & process some valid configuration file in a well-
defined way
Provide means to detect incorrect state during normal program
flow
Ä Assertions

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 28

© 2003 SAP Labs, LLC Session ID, Speaker 14


SAP TechEd ‘03 Las Vegas

What are Assertions ?

An assertion is

by intention, a program language construct which allows


explicit declaration of program correctness.

technically, a logical expression that must be true during


normal program execution.

Basic syntax:

ASSERT <logical_expression>.

Advanced syntax:

ASSERT ID <checkpoint_group>
CONDITION <logical_expression>.

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 29

Assertions Enforce a Valid Runtime State

unexpected
: assertion
behaviour
system state
system state

runtime
normal termination

normal termination

error

consistent state consistent state

program flow program flow

Assertions enforce a valid runtime state at discrete checkpoints in an


executing system, thus enhancing reliability and maintainability

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 30

© 2003 SAP Labs, LLC Session ID, Speaker 15


SAP TechEd ‘03 Las Vegas

Assertions Declare Developer's Intent

runtime error or
unexpected
behaviour : assertion

system state
system state

?
Where did things start
going wrong

consistent state not clearly defined consistent state

program flow program flow

Assertions declare developer's intent and provide insight into expected


system behavior, thus enhancing maintainability

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 31

Common Uses for Assertions

Preconditions:
Conditions that must be true when entering a procedure

Postconditions:
Conditions that must be true when exiting a procedure

Invariants:
Conditions that always hold true, e.g. for all iterations
inside a loop

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 32

© 2003 SAP Labs, LLC Session ID, Speaker 16


SAP TechEd ‘03 Las Vegas

Assertions in ABAP as Activatable Assertions

What's really special with assertions in ABAP:

ABAP assertions are activatable !


Assertions can be activated dynamically in productive
systems. No recompilation nor VM restart necessary.
No significant performance penalty from inactive assertions.
Transaction SAAB for administration

Control over scope of activation and mode of activation when


activating assertions:
Which assertions ?
For whom ?
What behavior in case of failure ?

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 33

Scope and Mode of Activation (Overview)

Control over scope of activation when activating assertions:


Which assertions shall be activated ?
Per compilation unit
Per checkpoint group:
ASSERT ID <checkpoint_group> CONDITION …
Via activation variants
For whom shall these assertions be activated ?
Per user (for all servers)
Per server (for all users)
Globally

Control over mode of activation, i.e. behavior in case an


assertion fails:
Break, i.e. stop program execution in debugger
Abort, i.e. terminate program execution with short dump
Protocol, i.e. write to assertion log and resume program
execution
 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 34

© 2003 SAP Labs, LLC Session ID, Speaker 17


SAP TechEd ‘03 Las Vegas

Multiple Activation Options for Assertions

ABAP assertions offer multiple activation options:

ASSERT A ASSERT D ASSERT F

ASSERT B ASSERT A ASSERT G

ASSERT C ASSERT E ASSERT A

Report x Class y Function group z


Application

We have a set of assertions for different aspects (A-G) of an


application in different compilation units (x-z).

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 35

Activating Assertions per Compilation Unit

ABAP assertions offer multiple activation options:

ASSERT A ASSERT D ASSERT F

ASSERT B ASSERT A ASSERT G

ASSERT C ASSERT E ASSERT A

Report x Class y Function group z


Application

1. Activate assertions for specified compilation units


(as known from C/C++, Eiffel and Java)

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 36

© 2003 SAP Labs, LLC Session ID, Speaker 18


SAP TechEd ‘03 Las Vegas

Activating Assertions per Checkpoint Group

ABAP assertions offer multiple activation options:

ASSERT A ASSERT D ASSERT F

ASSERT B ASSERT A ASSERT G

ASSERT C ASSERT E ASSERT A

Report x Class y Function group z


Application

2. Activate assertions for specified aspects.


Assert statements refer to a checkpoint group. Activation is
controlled via this checkpoint group. More than one assertion
can refer to the same checkpoint group.
 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 37

Activating Assertions via Activation Variants

ABAP assertions offer multiple activation options:

ASSERT A ASSERT D ASSERT F

ASSERT B ASSERT A ASSERT G

ASSERT C ASSERT E ASSERT A

Report x Class y Function group z


Application

3. Activate assertions from an activation variant.


Combinations of the above options can be stored as
activations variants.

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 38

© 2003 SAP Labs, LLC Session ID, Speaker 19


SAP TechEd ‘03 Las Vegas

Fine-Tuning the Scope of Assertion Activation

ABAP assertion activation is global or server specific or user specific:

Assertions can be used for maintenance without interference with


productive users
productive users

...
DB

DB

dedicated
support
support server

server specific activation user specific activation

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 39

Assertion Behavior in Case of Failure

ABAP assertions offer multiple behavior options:

BREAK: Program execution is stopped ( debugger)

ABORT: Program execution is terminated with runtime


error ASSERTION_FAILED.

PROTOCOL:Violation of the assert condition is logged,


program execution is resumed (use transaction
SAAB to display log)

ABAP assertions support different maintenance scenarios

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 40

© 2003 SAP Labs, LLC Session ID, Speaker 20


SAP TechEd ‘03 Las Vegas

Assertions in ABAP

Assertion behavior and maintenance scenarios:

Maintenance

Short term, interactive Long term, non-interactive

BREAK ABORT PROTOCOL

Productive user, Productive


prepared to encounter user, non
short dump disturbed
Support user, prepared to
jump into debugger
Support, analyzing short dumps or
monitoring assertion protocol

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 41

Activatable Breakpoints: Why and How

By using functional methods in the assert condition, also


complex checks can be implemented.
Nevertheless, in a business application it may not always be
possible to express state consistency in an easy way.
Ä Problem:
Development needs a way to mark such critical points
Support needs a way to find these points
Ä Solution:
Activatable breakpoints as a new form of BREAK-POINT
statement, which can be activated through association with a
checkpoint group:

BREAK-POINT ID <checkpoint_group>.

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 42

© 2003 SAP Labs, LLC Session ID, Speaker 21


SAP TechEd ‘03 Las Vegas

Comparison with Other Languages: C/C++, Eiffel, Java

C/C++: Assertions implemented via precompiler macros

Eiffel: Pioneering Design By Contract with a complex assertion


facility including OO-inheritance of assertions

Java: Offering a simple assertion facility (from J2SE 1.4 on)

In C/C++, assert coding is removed when a non-debug build is


made.

In Eiffel and Java, assertions are enabled through a command line


option of the runtime environment on the level of classes or
packages.

Ä No dynamic activation of assertions in a running system

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 43

Comparison with Other Languages: the ABAP Way

ABAP: On the language level comparable to Java assertions, but


on the runtime side offering unprecedented flexibility:

Activation on the fly

Activation on a semantic level by using different checkpoint


groups

Activation variants for complex settings

User specific or server specific activation

Additional options for the assert behavior facilitating interactive


and non-interactive maintenance

Ä Benefits of assertions can be exploited in the maintenance of


productive customer systems

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 44

© 2003 SAP Labs, LLC Session ID, Speaker 22


SAP TechEd ‘03 Las Vegas

Coming next

Generic Programming

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 45

Generic Programming

Runtime Type Creation

Open SQL

More catchable runtime errors

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 46

© 2003 SAP Labs, LLC Session ID, Speaker 23


SAP TechEd ‘03 Las Vegas

Runtime Type Creation - Motivation

Problem
Working on data whose structure isn't known at compile time
Examples
Tools like DDIC, ALV, Data Browser etc.
External data (RFC, IDOC, IMPORT etc.)

Current solutions
Code generation
Inefficient, cumbersome, error-prone
Limited number of subroutine pools
DDIC / database approach
Expensive, difficult to use
Explicit lifetime management necessary
Superset approach
Memory overhead
Only for minor differences in typing

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 47

Runtime Type Creation - Principle Ideas

Types as runtime objects


Types as instances of type classes
For each existing type, there is exactly one corresponding type
object

Type constructors
Constructors for all composed types (structs, tables, references)
Bottom-up approach (build new types from existing ones)
Support for easy type variations (e.g. projection on structures)

Characteristics of dynamically created types


Transientness
Lifetime limited to lifetime of internal mode
Enables garbage collection on types
Namelessness
Type represented by type object, not by name

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 48

© 2003 SAP Labs, LLC Session ID, Speaker 24


SAP TechEd ‘03 Las Vegas

Runtime Type Creation – Seamless Integration

Coherent with static types


Types created at runtime exactly behave like statically defined
types regarding type checks and type coercion

Merged with runtime type identification


Type hierarchy CL_ABAP_TYPEDESCR with its descendants (cf.
next slide) no also provides functionality for creating types

Handy language integration


Powerful API for type construction via CL_ABAP_TYPEDESCR
and its descendants
New keyword addition TYPE HANDLE with CREATE DATA
(CREATE OBJECT to follow) and ASSIGN

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 49

Dynamic Types - The Type System

CL_ABAP_TYPEDESCR
CL_ABAP_TYPEDESCR

CL_ABAP_DATADESCR
CL_ABAP_DATADESCR CL_ABAP_OBJECTDESCR
CL_ABAP_OBJECTDESCR

CL_ABAP_ELEMDESCR
CL_ABAP_ELEMDESCR CL_ABAP_CLASSDESCR
CL_ABAP_CLASSDESCR CL_ABAP_INTFDESCR
CL_ABAP_INTFDESCR

CL_ABAP_STRUCTDESCR
CL_ABAP_STRUCTDESCR
All data types are instances of
subclasses of CL_ABAP_DATADESCR
CL_ABAP_TABLEDESCR
CL_ABAP_TABLEDESCR Pre-arrangement for dynamic
creation of classes and interfaces
CL_ABAP_REFDESCR
CL_ABAP_REFDESCR

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 50

© 2003 SAP Labs, LLC Session ID, Speaker 25


SAP TechEd ‘03 Las Vegas

Dynamic Types - Type Creation

Create a standard table of a projection of a known structure


structure EMPLOYEE dyn. table of projection
name STRING name city .... phone
salaray P
city CHAR30
..... .....
phone(20) N

DATA: struct_type TYPE REF TO cl_abap_structdescr,


itab_type TYPE REF TO cl_abap_tabledescr,
comp_tab TYPE cl_abap_structdescr=>component_table.

struct_type ?=
cl_abap_typedescr=>describe_by_name( 'EMPLOYEE' ).
comp_tab = struct_type->get_components( ).
DELETE TABLE comp_tab WITH TABLE KEY name = 'salary'.
struct_type = cl_abap_structdescr=>create( comp_tab ).
itab_type = cl_abap_tabledescr=>create( struct_type ).

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 51

Dynamic Types - Type Usage

Dynamic types can be used to


Create anonymous data objects

DATA: dref TYPE REF TO data,


itab_type TYPE REF TO cl_abap_tabledescr.

... "create (or obtain) itab_type


CREATE DATA dref TYPE HANDLE itab_type.

Dynamically assign a type to a field symbol

DATA: dref TYPE REF TO data,


struc_type TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS: <fs>.

... "obtain struc_type


ASSIGN dref->* TO <fs> CASTING TYPE HANDLE struc_type.

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 52

© 2003 SAP Labs, LLC Session ID, Speaker 26


SAP TechEd ‘03 Las Vegas

Open SQL

Dynamic Open SQL enhancements:


Host variables now supported in dynamic WHERE clauses, i.e.
values don't have to be converted into literals any more
Ä Especially: Referring to range tables, i.e. IN rangeTab conditions,
now supported in dynamic WHERE clauses
Ä Especially: Referring to FOR ALL ENTRIES tables now supported
in dynamic WHERE clauses
Parsing dynamic SQL no up to 10x faster (50 µs instead of 500 µs
per clause, to give a rough estimate)

Multi-Connect:
Get access to multiple databases (other than system database)
Syntax: … dbtab CONNECTION con|(conName) …
Connections maintained in table DBCON
But: not officially released !
("This statement is for internal use only.
Incompatible changes or further developments may occur at any time
without warning or notice.")

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 53

More Catchable Runtime Errors

Many more catchable runtime errors !


Catching all kinds of procedure invokation errors (PERFORM,
CALL FUNCTION, CALL METHOD):
CX_SY_DYN_CALL_ERROR, CX_SY_DYN_CALL_*
Catching errors like
procedure unknown
parameter unknown
type error

Catching some ASSIGN errors:


CX_SY_ASSIGN_ERROR, CX_SY_ASSIGN_*
Catching errors like
casting errors (illegal cast, unknown type) and
range errors (range violation)

Further catchable runtime errors: look in the (dyna) book, aka


ABAP keyword documentation

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 54

© 2003 SAP Labs, LLC Session ID, Speaker 27


SAP TechEd ‘03 Las Vegas

Coming next

ABAP Objects &


Class-Based Exceptions

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 55

ABAP Objects Enhancements

Handling improvements:

Implicit loading of classes and interfaces:


CLASS class DEFINITION LOAD (almost) obsolete

More sensitive dependency checks:


Less recompilations in development systems

Enhanced checks for unused private components

New functionality:

Types in public section of global classes and in global


interfaces Ä more self-contained classes and interfaces

Improved ALIASES, especially:


Using Aliases with REDEFINITION and in the implementation
section's METHOD statement.

Kernel Methods
 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 56

© 2003 SAP Labs, LLC Session ID, Speaker 28


SAP TechEd ‘03 Las Vegas

Class-Based Exceptions (1)

Enhanced ST22 / ABAP short dump analysis:


Dedicated ABAP runtime error display for uncaught exceptions
(runtime error UNCAUGHT_EXCEPTION)

Access to exception object in cleanup section:


TRY.
DATA: xref TYPE REF TO cx_root.

CATCH …

CLEANUP INTO xref.

ENDTRY.

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 57

Class-Based Exceptions (2)

T100-based exception messages


Definition and usage analogous to OTR-based exception
messages
Mapping of positional parameters &1 … &4 to exception attributes
T100 restrictions: 4 variables, 72 characters text

Direct messaging for exception objects with T100-based


messages:
MESSAGE excObj TYPE …
(if excObj implements IF_T100_MESSAGE)

Syntax check messages for missing exception handling more


up to the point.

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 58

© 2003 SAP Labs, LLC Session ID, Speaker 29


SAP TechEd ‘03 Las Vegas

Coming next

Miscellaneous

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 59

Optimizations & Improved Resource Utilization

Enhanced 64 bit enabling


Single roll areas > 2 GB
Single buffers > 2 GB (PXA, table buffers, EXP/IMP buffers)

Improved multi-processor support in PXA


Better scalability
Higher degree of potential parallelization

DST-safe web application server


Keep your system up and running during the 'double hour'
Dilating time to guarantee unique timestamps

Sorting internal tables


String type sort key fields handled much more efficient

Saving PXA address space


Compressing initial record layouts
MOVE-CORRESPONDING optimized for minimum DATA CBs
 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 60

© 2003 SAP Labs, LLC Session ID, Speaker 30


SAP TechEd ‘03 Las Vegas

New Features (1)

Unicode
Pro-actively checking effects of potential structure enhancements
Support for multiple enhancement categories.
Unicode-enabled lists
Memory length and screen width not proportional any more

EXPORT / IMPORT
New medium INTERNAL TABLE
Comparable to DATA BUFFER, but line-wrapped instead of
continuous string

Arithmetics
Computing with time stamps: methods from CL_ABAP_TSTMP
provide for time stamp arithmetics analogous to date and time
arithmetics
New PRNG (pseudo random number generator) – details below

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 61

New Features (2)

API for (un-)zipping, i.e. (de-)compressing text and binary data:


CL_ABAP_GZIP, CL_ABAP_[UN]GZIP_*

Enhancing CONSTANTS analogous to DATA

Restarting parameter and variant transactions correctly:


LEAVE TO CURRENT TRANSACTION
CL_DYNPRO=>GET_CURRENT_TRANSACTION( )

Generalized secondary language access, including ABAP text


elements

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 62

© 2003 SAP Labs, LLC Session ID, Speaker 31


SAP TechEd ‘03 Las Vegas

New Tools

New Tools (cf. ABAP Tools lecture for more details):


Memory Inspector
Find memory leaks, especially when using dynamically allocated
(data) objects
Compare memory snapshots, e.g. for go-around points of long-
running transactions

ABAP Unit
Module testing à la XUnit / JUnit
Packaging test code with code to be tested in testee program
Automatic test suite creation
Managing more advanced test attributes

New debugger
Process separation between debugger and debuggee
Much improved UI
More & better debugging tools

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 63

Pseudo Random Number Generator - Problem

PRNGs are used to compute "random" sequences of numbers.

The sequences are produced in a deterministic way. Anyway the


numbers appear to the user to be random, that is the values of
subsequently generated numbers cannot be predicted.

Typical applications of PRNGs:


Testing of programs: Monte Carlo methods.
Quality assurance: data sampling.

Finding good algorithms for PRNGs is a hard mathematical task:


Numbers must be uniformly distributed within the target
range.
Multidimensional data must be uniformly distributed as well.
They must not lie in a subspace only.
The period of the generated sequence must be as high as
possible.

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 64

© 2003 SAP Labs, LLC Session ID, Speaker 32


SAP TechEd ‘03 Las Vegas

Pseudo Random Number Generator - Solution

Existing PRNGs at SAP have been tested thoroughly.


All of them showed significant statistical anomalies (even
the one that was certified externally …)

Thus we implemented one of the best algorithms available, the


Mersenne Twister (developed in 1997 by Makoto Matsumoto
and Takuji Nishimura).
Has a very high period length: 219937-1 (a Mersenne prime,
named after Marin Mersenne, 1588 - 1648).
Generates uniformly distributed values up to a dimension
of 623.
Access via ABAP classes. One can work with several
instances of PRNGs in parallel.

Using PRNGs is tricky, too:


Mapping numbers onto a range is error-prone. Numbers
can easily be outside the range after the mapping.
Ä Range-mapping as part of the API provided.

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 65

Pseudo Random Number Generator - Implementation

Generating number sequences for a fixed number type:


CL_ABAP_RANDOM_INT generates integer numbers, either
within a given interval, or within the whole integer range.
CL_ABAP_RANDOM_FLOAT generates floating-point
numbers between 0 (including) and 1 (excluding).
CL_ABAP_RANDOM_PACKED generates (integer) packed
numbers, either within a given interval, or within the whole
range of packed numbers.
CL_ABAP_RANDOM_PACKED_DEC<n> generates packed
numbers with <n> digits after the decimal point. <n> can be
in the range from 1 to 14.

CL_ABAP_RANDOM should be used when multidimensional


data with different data types are to be generated.

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 66

© 2003 SAP Labs, LLC Session ID, Speaker 33


SAP TechEd ‘03 Las Vegas

Pseudo Random Number Generator - Examples

Create 10.000 integers between 1 and 100:


DATA: prng TYPE REF TO cl_abap_random_int,
number TYPE i.

prng = cl_abap_random_int=>create( min = 1 max = 100 ).

DO 10000 TIMES.
number = prng->get_next( ).

ENDDO.

Create 100 2-tupels of type P(8) with random seed:


DATA: prng TYPE REF TO cl_abap_random_packed,
seed TYPE i, p1 TYPE p, p2 TYPE p.

seed = cl_abap_random=>seed( ).
prng = cl_abap_random_packed=>create( seed = seed
min = -999999999999999 max = 999999999999999 ).
DO 100 TIMES.
p1 = prng->get_next( ). p2 = prng->get_next( ).

ENDDO.

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 67

Coming next

Summary

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 68

© 2003 SAP Labs, LLC Session ID, Speaker 34


SAP TechEd ‘03 Las Vegas

Summary

ABAP is alive as a SAP NetWeaver language


Substantial ABAP improvements (language & tools)
with 6.20 and 6.40, more in the pipeline for > 6.40
Improving ABAP nowadays often means enhancing
libraries & tools instead of adding new keywords
Shared Objects: open new fields of ABAP
programming: application specific caches, roll-
area-transcendent contexts
Activatable Assertions: improve correctness &
serviceability
Runtime Type Creation: further improve flexible and
dedicated means for generic programming
 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 69

Further Information

Related Workshops/Lectures at SAP TechEd 2003

All sessions in track ABAP Development, but especially:

ABAP252: Developing Correct and Robust ABAP Code, 2-hr Hands-on


Wed, 2:00:00 PM, H4
ABAP254: Shared Objects in ABAP, 2-hr Hands-on
Wed, 11:00:00 AM, H4
ABAP256: Why Use ABAP Objects?, 4-hr Hands-on
Wed, 9:00:00 AM, H12
ABAP257: ABAP Troubleshooting, 4-hr Hands-on
Wed, 2:00:00 PM, H12

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 70

© 2003 SAP Labs, LLC Session ID, Speaker 35


SAP TechEd ‘03 Las Vegas

Further Information

Related Workshops/Lectures at SAP TechEd 2003

More favorites from track ABAP Development:

ABAP201: ABAP Workbench News, 1-hr Lecture


Thu, 9:00:00 AM, L1
ABAP258: Web Development with the ABAP Workbench, 4-hr Hands-on
Thu, 8:00:00 AM, H12
ABAP151: How to Make Your ABAP Code Unicode-Enabled, 2-hr Hands-on
Wed, 0:09:00 AM, H4
OSI253: XML Processing and XSLT Transformations with ABAP,
4-hr Hands-on
Thu, 9:00:00 AM, H8

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 71

Questions?

Q&A

 SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 72

© 2003 SAP Labs, LLC Session ID, Speaker 36


SAP TechEd ‘03 Las Vegas

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 / ABAP203, Andreas Blumenthal / 73

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 ServerTM 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 / ABAP203, Andreas Blumenthal / 74

© 2003 SAP Labs, LLC Session ID, Speaker 37

You might also like