abap language news
TRANSCRIPT
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 1/37
ABAP LanguageNews
Andreas BlumenthalVP ABAP Server Technology & I18N
SAP AG
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 2
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
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 2/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 3
Agenda
Shared Objects
Activatable Checkpoints:
Assertions & Breakpoints
Generic Programming
ABAP Objects & Class-Based Exceptions
Miscellaneous
Summary
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 4
Coming next
Shared Objects
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 3/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 5
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 / 6
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
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 4/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 7
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 referencesinto 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 / 8
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)
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 5/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 9
Shared Objects - Areas and Area Instances 1
Shared Memory
The organizational units are called
areas
Defined at design time
Identified by unique name
(checked at design time)
Area Area
Contents are stored in area instances
at runtime
Instance
Instance
Instance
Identified by a unique name within
the area
The instance of a single-instance
area is generally addressed by a
default name
Shared Objects Memory
The shared objects memory is a
reserved part of the shared memory
Size customizable by profile
parameter
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 10
Shared Objects - Areas and Area Instances 2
Basics about area instances Roll Area
Area Instance
All (data) objects in an area instance
are reachable via references
Each area instance has a root object
Root
An area instance must be self-contained,
i.e. no outgoing references after build-up
to
Roll area
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
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 6/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 11
Shared Objects Example: A Simple Catalogue
Catalogue (area instance)
Active version
Reader
Reader
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 12
Catalogue (area instance)
Active version
Shared Objects Example: A Simple Catalogue
Version under
construction
Writer
Reader
Reader
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 7/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 13
Shared Objects Example: A Simple Catalogue
Catalogue (area instance)
Version
out-of-date
Active version
Reader
Reader
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 14
Shared Objects Example: A Simple Catalogue
Catalogue (area instance)
Version
out-of-date
Active version
Reader
Reader Reader
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 8/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 15
Shared Objects Example: A Simple Catalogue
Catalogue (area instance)
Version
out-of-date
Active version
Reader Reader
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 16
Shared Objects Example: A Simple Catalogue
Catalogue (area instance)
Version
expired
Active version
Reader
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 9/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 17
Shared Objects Example: A Simple Catalogue
Catalogue (area instance)
Active version
Reader
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 18
Instance
Area
Root
Shared Objects - Design Time Support
An area is defined at design time withtransaction SHMA
The specified area name corresponds
to a class to be generated as a
subclass of the abstract area root
class CL_SHM_AREA: cl_my_area
The name of a root data class must be
specified (static type safety) : cl_my_root
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 10/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 19
Shared Objects – Design Time Support viaTransaction SHMA
An area is a special
class generated with
transaction SHMA
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 20
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
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 11/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 21
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 / 22
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)
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 12/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 23
Shared Objects - Monitoring Support viaTransaction 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 / 24
Monitoring Transaction SHMM
Living areas
Lock overview
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 13/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 25
DATA:
...
myShmHandle TYPE REF TO cl_my_area,
myRoot TYPE REF TO cl_my_root.
myShmHandle = cl_my_area=>attach_for_write( ).
CREATE OBJECT myRoot AREA HANDLE myShmHandle.
myRoot->name = 'My first area instance'.
APPEND wa TO myRoot->itab.
...
CREATE OBJECT oref AREA HANDLE myShmHandle.
myRoot->struc->oref = oref.
...
IF ...
myShmHandle->set_root( myRoot ).
myShmHandle->detach_commit( ).
ELSE.
myShmHandle->detach_rollback( ).
ENDIF.
Open default instance
for write
Shared Objects - Sneak Code Preview – Write Access
Create arbitray (data)
objects in shared
memory
Set root object and
commit changes
Rollback changes
Coding typically encapsulated within the loader
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 26
DATA: myShmHandle TYPE REF TO cl_my_area.
myShmHandle = cl_my_area=>attach_for_read ( ).
READ TABLE myShmHandle->root->itab
INTO wa INDEX i.
...
myShmHandle->detach( ).
Open default instance
for read
Shared Objects - Sneak Code Preview – Read Access
Access root object
components
Release lock
Coding typically encapsulated by the broker
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 14/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 27
Coming next
Activatable Checkpoints:Assertions & Breakpoints
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 28
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
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 15/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 29
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 / 30
Assertions Enforce a Valid Runtime State
Assertions enforce a valid runtime state at discrete checkpoints in an
executing system, thus enhancing reliability and maintainability
s y s t e m s
t a t e
program flow
consistent state
n o r m a l t
e r m i n a t i o n
unexpected
behaviour
s y s t e m s
t a t e
program flow
consistent state
n o r m a l t
e r m i n a t i o n
: assertion
runtime
error
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 16/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 31
Assertions Declare Developer's Intent
consistent state not clearly defined consistent state
: assertion
s y s t e m s
t a t e
program flow
Assertions declare developer's intent and provide insight into expected
system behavior, thus enhancing maintainability
s y s t e m s
t a t e
program flow
runtime error or
unexpected
behaviour
?Where did things start
going wrong
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 32
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
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 17/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 33
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 / 34
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
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 18/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 35
Multiple Activation Options for Assertions
ABAP assertions offer multiple activation options:
Application
Report x Class y Function group z
ASSERT A
ASSERT B
ASSERT C
ASSERT D
ASSERT A
ASSERT E
ASSERT F
ASSERT G
ASSERT A
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 / 36
Activating Assertions per Compilation Unit
ABAP assertions offer multiple activation options:
Application
Report x Class y Function group z
ASSERT A
ASSERT B
ASSERT C
ASSERT D
ASSERT A
ASSERT E
ASSERT F
ASSERT G
ASSERT A
1. Activate assertions for specified compilation units(as known from C/C++, Eiffel and Java)
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 19/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 37
Activating Assertions per Checkpoint Group
ABAP assertions offer multiple activation options:
Application
Report x Class y Function group z
ASSERT A
ASSERT B
ASSERT C
ASSERT D
ASSERT A
ASSERT E
ASSERT F
ASSERT G
ASSERT A
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 / 38
Activating Assertions via Activation Variants
ABAP assertions offer multiple activation options:
Application
Report x Class y Function group z
ASSERT A
ASSERT B
ASSERT C
ASSERT D
ASSERT A
ASSERT E
ASSERT F
ASSERT G
ASSERT A
3. Activate assertions from an activation variant.
Combinations of the above options can be stored as
activations variants.
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 20/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 39
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
DB
productive users
supportdedicated
support server
server specific activation
DB
...
user specific activation
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 40
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
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 21/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 41
Assertions in ABAP
Assertion behavior and maintenance scenarios:
Maintenance
Short term, interactive Long term, non-interactive
BREAK ABORT PROTOCOL
Support user, prepared to
jump into debugger
Productive user,
prepared to encountershort dump
Productive
user, nondisturbed
Support, analyzing short dumps or
monitoring assertion protocol
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 42
Activatable Breakpoints: Why and How
By using functional methods in the assert condition, alsocomplex checks can be implemented.
Nevertheless, in a business application it may not always bepossible 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-POINTstatement, which can be activated through association with acheckpoint group:
BREAK-POINT ID <checkpoint_group>.
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 22/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 43
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 / 44
Comparison with Other Languages: the ABAP Way
ABAP: On the language level comparable to Java assertions, buton 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
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 23/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 45
Coming next
Generic Programming
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 46
Generic Programming
Runtime Type Creation
Open SQL
More catchable runtime errors
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 24/37
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 25/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 49
Runtime Type Creation – Seamless Integration
Coherent with static types
Types created at runtime exactly behave like statically definedtypes 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_TYPEDESCRand its descendants
New keyword addition TYPE HANDLE with CREATE DATA(CREATE OBJECT to follow) and ASSIGN
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 50
Dynamic Types - The Type System
CL_ABAP_DATADESCR
CL_ABAP_DATADESCR
CL_ABAP_ELEMDESCR
CL_ABAP_ELEMDESCR
CL_ABAP_STRUCTDESCR
CL_ABAP_STRUCTDESCR
CL_ABAP_TABLEDESCR
CL_ABAP_TABLEDESCR
CL_ABAP_REFDESCR
CL_ABAP_REFDESCR
All data types are instances ofsubclasses of CL_ABAP_DATADESCR
CL_ABAP_TYPEDESCR
CL_ABAP_TYPEDESCR
CL_ABAP_OBJECTDESCR
CL_ABAP_OBJECTDESCR
CL_ABAP_CLASSDESCR
CL_ABAP_CLASSDESCR CL_ABAP_INTFDESCR
CL_ABAP_INTFDESCR
Pre-arrangement for dynamiccreation of classes and interfaces
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 26/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 51
Dynamic Types - Type Creation
Create a standard table of a projection of a known structure
name STRING
salaray P
city CHAR30
..... .....
phone(20) N
structure EMPLOYEE
name city .... phone
dyn. table of projection
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 / 52
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.
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.
Dynamically assign a type to a field symbol
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 27/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 53
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 supportedin dynamic WHERE clauses
Parsing dynamic SQL no up to 10x faster (50 µs instead of 500 µsper 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 timewithout warning or notice.")
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 54
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, akaABAP keyword documentation
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 28/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 55
Coming next
ABAP Objects &Class-Based Exceptions
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 56
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
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 29/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 57
Class-Based Exceptions (1)
Enhanced ST22 / ABAP short dump analysis:
Dedicated ABAP runtime error display for uncaught exceptions
(runtime error UNCAUGHT_EXCEPTION)
TRY.
DATA: xref TYPE REF TO cx_root.
CATCH
CLEANUP INTO xref.
ENDTRY.
Access to exception object in cleanup section:
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 58
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.
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 30/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 59
Coming next
Miscellaneous
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 60
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
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 31/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 61
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 / 62
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 textelements
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 32/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 63
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 / 64
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.
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 33/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 65
Pseudo Random Number Generator - Solution
Existing PRNGs at SAP have been tested thoroughly.
All of them showed significant statistical anomalies (eventhe one that was certified externally …)
Thus we implemented one of the best algorithms available, theMersenne Twister (developed in 1997 by Makoto Matsumotoand 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 dimensionof 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. Numberscan easily be outside the range after the mapping.
Range-mapping as part of the API provided.
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 66
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.
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 34/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 67
Pseudo Random Number Generator - Examples
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.
Create 100 2-tupels of type P(8) with random seed:
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 10.000 integers between 1 and 100:
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 68
Coming next
Summary
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 35/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 69
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 enhancinglibraries & tools instead of adding new keywords
Shared Objects: open new fields of ABAPprogramming: application specific caches, roll-area-transcendent contexts
Activatable Assertions: improve correctness &serviceability
Runtime Type Creation: further improve flexible anddedicated means for generic programming
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 70
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
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 36/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 71
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-onThu, 9:00:00 AM, H8
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 72
Q
Questions?
8/13/2019 ABAP Language News
http://slidepdf.com/reader/full/abap-language-news 37/37
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 73
Please complete your session evaluation and
drop it in the box on your way out.
Feedback
Thank You
The SAP TechEd ’03 Basel Team
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
Copyright 2003 SAP AG. All Rights Reserved