Professional Documents
Culture Documents
ABAP Language
News
Andreas Blumenthal
VP ABAP Server Technology & I18N
SAP AG
Learning Objectives
Agenda
Shared Objects
Activatable Checkpoints:
Assertions & Breakpoints
Generic Programming
Miscellaneous
Summary
Coming next
Shared Objects
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
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
Active version
Reader
Reader
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 11
Reader
Reader Writer
Reader
Reader
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 13
Reader
Reader Reader
Reader
Reader
Reader
Active version
Reader
Instance
The name of a root data class must be
Root: cl_my_root
specified (static type safety)
An area is a special
class generated with
transaction SHMA
Dynamic properties
Changes apply to new area instance versions only, but still require
developer’s rights
Current readers or changers are not interrupted
Dynamic properties:
Loader class
Displacement (off, on, w/ serialization)
Living areas
Lock overview
DATA:
...
Open default instance
myShmHandle TYPE REF TO cl_my_area, for write
myRoot TYPE REF TO cl_my_root.
DATA:
Open default instance
myShmHandle TYPE REF TO cl_my_area.
for read
myShmHandle = cl_my_area=>attach_for_read( ).
Access root object
components
myShmHandle->detach( ).
Coming next
Activatable Checkpoints:
Assertions & Breakpoints
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
An assertion is
Basic syntax:
ASSERT <logical_expression>.
Advanced syntax:
ASSERT ID <checkpoint_group>
CONDITION <logical_expression>.
unexpected
: assertion
behaviour
system state
system state
runtime
normal termination
normal termination
error
runtime error or
unexpected
behaviour : assertion
system state
system state
?
Where did things start
going wrong
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
...
DB
DB
dedicated
support
support server
Assertions in ABAP
Maintenance
BREAK-POINT ID <checkpoint_group>.
Coming next
Generic Programming
Generic Programming
Open SQL
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
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)
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
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 ).
Open SQL
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.")
Coming next
Handling improvements:
New functionality:
Kernel Methods
SAP AG 2003, TechED_Basel / ABAP203, Andreas Blumenthal / 56
Coming next
Miscellaneous
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
New Tools
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
DO 10000 TIMES.
number = prng->get_next( ).
…
ENDDO.
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.
Coming next
Summary
Summary
Further Information
Further Information
Questions?
Q&A
Feedback
Thank You !
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.