Sunteți pe pagina 1din 153

ABAP Language: New

Features with Relases 6.10


and 6.20
Andreas Blumenthal, SAP AG

Learning Objectives

As a result of this presentation, you will


be able to:
 Understand the direction into which ABAP has moved with its

6.10 and 6.20 developments


 Identify the areas of development in 6.10 and 6.20
 Know about some of the new ABAP features in more detail

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 2

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 3

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 4

Unicode

 What is Unicode ?
 Problems
 Principles of Unicode Enabling ABAP
 Handling
 Stricter Checks
 Unicode and List Programming
 DDIC Structure Extensions
[More details in workshop Unicode Enabling of ABAP Programs,
Tue., 4:15:00 PM - 6:15:00 PM, 391 and
Wed., 4:15:00 PM - 6:15:00 PM, 298 / 299 ]

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 5

What is Unicode ? (1)


The Unicode Home Page www.unicode.org gives the following answer:
Unicode provides a unique number for every character,
no matter what the platform,
no matter what the program,
no matter what the language.
Fundamentally, computers just deal with numbers. They store letters and other
characters by assigning a number for each one. Before Unicode was invented,
there were hundreds of different encoding systems for assigning these
numbers. No single encoding could contain enough characters: for example,
the European Union alone requires several different encodings to cover all its
languages. Even for a single language like English no single encoding was
adequate for all the letters, punctuation, and technical symbols in common use.
These encoding systems also conflict with one another. That is, two encodings
can use the same number for two different characters, or use different numbers
for the same character. Any given computer (especially servers) needs to
support many different encodings; yet whenever data is passed between
different encodings or platforms, that data always runs the risk of corruption.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 6

What is Unicode ? (2)


Unicode is changing all that!
Unicode provides a unique number for every character, no matter what the
platform, no matter what the program, no matter what the language. The
Unicode Standard has been adopted by such industry leaders as Apple, HP,
IBM, JustSystem, Microsoft, Oracle, SAP, Sun, Sybase, Unisys and many
others. Unicode is required by modern standards such as XML, Java,
ECMAScript (JavaScript), LDAP, CORBA 3.0, WML, etc., and is the official way
to implement ISO/IEC 10646. It is supported in many operating systems, all
modern browsers, and many other products. The emergence of the Unicode
Standard, and the availability of tools supporting it, are among the most
significant recent global software technology trends.
Incorporating Unicode into client-server or multi-tiered applications and
websites offers significant cost savings over the use of legacy character sets.
Unicode enables a single software product or a single website to be targeted
across multiple platforms, languages and countries without re-engineering. It
allows data to be transported through many different systems without
corruption.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 7

What is Unicode ? (3)


About the Unicode Consortium
The Unicode Consortium is a non-profit organization founded to develop,
extend and promote use of the Unicode Standard, which specifies the
representation of text in modern software products and standards. The
membership of the consortium represents a broad spectrum of corporations
and organizations in the computer and information processing industry. The
consortium is supported financially solely through membership dues.
Membership in the Unicode Consortium is open to organizations and
individuals anywhere in the world who support the Unicode Standard and wish
to assist in its extension and implementation.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 8

Problems
The character-equals-byte assumption does not hold any more:
 A character might consist of one, two, or four bytes.
 A Unicode character is represented as an integer, so byte order is
relevant (big endian vs. little endian).
 The memory layout on the byte level differs between Unicode and
non-Unicode systems, and even between different Unicode
environments.
 Character processing and byte processing can not be mixed up any
more.

Programming techniques based on memory layout assumptions


are not portable any more and might yield different results in
different environments:
 Offset/length access to structures
 Conversions and comparisons between incompatible types
 'Memory hopping' across field boundaries

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 9

Principles of Unicode Enabling ABAP


In Unicode systems, all character-type data types (C, N, D, T,
STRING) are Unicode encoded.
This provides for a far-reaching automatic Unicode enabling of
existing ABAP applications.
Unicode enabled ABAP programs are just ABAP programs that
conform to the slightly stricter Unicode checks.
A Unicode enabled ABAP program executes with identical
semantics in both Unicode and non-Unicode environments.
This means that
 one and the same ABAP program source can serve Unicode systems
as well as non-Unicode systems, and
 Unicode enabling can be done step by step in a non-Unicode system.

Unicode-enabled ABAP is the best ABAP ever !

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 10

Handling
Just set the Unicode flag for an ABAP program, i.e. turn on
"Unicode checks active" under the program attributes.
(For new programs, the Unicode flag is set by default as of release
6.10.)
The ABAP syntax checker (and occasionally the ABAP run-time
system) will then tell you which parts of a program need
adjustments.
For easy Unicode migration of large bulks of ABAP programs,
 use transaction UCCHECK for doing the compile-time related work,
and
 monitor your run-time test coverage with the coverage analyzer
(transaction SCOV).

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 11

Stricter Checks

 Offset / Length Access to Structures


 Conversions and Comparisons between Incompatible Types
 Separation of Character and Byte Processing
 Stricter Range Checks
 More Explicit Dataset Operations

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 12

Offset / Length Access to Structures


With Unicode, structures are really structures, and not field lists
that are handled like type C fields any more.
Only the character-type beginning of a structure can still be
operated on like a type C field.
The character-type beginning of a structure
 comprises all successive C, N, D, T components at the beginning of a
structure, and
 stops at the first
 numeric

component (I, P, F),


 string component (STRING, XSTRING),
 reference (REF TO someObjectType, REF TO someDataType),
 internal table component (someTableType), or
 alignment gap.

Offset/length access is now restricted to the character-type


beginning of a structure.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 13

Conversions and Comparisons between


Incompatible Types
Conversions and comparisons between incompatible structure types
are defined if and only if the Unicode fragment view of the longer
structure begins with the Unicode fragment view of the shorter one.
Helper classes for all kinds of strange conversions:
 CL_ABAP_CONV*
 CL_ABAP_VIEW_OFFLEN
 CL_ABAP_CONTAINER_UTILITIES
 CL_ABAP_CHAR_UTILITIES

The Unicode fragment view of a structure


 is a portable abstraction of the structure,
 ignores any substructuring and treats components on the leaf level,
 treats adjacent flat character-type components (C,N, D, T) and adjacent
flat byte-type components (X) as one single component,
 takes into account the different alignment gaps on 1-byte, 2-byte, and 4byte platforms.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 14

Character Type Beginning and Unicode Fragment View


DATA: BEGIN OF s1,
date TYPE d, time TYPE t, val TYPE i, x8(8) TYPE x,
END OF s1,
BEGIN OF s2,
date_time(14) TYPE c, val TYPE i, x2(2) TYPE x, x6(6) TYPE x,
END OF s2,
BEGIN OF s3,
date_time(14) TYPE c, i1 TYPE int2, i2 TYPE int2, x8(8) TYPE x,
END OF s3.
CharacterTypeBeginning(s1|s2|s3):
<f1(14) TYPE c>
CTB(s1) = CTB(s2) = CTB(s3)

UnicodeFragmentView(s1|s2):
<f1(14) TYPE c, a(2/0/0), f2 TYPE i, f3(8) TYPE x>
UnicodeFragmentView(s3):
<f1(14) TYPE c, f2 TYPE int2, f3 type int2, f3(8) TYPE x>
UFV(s1) = UFV(s2) <> UFV(s3)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 15

Separation of Character and Byte Processing


Stricter operand checks on character-type operand positions.
Stricter operand checks on numeric operand positions.
New set of language additions for processing byte sequences:
 CLEAR / CONCATENATE / FIND / REPLACE / SEARCH / SHIFT /
SPLIT IN BYTE MODE
 XSTRLEN( ) in arithmetic expressions
 BYTE-CO, BYTE-CN, BYTE-CA, BYTE-NA, BYTE-CS, BYTE-NS in
logical expressions
 DESCRIBE
FIELD f LENGTH len
DISTANCE BETWEEN f1 AND f2
IN BYTE MODE

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 16

Stricter Range Checks


No implicit field boundary violations at ASSIGN and PERFORM:
Arguments f+off not valid any more, only
 f+off(len) (with off+len <= length(f)) or
 f+off(*)

Explicit range and increment handling at ASSIGN:


 New INCREMENT variant
 New RANGE addition
 DATA: BEGIN OF s, m01 TYPE p, , m12 TYPE p, END OF s,
incr TYPE I.
FIELD-SYMBOLS: <current_month> TYPE p.
DO 12 TIMES.
ASSIGN s-m01 INCREMENT incr TO <current_month> RANGE s.
ADD 1 TO incr.
ENDDO.

Explicit range handling at


 DO VARYING, WHILE VARY
 ADD THEN UNTIL, ADD FROM TO

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 17

More Explicit Dataset Operations


see chapter " Data Interfaces: EXPORT/IMPORT, File Interface "
below

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 18

Unicode and List Programming - Problem


ABAP list programming is based on three rather strict character set and
font assumptions:
 Fonts have to be fixed-size, i.e. non-proportional
 Besides single-byte character sets, only double-byte character sets are
supported, but not arbitrary multibyte character sets
 Fonts have to be such that double-byte characters are exactly twice as wide
as single-byte characters, i.e. full-width characters, like '
' or '
' or '
' or '

', are twice as wide as half-width characters, like '1' or 'a':



CCCC

This leads to the following memory-length-proportional-to-display-length


assumption:
A fixed amount of memory, when being displayed, always eats up the same
amount of display cells, no matter what characters are stored and displayed,
i.e. a field's display length is proportional to its memory length.

This assumption does not hold for Unicode any more :


 With unicode, both full-width and half-width characters are stored in a single
character, i.e. share the same memory length, but have different display
lengths
 Therefore, for unicode, memory length and display length are not
proportional any more

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 19

Unicode and List Programming - Solution


For a C(n) field, the default output length allows for the display of n halfwidth characters or n/2 full width characters, i.e. by default character
fields are truncated if the display length exceeds the memory length.
 But, this never leads to truncation when operating on data migrated from preUnicode double-byte character sets to Unicode

Strings and character literals are displayed completely if no output length


is specified.
The display length can be controlled via explicitly specifying a output
length.
New output length specifiers (*) and (**) for dynamic length and maximal
length.
New additions DISPLAY OFFSET and MEMORY OFFSET with SET/GET
CURSOR (OFFSET alone defaults to DISPLAY OFFSET).
New helper class CL_ABAP_LIST_UTILITIES with many convenience
methods for switching back and forth between memory layout and list
layout.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 20

DDIC Structure Extensions


DDIC structures can be extended via predefined customer includes
or arbitrary appends.
Regarding manipulating structures in an ABAP program, with
Unicode it makes a big difference whether a structure is
 guaranteed to contain only character-type components,
 guaranteed to contain only 'flat' components, or
 potentially deep.

Therefore, DDIC structures can be classified with respect to their


extendibility as





not extendible at all,


extendible, but only with character-type components,
extendible, but only with 'flat' components, or
arbitrarily ('deep') extendible.

Syntax check and extended program check throw structure


extension warnings if legal extensions might break the ABAP code.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 21

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 22

ABAP Objects

 Dynamic Access
 Friends
 Enhanced Interface Handling
 Stricter Compile Time Checks for Event Handlers
 Performance
 Miscellaneous Topics
[More details in workshop Essential ABAP Objects,
Wed., 2:00:00 PM - 6:00:00 PM, 391 and
Thu., 8:15:00 AM - 12:15:00 PM, 352]

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 23

Dynamic Access
Dynamic access to - statically unknown - attributes
Analogous to dynamic method calls, in particular with regard to
the search logic:
 The static type takes priority over the dynamic type
 Private attributes of the static type hide identically named public
attributes of subclasses

Currently only possible at ASSIGN


 Variants of the standard ASSIGN statement:
 ASSIGN ref->('comp') ...
 ASSIGN

class|intf=>('comp') ...

 ASSIGN

('class|intf')=>('comp') ...

 Within dynamic ASSIGN:


 ASSIGN ('ref->comp') ...
 ASSIGN ('class|intf=>comp') ...

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 24

Dynamic Access
Dynamic ASSIGN in all cases now - not only for references but also
for structures - with enhanced search logic:
 The static type takes priority over the dynamic type
 ASSIGN variant
ASSIGN COMPONENT name OF STRUCTURE s ...
only as optimization for
CONCATENATE 's-' name INTO f.
ASSIGN (f) ...

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 25

Friends - Basic Concepts


A class can grant friendship - to whom?
 To other classes
 To other interfaces (and consequently to all classes implementing
this interface)

Friends
 Have access to all components (not only to public, but also to
protected and private ones)
 Can always generate instances, even in the case of proteced or
private instantiation

The friends relation is asymmetric and must be unilaterally


declared:
 If A grants friendship to B, that is, if B is a friend of A, this does not
necessarily mean that A is also a friend of B
 If A grants friendship to B, A must explicitly declare this relation

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 26

Friends and Inheritance


The property of an object type to be the friend of a class is passed
on (= inheritance). This means that:
 classes derived from friend classes and
 interfaces comprising friend interfaces

are also automatically friends


The property of a class to grant friendship to a specific object type
is not passed on. This means that a friend of class A is not
automatically also a friend of all subclasses of A.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 27

Friends - Syntax
Local classes:
 CLASS lcl DEFINITION FRIENDS fr1 ... frN

Global classes:
 Differentiation between local friends of the class pool and global
friends to minimize regeneration dependencies
 Local friends of the class pool:
CLASS gcl DEFINITION LOCAL FRIENDS lfr1 ... lfrN
as separate preceding statement in the include for the definition of
local types of the class pool
 Global friends:
CLASS gcl DEFINITION GLOBAL FRIENDS gfr1 ... grfN
in the actual class definition

Workaround DATA oref TYPE REF TO class %_FRIENDS


obsolete

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 28

Enhanced Interface Handling


Additional options when implementing interfaces in - local or
global - classes:
 Some or all interface methods are abstract in the class:
 ABSTRACT
 ALL

METHODS m1 ... mN

METHODS ABSTRACT

 Some or all interface methods are final in the class:


 FINAL
 ALL

METHODS m1 ... mN

METHODS FINAL

 Initial values for interface attributes:


 DATA

VALUES attr1 = val1 ... attrN = valN

 Class Builder support for all options mentioned above

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 29

Enhanced Interface Handling


If a class implements a nested interface (and thus all inner
interfaces), all interfaces - the interface included explicitly as well
as all the inner interfaces of any nesting depth - are at the same
level from the point of view of the implementing class. Using a
reference to the class, the components of inner interfaces can
therefore be accessed directly by means of interface resolution:
 CL implements IF2 which includes IF1 with component comp, and
oref is of type REF TO cl
 oref->if1~comp is a valid component access
(and a shortcut for if1->comp after if1 = oref)

The same applies if an interface includes a nested interface:


 IF includes IF2 which includes IF1 with component comp, and iref
is of type REF TO if
 iref->if1~comp is a valid component access
(and a shortcut for if1->comp after if1 = iref)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 30

Stricter Compile Time Checks for Event Handlers


True syntax check at SET HANDLER to verify that the object for
which the handler is to be registered has the event which is
handled by the handler:
 METHODS hdl FOR EVENT e OF cl|if
 SET HANDLER hdl FOR obj
 Syntax error if obj does not have the type cl or if

METHODS hdl FOR EVENT e OF cl|if now restricts the handler


hdl to objects of type cl|if even if e is actually from a superclass
of cl or from an interface included in if. The parameter sender is
typed with that special reference:
 METHODS hdl FOR EVENT e of cl|if IMPORTING sender
 Parameter sender is of type REF TO cl|if
 Syntax error if hdl is to be registered for an instance that statically
has a more generic type than cl or if

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 31

Performance
Considerable method call improvements. Example:
 Global get method for integer value: 1,8 microseconds
(on 800 MHz Pentium with optimized nUC kernel)

Considerable attribute access improvements:


 Class-specific non-public attributes can now be accessed as quickly
as local or global variables. Approximate time: 0,02 microseconds
(system environment as above)
 Approximate time for foreign public attributes:
0,07 microseconds (system environment as above)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 32

Miscellaneous Topics (1)


CALL METHOD now optional when using parenthesis-based
notation





o->m(
o->m(
o->m(
o->m(

).
4711 ).
p1 = 4711 p2 = 4712 ).
EXPORTING p1 = input IMPORTING p2 = output ).

Attribute access now also at READ ... COMPARING


Asynchronous RFC within global classes:
CALL FUNCTION func
STARTING NEW TASK taskname
CALLING method ON END OF TASK.

analogous to
CALL FUNCTION func
STARTING NEW TASK taskname
PERFORMING form ON END OF TASK.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 33

Miscellaneous Topics (2)


Static or dynamic constructor parameterization when using
CREATE OBJECT with dynamic object type specification:
Static parameterization:
CREATE OBJECT oref TYPE (class_name)EXPORTING

Dynamic parameterization:
DATA:ptab TYPE abap_parmbind_tab.
" fill ptab
CREATE OBJECT oref TYPE (class_name)PARAMETER-TABLE ptab.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 34

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 35

Object Services

 What are Object Services ?


 Redesign of the Class Actors
 Class-Based Exception Handling
 Multiple Table Mapping
 Garbage Collection
 Asynchronous Update
[More details in workshop Essential ABAP Objects,
Wed., 2:00:00 PM - 6:00:00 PM, 391 and
Thu., 8:15:00 AM - 12:15:00 PM, 352]

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 36

What are Object Services ?


Object Services provide a persistence service, i.e. (partially)
transparent object persistence for ABAP Objects classes:
 Support for persistent classes in the class builder, especially
support for defining an object-relational mapping (OR-mapping)
between instance attributes of persistent classes and database table
columns
 Generated classes ca_xxx and cb_xxx (called class agents) for each
persistent class cl_xxx
 A set of generic helper classes cl_os_*, especially
cl_os_persistency_manager

Object Services provide a transaction service, i.e. object


transactions and transaction management for managing changes
of persistent objects:
 Support for defining object transactions when maintaining
transactions (i.e. transaction codes)
 A set of generic helper classes cl_os_*, especially cl_os_transaction*

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 37

Redesign of the Class Actors


No separate state object cs_xxx required any more
Central superclass cl_os_ca_common for class actors
 Better changeability without generation being required
 Implementation in the kernel can be realized more easily

Improved enhancement options for application developers thanks


to
 'Empty' methods ext_... of class actors cb_xxx which can be
redefined in ca_xxx
 Events ... of cb_xxx, ...

Transient objects of persistent classes can also be managed

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 38

Redesign of the Class Actors (Class Diagram)

class agent

common

abstract
cl_os_ca_common

abstract
cb_xxx

class specific
(generated)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 39

managed class

cl_xxx
keys
attributes

final
ca_xxx

get_attribut/set_attribute
get_key
application methods

Class-Based Exception Handling (Classes)

Object services exceptions checked dynamically if available, which


means under CX_DYNAMIC_CHECK and not under CX_NO_CHECK

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 40

Class-Based Exception Handling (Example)


Example: Creating a flight booking
try.
my_flight = ca_os_ex_flight=>agent->get_persistent(
i_carrid = p_carrid i_connid = p_connid i_fldate = p_fldate ).
my_booking = ca_os_ex_booking=>agent->create_persistent(
i_carrid = p_carrid i_connid = p_connid
i_fldate = p_fldate i_bookid = bookid ).
my_booking->set_customid( p_custom ).
seatsocc = my_flight->get_seatsocc( ) + 1.
my_flight->set_seatsocc( seatsocc ).
commit work.
catch cx_os_db_select.
flight not found
catch cx_os_db_insert.
*
could not create booking
catch cx_os.
*
other error
*

endtry.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 41

Mapping to Multiple Tables


The attributes of a class can be derived from several tables
OID: The OID is the key of all tables
Business key: The key fields of a table involved in mapping are a
subset of the key attributes of the persistent class

Table A

CL_XXX
attributeA1
attributeAn
attributeB1
attributeBn

id(OID)
field1
fieldn

Table B
id(OID)
field1
fieldn

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 42

Table C

CL_YYY
key1 (Business Key)
key2 (Business Key)
attributeA1
attributeAn
attributeB1
attributeBn

Key1
field1
fieldn

Table D
Key1
Key2
field1
fieldn

Garbage Collection
Class actors hold strong references only to loaded objects. This
means that objects which are not loaded can be cleared by
garbage collection.
If a subsequent transaction (which is not concatenated) is started,
all objects have 'not loaded' status and can therefore be cleared.
You can use release() to remove loaded objects (provided they
have not been changed) from management and clear them.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 43

Asynchronous Update
Update modes
 OBSOLETE: Direct update (direct database operations in current WP)
- although no longer supported, it is still possible
 Local update (update in current WP through set update task local,
update result known)
 Synchronous update (update in update task, waiting for update
result) - default
 NEW: Asynchronous update (update in update task, no waiting for
update result)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 44

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 45

New Exceptions

 What are the Disadvantages of the Old Exceptions?


 What are the Advantages of the New Exceptions?
 Exceptions as Classes
 Triggering, Catching, and Propagating Exceptions
 Preventing Inconsistencies: CLEANUP
 Declaring Exceptions, Class Hierarchy
[More details in workshop Exception Handling in ABAP,
Wed., 10:30:00 AM - 12:30:00 PM, 392 and
Thu., 10:30:00 AM - 12:30:00 PM, 357]

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 46

Problem Description

What are the disadvantages of the old exceptions?


 Exceptions as simple return codes
 No deep-level catching supported
 No automatic exception propagation
 No exception grouping (except system exceptions)
 System and user exceptions are two separate worlds
METHODS m1 ... EXCEPTIONS ex1 ex2 ex3.
...
CALL METHOD o->m1 ... EXCEPTIONS ex1 = 4 ex2 = 8.
CASE sy-subrc.
WHEN 4.
... " exception handling for ex1
WHEN 8.
... " exception handling for ex2
ENDCASE.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 47

Requirements

What are the features of a good exception concept?


 Redirecting the control flow
 Transport of error-relevant information
 Strict separation of 'normal' code and handler code
 Support for creating a consistent state
 Handling exceptions at different abstract levels

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 48

Solution Path
Exceptions as objects of exception classes
 Attributes can store additional information
 Specialization of exceptions by means of inheritance
 Classification and grouping by means of inheritance
 Exceptions are globally unique

Triggering an exception
 Generating an exception object
 Propagation along the call hierarchy until the handler is found
 No handler => RABAX

Exceptions as part of the interface


 Declaration of exceptions when defining procedures
 Caller knows which exceptions occur

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 49

General Properties of Exception Classes


Prefix CX_ for exception classes
CX_ROOT root of all exception classes
Special features of exception classes:
 Predefined methods get_text( ), get_long_text( ) und
get_source_position( ) in CX_ROOT
 Predefined attributes previous, textid, and kernel_errid (for runtime
errors) in CX_ROOT
 Automatic generation of constructor method with importing
parameters for previous, textid, and any additional public attributes

Attributes should be READ_ONLY


Classes can also be local
Note
 New and old exceptions are two totally separate worlds
 But: Catchable runtime errors are mapped to exception classes

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 50

Triggering an Exception
From a conceptional point of view, triggering an exception
consists of two phases
 Generating the exception object
 Changing the control flow

Attributes are set as usual using the constructor


 For global exception classes, a constructor is generated
automatically which has all attributes as optional parameters

Exceptions can be triggered in two ways:


 By generating a new exception object
RAISE EXCEPTION TYPE cx_my_application
[ EXPORTING attr1 = value1 attr2 = ... ].

 By using an existing object


RAISE EXCEPTION someExceptionObject.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 51

Catching Exceptions
Catch exceptions in TRY blocks
Handle exceptions in CATCH blocks
DATA xref TYPE REF TO cx_root.

Monitored
section

Handler
code

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 52

TRY.
" protected code
CALL METHOD o1->m1.
CALL METHOD o1->m2.
...
CATCH cx_my_application.
... " handle exception cx_my_application
CATCH cx_root INTO xref.
... " handle other exceptions
RAISE EXCEPTION TYPE cx_some_exception
EXPORTING previous = xref.
ENDTRY.

Automatic Propagation
METHOD m1.
TRY.
CALL METHOD obj->m2.
CATCH cx_app1.
...
ENDTRY.
ENDMETHOD.

METHOD m2. " RAISING cx_app1


TRY.
CALL METHOD obj->m3.
CATCH cx_some_exc.
...
CATCH cx_other_exc.
...
ENDTRY.
ENDMETHOD.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 53

METHOD m3. " RAISING cx_app1


...
RAISE EXCEPTION TYPE cx_app1.
ENDMETHOD.

CLEANUP Clause
METHOD m1.
TRY.
CALL METHOD obj->m2.
CATCH cx_app1.
...
ENDTRY.
ENDMETHOD.
5

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 54

Solution: CLEANUP

METHOD m2. " RAISING cx_app1


TRY.
... " resource allocated
CALL METHOD obj->m3.
CATCH cx_some_exc.
...
CATCH cx_other_exc.
...
CLEANUP
... " resource freed
ENDTRY.
ENDMETHOD.
3

Problem: Inconsistent
state due to premature
termination

METHOD m3. " RAISING cx_app1


...
RAISE EXCEPTION TYPE cx_app1.
ENDMETHOD.

Rules: Syntax
TRY.
... " Statements of the protected section
CATCH cx_e1 ... cx_en [ INTO ex1 ].
... " Handling exceptions cx_e1 to cx_en
CATCH cx_f1 ... Cx_fn [ INTO ex2 ].
... " Handling exceptions cx_f1 to cx_fn
...
" Other CATCH clauses
[ CLEANUP.
... " Statements of the CLEANUP section
]
ENDTRY.

 CATCH

clauses must be sorted in ascending order

 Multiple classes allowed within one CATCH clause


 Variable of INTO addition must have a suitable type

 TRY

blocks can be nested as required

 CLEANUP

must only be exited normally

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 55

Declaring Exceptions
Exceptions as part of the signature of methods, forms, FMs
METHODS m1 IMPORTING ... EXPORTING ...
RAISING cx_app1 ... cx_appn.

Either RAISING addition or EXCEPTIONS addition


Superclasses can be specified
RAISING clause fulfills two purposes
 User can be sure that only exceptions of those classes specified in the
interface occur
 Compiler can verify wether all possible exceptions have been considered
(caught locally or specified in the RAISING clause)

But: In some cases, forced declaration or compiler verification can be a


disadvantage. This applies to exceptions that
 Can basically occur anywhere, for example, due to a resource bottleneck
(exception would have to be declared everywhere)
 Can be prevented by means of a simple test (user knows that exception
cannot occur)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 56

Class Hierarchy
Three exception categories
All exception classes are derived
from the abstract basis classes

CX_STATIC_CHECK

Interface
checked statically
by compiler and
dynamically at runtime

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 57

CX_Root
CX_Root

CX_DYNAMIC_CHECK

Interface checked
only dynamically
at runtime

CX_NO_CHECK

Not included
in the interface
check neither
statically
nor dynamically

Interface Check
Static check
 Compiler checks if exceptions that may exit the procedure have been
declared
 ToDo warning in case of violation

Dynamic check
 The system checks at runtime if the exception that wants to pass the
call interface has been declared
 Mapping to CX_SY_NO_HANDLER in case of violation

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 58

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 59

Generic Programming

 Typed Data References


 Generic Typing
 Enhancements of CREATE DATA
 Extended Dynamic Open SQL
[More details in workshops
ABAP for Power Users,
Thu., 2:00:00 PM - 6:00:00 PM, 392 and
Fri., 8:15:00 AM - 12:15:00 PM, 392
Efficient Database Programming with ABAP,
Wed., 2:00:00 PM - 6:00:00 PM, 392 and
Fri., 8:15:00 AM - 12:15:00 PM, 395]

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 60

Defining Typed Data References


Analogous to generic data references and object references
 ... REF TO object ...
 ... REF TO someObjectType ...
 ... REF TO data ...

... REF TO someDataType ...

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 61

Type Check for Typed Data References


A technical type check is made for references to elementary types
(such as REF TO i or REF TO myInt)
A conceptual type check is made (as for object references) for
references to tables and structures (aggregated types)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 62

Object and Reference Creation


Dynamic creation of data objects using
 CREATE DATA dref.
 CREATE DATA dref [TYPE|LIKE] ...

A type check is made at


GET REFERENCE OF dataObject INTO dataRef.

The check is based on the reference type of the data object from
which the reference is to be taken, and the type of the reference
variable in which the reference is to be stored.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 63

Dereferencing Typed Data References


Dereferencing will be possible at any operand position (new type of
addressing)
... ref->* ...
General reference
... ref->comp ...
Reference to structure
... ref->*->* ...
Reference to reference
... ref->*-comp ...

Reference to structure

Examples:
CLEAR: ref1->*, ref2->comp.
WRITE: ref1->*, ref2->comp.
...
Dereferencing by preceeding assignment to field symbol not necessary
any more:
ASSIGN ref->* TO <f>.
... <f> ...

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 64

Casting of Typed Data References


Upcast always permitted:
 genref = specref.
Downcast as with object references:
 specref ?= genref.
General cast only indirectly using ASSIGN CASTING:
 * Cast REF TO t2 to REF TO t1:
DATA t1ref TYPE REF TO t1.
DATA t2ref TYPE REF TO t2.
FIELD-SYMBOLS <t1> TYPE t1.
...
ASSIGN t2ref->* TO <t1> CASTING.
GET REFERENCE OF <t1> INTO t1ref.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 65

Data References and Internal Tables


Internal tables as containers: At SORT, LOOP, READ,
 component or value access for typed data references in tables of
typed data references, for example
 SORT

container BY dref->name or

 SORT

container BY table_line->* analogous to

 attribute access for object references in tables of object references,


for example
 SORT

container BY oref->name

Data references as table locators: Current line is referenced in LOOP


and READ using
 LOOP|READ ... REFERENCE INTO dref analogous to
 LOOP|READ ... ASSIGNING <f>

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 66

Generic Typing
Generic typing of formal parameters and field symbols: providing
selected predefined generic types
Important 'natural classifications':
 csequence

- c, string

 xsequence

- x, xstring

 numeric

- i, p, f (int1, int2)

Important operand checks for language elements:


 clike

- c, n, d, t, string,
UC: struct (c, n, d, t)
nUC: flat struct, xsequence
String processing operations, for example, are defined for all clike
types.
 simple
- clike, numeric, xsequence
Arithmetics and WRITE, for example, are defined for all simple types.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 67

CREATE DATA - Length and Decimal Places


Dynamic specification of length and, if required, decimal places for
incomplete elementary types - additions LENGTH and DECIMALS:
 CREATE DATA dref TYPE c

LENGTH len.

 CREATE DATA dref TYPE (tname) LENGTH len.


 CREATE DATA dref TYPE p

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 68

LENGTH len
DECIMALS dec.

CREATE DATA - Internal Tables


Generates internal tables dynamically without a table type name addition TABLE OF can be used in all variants as in DATA etc. Line
type and/or key structure can additionally be specified
dynamically:
 CREATE DATA dref TYPE TABLE OF (lineType).
 CREATE DATA dref TYPE SORTED TABLE OF struct
WITH NON-UNIQUE KEY (keyListTab).
 CREATE DATA dref TYPE HASHED TABLE OF (lineType)
WITH UNIQUE KEY (keyListTab).
 CREATE DATA dref TYPE TABLE OF i.

If there is a suitable table type available statically or dynamically,


the overhead of dynamic table type construction can be avoided as
follows (starting with 4.6):
 CREATE DATA dref TYPE itabType.
 CREATE DATA dref TYPE (itabTypeName).

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 69

Extended Dynamic Open SQL


Basically: All dynamic specifications can be made using data objects of type
 clike - that is: c, n, d, t, string, struct (c, n, d, t) - or
 TABLE OF clike

Support for host variables in dynamic WHERE clauses:


 DATA: low
TYPE msgnr VALUE '000',
high
TYPE msgnr VALUE '100',
where_clause TYPE string VALUE
`sprsl = 'D' and arbgb = 'SY' and ` &
`msgnr between low and high`.
SELECT * FROM t100 INTO TABLE msgtab WHERE (where_clause).

SELECT
 FROM clause now completely dynamic (not only table name, but also joins, ON
conditions and table aliases ...)
 Dynamic HAVING clause now with aggregate functions
 SELECT
(selectClause)
FROM
(fromClause)
INTO
...
WHERE
(whereClause)
GROUP BY (groupByClause)
HAVING
(havingClause)
ORDER BY (orderByClause)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 70

Extended Dynamic Open SQL


UPDATE SET
 Dynamic SET clause
 UPDATE dbtab SET (setClause) [WHERE ...]
 Dynamic WHERE clause
 UPDATE dbtab SET ... WHERE (whereClause)
 Dynamic table name
 UPDATE (dbtabName) SET ... [WHERE ...]

DELETE
 Dynamic WHERE clause
 DELETE FROM dbtab WHERE (whereClause)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 71

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 72

EXPORT / IMPORT

 New Media
 Controllable Compression Logic
 Controllable IMPORT Logic
 Administration Classes CL_ABAP_EXPIMP*

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 73

New Media and Controllable Compression Logic


New EXPORT/IMPORT media:
 DATA BUFFER - Main memory, variable of type xstring
 INTERNAL TABLE - Main memory, internal table with line type
<int2, x(n)>
 SHARED MEMORY - Fixed shared buffer, explicit delete required

Controllable compression logic for EXPORT:


 COMPRESSION ON|OFF
 Default:
 DATA

BUFFER, INTERNAL TABLE, MEMORY, SHARED BUFFER, SHARED


MEMORY:
 Compression off

 DATABASE:
 Compression on

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 74

Controllable IMPORT Logic (1)


ACCEPTING TRUNCATION - Truncation during import
 Shorten last C field
 Omit last C component at top level
 Implicitly allowed prior to 6.10

ACCEPTING PADDING - Padding during import


 Target fields can be larger (c, n, x, p, [i])
 C fields can be imported into C strings, X fields can be imported into
X strings
 Target structures can have additional components appended (this
also applies to row structures of target tables)
 Implicitly allowed prior to 6.10 - inversely to ACCEPTING TRUNCATION
- but with many restrictions

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 75

Controllable IMPORT Logic (2)


IGNORING STRUCTURE BOUNDARIES - Different substructurings
are identified
 Only the sequence of leaves is relevant
 Structure boundaries (substructures, named and unnamed includes)
and corresponding alignment gaps are ignored
 Cannot be combined with ACCEPTING PADDING|TRUNCATION

IGNORING CONVERSION ERRORS


 No runtime error when conversion errors occur
 Default replacement character: #

REPLACEMENT CHARACTER rc
 Choose special replacement character in connection with IGNORING
CONVERSION ERRORS

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 76

Controllable IMPORT Logic (3)


IN CHAR-TO-HEX MODE
 Character data is not converted but imported in binary format
 Allows the import of binary data disguised as character data

Code page and endian information about imported data (in


connection with CHAR-TO-HEX-MODE)
 CODE PAGE INTO cp
 ENDIAN INTO en

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 77

CL_ABAP_EXPIMP_* - Class Hierarchie (1)


cl_abap_expimp

cl_abap_expimp_mem
+get_next_level(id generic_key)
->level_tab
+get_keys(id generic_key)->keytab
+get_directory(id)->directory
+delete(id generic_key)
+delete_all()

cl_abap_expimp_shmem

cl_abap_expimp_shbuf

cl_abap_expimp_db

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 78

CL_ABAP_EXPIMP_* - Class Hierarchie (2)


cl_abap_expimp

cl_abap_expimp_shmem
cl_abap_expimp_shbuf

cl_abap_expimp_db

+get_next_level(tabname client area id


generic_key client_specified)
->level_tab
+get_keys(tabname client area id
generic_key client_specified)
->keytab
+get_directory(tabname client area id)
->directory
+delete(tabname client area id
generic_key client_specified)
+delete_all()

+get_next_level(tabname client area id


generic_key client_specified)
->level_tab
+get_keys(tabname client area id
generic_key client_specified)
->keytab
+get_directory(tabname client area id)
->directory
+delete(tabname client area id
generic_key client_specified)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 79

CL_ABAP_EXPIMP_* - Functionality
Administration is especially important for SHARED MEMORY, because
there is no automatic displacement of items that are buffered in
SHARED MEMORY !
get_keys(): return key list for a given partial sequential key
get_next_level(): return next key level (tables, clients, areas, or ids) for
a given partial sequential key
get_directory(): return directory for a given fully qualified key;
analogous to IMPORT DIRECTORY
delete(): delete for a given partial sequential key;
for a fully qualified key, equivalent to DELETE FROM
delete_all(): delete everything
generic_key: flag, indicating that trailing blanks in the last key field
supplied are to be replaced by pattern '*'
client_specified: flag, as in Open SQL, indicating explicit client
handling

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 80

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 81

File Interface

 Unicode Requirements
 Problems Caused by Old Automatisms
 Stricter Checks under Unicode
 New Additions for OPEN
 Handling Conversion Errors
 New Language Elements: SET DATASET, GET DATASET
 Conversion Classes

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 82

Unicode: The Problem


A single character is no longer represented by 1 byte, but by a 2
byte (or possibly 4 byte) integer
Differences between nUC systems and UC systems:
 Structures with C fields are no longer binary-compatible
 Different byte offsets for positioning
 Byte sequence (endian) now also relevant to characters
Alignment

Example:
nUC system:
DATA:
BEGIN OF struc,
c(3) TYPE C,
i
TYPE I,
END OF struc.

c(3)

i
Alignment

UC system:
c(3)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 83

Design Goals
Text exchange between
Application servers of a UC system
UC systems with different Unicode formats
UC systems and nUC systems

No UC/nUC query required in the application source code


UC-critical places as explicit as possible
Processing nUC files in a UC system
Cleanup of previously problematic places

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 84

Problems Caused by Automatisms


File is automatically opened in binary mode when written / read
 Errors not related to the actual
place where they occur
 Error handling becomes more
difficult
 System reads 'nonsense' data,
or output is not what the user
wants

OPEN DATASET dsn


IN TEXT MODE.

READ DATASET dsn


INTO f.

File is opened for write access despite OPEN FOR INPUT


 File may be accidentally overwritten

OPEN for files already opened changes file attributes


 It is not possible to recognize what happens from the code alone
(additions not specified have different semantics for open and
reopen)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 85

Extended Checks in Unicode Programs


File must be opened with OPEN DATASET and must not be already opened
at OPEN DATASET
New addition in text mode: ENCODING
 UTF-8: File is read and written in UTF-8
 NON-UNICODE: File is written in code page defined by current language
 DEFAULT: UTF-8 in UC system, NON-UNICODE in nUC system
 Addition is required !!!

READ/TRANSFER in TEXT MODE: Only for character-type data


 C, N, D, T, STRING, Structures with C, N, D, T
READ/TRANSFER in BINARY MODE: Only for byte-type data
 X, XSTRING
OPEN DATASET dsn FOR INPUT / OUTPUT / APPENDING opens file only
in read / write / append mode
 New addition FOR UPDATE allows read AND write access

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 86

LEGACY ... MODE


Writing and reading nUC structures in UC programs:
 OPEN DATASET dsn IN LEGACY [ TEXT | BINARY ] MODE
 Old semantics (same semantics as in nUC programs)
 UC text files are converted based on code page which is defined by
current language
 Automatic conversion between UC structures and nUC structures at
READ DATASET and TRANSFER (structure layout, code page, endian).

TRANSLATE...CODE PAGE and TRANSLATE...NUMBER FORMAT no


longer permitted in UC programs
 Functionality implemented in LEGACY...MODE using additions
 CODE PAGE cp
[

LITTLE | BIG ] ENDIAN

 or via conversion classes CL_ABAP_CONV*

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 87

Other Additions
Error handling if conversion errors occur at READ / TRANSFER
 Addition: IGNORING CONVERSION ERRORS (errors are ignored, even
SY-SUBRC at READ|TRANSFER)
 Other cases: Exception CX_SY_CONVERSION_CODEPAGE is triggered

Replacement character if a character cannot be converted:


 Addition: REPLACEMENT CHARACTER rc (default #)

Positioning within file


 Addition: AT POSITION p
 Now supports files > 2GB (specify p as type P number) (exceptions:
AS400, OS390)
 Position determination previously by adding up the data written
(causes problems in TEXT MODE !)
 Better: GET DATASET dsn POSITION pos.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 88

Handling Conversion Errors


Ignore conversion errors:
DATA: text(100) TYPE C.
OPEN DATASET dsn FOR INPUT IN TEXT MODE ENCODING NON-UNICODE
IGNORING CONVERSION ERRORS.
READ DATASET dsn INTO text.
CLOSE DATASET dsn.

Handle conversion errors:


DATA: text(100) TYPE C.
OPEN DATASET dsn FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
TRY.
READ DATASET dsn INTO text.
CATCH cx_sy_conversion_codepage.
" Can text be used?
CATCH ...
" Other read errors.
ENDTRY.
CLOSE DATASET dsn.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 89

Summary: Syntax
OPEN DATASET dsn
 Access type (required)
 FOR INPUT
 FOR

OUTPUT

 FOR

APPENDING

 FOR

UPDATE

 Mode (required)
 IN BINARY MODE
 IN

TEXT MODE ENCODING (DEFAULT|UTF-8|NON-UNICODE)

 IN

LEGACY BINARY MODE [(LITTLE|BIG ENDIAN)] [CODE PAGE cp]

 IN

LEGACY TEXT MODE [(LITTLE|BIG ENDIAN)] [CODE PAGE cp]

 Optional conversion additions


 REPLACEMENT CHARACTER rc
 IGNORING CONVERSION ERRORS

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 90

Changing File Attributes


Problem: OPEN DATASET no longer permitted for open files
Question: How can I change file attributes at runtime?
 New command: SET DATASET dsn ...
 ...

POSITION pos

 ...

REPLACEMENT CHARACTER rc

 ...

ATRRIBUTES dsetAttribChng

Question: How can I get file attributes at runtime?


 New command: GET DATASET dsn ...

 ...

POSITION pos

 ...

REPLACEMENT CHARACTER rc

 ...

ATTRIBUTES dsetAttrib

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 91

Conversion Classes
Model: Data in external formats is
 Read from a binary stream (an XSTRING)
 Written into a binary stream (an XSTRING)
Classes
 For reading and writing ABAP data
 CL_ABAP_CONV_IN_CE
 CL_ABAP_CONV_OUT_CE

 For converting data between external formats


 CL_ABAP_CONV_X2X_CE
 Further helper classes:
 CL_ABAP_CHAR_UTILITIES
 CL_ABAP_CONTAINER_UTILITIES
 CL_ABAP_VIEW_OFFLEN

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 92

Conversion Classes
Example: Writing SJIS text into a binary file
DATA: conv TYPE REF TO cl_abap_conv_out_ce,
xs
TYPE xstring.
conv = cl_abap_conv_out_ce=>create( encoding = '8000' ).
OPEN DATASET dsn FOR OUTPUT IN BINARY MODE.
LOOP AT itab INTO line.
...
conv->write( data = line ).
IF conv->position > 100000.
xs = conv->get_buffer( ).
TRANSFER xs TO dsn.
conv->reset( ).
ENDIF.
...
ENDLOOP.
CLOSE DATASET dsn.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 93

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 94

Handling ABAP Programs

 Enlarged Line Width, Source Code as String Tables


 Syntax Check Messages
 Program Property Manipulation
 Enhancements of SCAN ABAP-SOURCE
 Precompiled Headers
 Improved Where-Used List
 Separate Generation LUW

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 95

Enlarged Line Width, Source Code as String Tables


End of the punch-card format in the ABAP Editor !
Line width 255 instead of 72
Source code as string tables for all program-processing
statements:
 INSERT/READ REPORT
 SYNTAX-CHECK
 GENERATE SUBROUTINE POOL
 SCAN ABAP-SOURCE

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 96

Enlarged Line Width, Source Code as String Tables


Length and error handling in the report interface
 INSERT REPORT
 Output

parameter
 MAXIMUM WIDTH INTO width

 Exception

/ RABAX
 CX_SY_INSR_REPO_LINE_TOO_LONG
 INSERT_REPORT_LINE_TOO_LONG

 READ REPORT
 Output

parameter
 MAXIMUM WIDTH INTO width

 Exception

/ RABAX
 CX_SY_READ_REPO_LINE_TOO_LONG
 READ_REPORT_LINE_TOO_LONG

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 97

Syntax Check Messages


Accumulation of error messages
 Not for declarative statements
 Not for statements that are too complex'
 Programmed using
 SYNTAX-CHECK ID 'ERR'
 In the Workbench by means of
 Settings
 ABAP

Editor

 Editor
 Display

all syntax errors

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 98

Syntax Check Messages


Help on error messages, for example, Unicode fragment view for
structure assignment
and comparison

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 99

Syntax Check Messages

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 100

Program Property Manipulation


Set program properties at INSERT REPORT
 Default logic for Unicode flag:
 "UC

stronger than nUC"

 Special input parameters at INSERT REPORT instead of separate


MODIFY trdir:
 DIRECTORY
 PROGRAM

ENTRY trdir

TYPE subc

 FIXED-POINT
 UNICODE
 KEEPING

ARITHMETIC fxpt

FLAG uccheck

DIRECTORY ENTRY (except for version number, last


changed by and changed on)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 101

Enhancements of SCAN ABAP-SOURCE


Tokens as strings instead of C(30) plus overflow area:
token table of row type
 STOKES or STOKESX instead of
 STOKEN or STOKEX
Addition WITH COMMENTS to return comments as statements
 Successive comments are combined to one comment statement
 One comment token for each comment line
 Inserted comments precede the statement

Addition WITH LIST TOKENIZATION to break down list


expressions into single tokens

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 102

Precompiled Headers
Considerably improved performance of syntax check, generation
(tbd), and new where-used list
Semi-persistent compiler load stored in the program buffer (PXA)
for
 definition sections of global classes
 global interfaces
 type groups
 TOP includes of module pools, function groups, and reports

Particularly important for classes and interfaces (because of static


checks in ABAP Objects) as well as for type groups

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 103

Improved Where-Used List


Compiler interface for where-used list to improve where-used list
especially for all kinds of types (data types, classes, interfaces)
and type components (attributes, methods)
Performance improvements through precompiled headers

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 104

Separate Generation LUW


Separate database connection for generation
Commit after implicit generation possible without affecting the
main LUW
No pending generation locks in case of long-running main LUWs
Heuristic (timestamp comparison between start of main LUW and
last source code modification) to differentiate between programs
that
 are only used
 belong to the main LUW

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 105

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 106

Miscellaneous Topics

 Strings
 Declarations and Literals
 Control Flow and Logical Expressions
 Internal Tables
 Open SQL
 MOVE-CORRESPONDING
 List Processing
 Resource Optimizations
 Mitigating Size Restrictions
 XML Processing
 New Helper Classes
 JavaScript in ABAP

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 107

Strings
String literals:
 `some string literal

` (trailing spaces are preserved)

 'some character literal

' (trailing spaces are ignored)

Initial values for string variables, string constants:


 DATA: str1 TYPE string VALUE 'anton
',
str2 TYPE string VALUE `berta
`,
str3 TYPE string VALUE 'dagobert'.
 CONSTANTS:str4 TYPE string VALUE 'emil'.

Support for strings as columns of database tables


More efficient offset-/length-access to strings
New FIND statement (instead of SEARCH), improved REPLACE
statement

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 108

Declarations and Literals


Addition LENGTH instead of length specification in round
brackets in DATA etc.:
 DATA: name TYPE c LENGTH 72,
xbuf TYPE x LENGTH 255.
 CONSTANTS: plen TYPE i VALUE 12,
pdec TYPE i VALUE 3.
DATA:
pval TYPE p LENGTH plen DECIMALS pdec.

Deep constants, not only for strings, but also for initial (data and
object) references and for initial internal tables:
 CONSTANTS: BEGIN OF s,
f1 TYPE i
f2 TYPE c LENGTH 2
f3 TYPE string
f4 TYPE REF TO data
f5 TYPE REF TO object
f6 TYPE someItabType
f7 TYPE f
END OF s.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 109

VALUE
VALUE
VALUE
VALUE
VALUE
VALUE
VALUE

4711,
'AB'
`anton`,
IS INITIAL,
IS INITIAL,
IS INITIAL,
'3.14',

Control Flow and Logical Expressions


RETURN
 Exits a processing block immediately (procedure, event block)
 Acts like EXIT in a processing block outside all loops

IS SUPPLIED [4.6D]
 More generic version of IS REQUESTED for all optional parameters, that
is, also for optional IMPORTING parameters
 Checks at runtime whether an actual parameter has been specified for
an optional formal parameter during the call

IS BOUND
 Defined for data and object references; checks whether a reference can
be de-referenced, i.e. whether there is an accessible object bound to the
reference (analogous to IS ASSIGNED for field symbols)

Direct negation of special operators:


 NOT IN, NOT BETWEEN
 IS NOT ASSIGNED, IS NOT INITIAL
 IS NOT SUPPLIED, IS NOT REQUESTED

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 110

Internal Tables (1)


Dynamic generation without explicit table type name: CREATE
DATA with all variants of TABLE OF
(see above under Generic Programming)
Typed data reference support: Internal tables as containers and
data references as table locators
(see above under Generic Programming)
Improved object reference support
 Attribute access at READ ... COMPARING

Smaller table header (60 instead of 112 bytes with 4 byte pointers)
due to removal of
 Field symbol registration
 Old COLLECT for standard tables
 RFC handling

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 111

Key Tables and Table Sharing


Key tables
 Performance optimizations at LOOP and READ
 Key table support at
 READ/WRITE

TEXTPOOL

operator in logical expressions (IF etc., LOOP WHERE, SELECT


WHERE), i.e. range tables can be implemented as key tables

 IN

Table sharing
 Combination of value semantics with CopyOnWrite for internal
tables similar to handling strings in ABAP
 Saves space and time
 Allows functional methods to return internal tables efficiently, e.g.
get methods for containers

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 112

Open SQL
Extended dynamic SQL (see above under Generic Programming)
DELETE FROM dbtab without WHERE clause
Internal debugging
 OSQL instead of DSQL
 Breakpoint before going down one level

Strings on the database!

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 113

Dynamic MOVE-CORRESPONDING
MOVE-CORRESPONDING with dynamic operand handling:
 Untyped formal parameters and field symbols possible as operands
 Runtime error if operands are no structures at runtime

Much more expensive than static MOVE-CORRESPONDING


Cache to efficiently process dynamic MOVE-CORRESPONDING in a
loop

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 114

List Processing
Line characters on lists are combined into continuous frame
sections by default
This behaviour is controlled using
 FORMAT ... FRAMES ON|OFF
 WRITE ... FORMAT ... FRAMES ON|OFF

Default: FRAMES ON
Unicode enhancements (see above)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 115

Resource Optimizations
Performance
 Method call, attribute access (see above under ABAP Objects)
 Offset-/length-based access to strings (faster than <f>++)
 Iterative string setup (multiple CONCATENATE head tail INTO
tail) no longer involves costs in square order
 Better PXA throughput due to faster locks and smaller lock
granulates

Load size
 More compact code for FM call
 As with DDIC structures, no component CBs in the user load for
type group structures now
 More compact initial record layouts

Roll size
 Data CBs for completely typed field symbols only in the PXA and
no longer in the roll as well

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 116

Mitigating Size Restrictions


Maximum number of segments per roll area:
 Previously 32 K
 In future almost unlimited
(segment addressing up to 32 K locally in the program)

Maximum size of text literals:


 Previously 255
 In future 64 K

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 117

XML Processing (1)


Use CALL TRANSFORMATION for the transformation from XML to
ABAP and vice versa by means of XSLT programs.
CALL TRANSFORMATION trans | (name)
PARAMETERS
" pass parameters to
p1 = ap1 | (parmTab) " the XSLT program
OBJECTS
" pass object references to
o1 = ao1 | (objTab)
" the XSLT program
SOURCE
XML sxml |
" source XML
sp1 = ap1 | (srcTab) " source ABAP
RESULT
XML rxml |
" result XML
rp1 = ap1 | (resTab) " result ABAP
Handle XML data (input or output) via strings or via the appropriate
IXML interfaces (if_ixml_istream, if_ixml_node, if_ixml_ostream,
if_ixml_document).

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 118

XML Processing (2)


Predefined transformation id for mapping between arbitrary ABAP data
(possibly containing data and object references) and its canonical XML
representation, i.e. for (de-)serializing arbitrary ABAP data.
CALL TRANSFORMATION id can be used in combination with EXPORT/IMPORT
for externalizing arbitrary ABAP data.
Data objects are serialized iff they are allocated on the heap.
For instances of a class to be serializable, the class has to implement tag
interface IF_SERIALIZABLE_OBJECT.
Classes implementing IF_SERIALIZABLE_OBJECT might as well have
 a private integer constant SERIALIZABLE_CLASS_VERSION and/or
 private instance methods
 SERIALIZE_HELPER and
 DESERIALIZE_HELPER
for controlling the (de-)serialization process.

[More details in workshop XML Processing with ABAP,


Thu., 8:15:00 AM - 12:15:00 PM, 295]

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 119

New Helper Classes


CL_ABAP_EXCEPTIONAL_VALUES:
 Minimum and maximum values for predefined ABAP types:
 int_max_ref =
cl_abap_exceptional_values=>get_max_value( int ).
 float_min_ref =
cl_abap_exceptional_values=>get_min_value( float ).

CL_ABAP_TSTMP:
 Arithmetics for time stamps:
 TIMESTAMP
= 'YYYYMMDDHHMMSS'
= P<14,0> = P(8)
 TIMESTAMPL = 'YYYYMMDDHHMMSS.1234567' = P<14,7> = P(11)
 Time stamps can be subtracted from each other
 Time intervals (seconds) can be added to or subtracted from time stamps

Addition DAYLIGHT SAVING TIME dst for timestamp variants of CONVERT.


Especially useful for discriminating duplicative local times during the
'double hour' when switching back from summer to winter time:
 CONVERT TIME STAMP tst TIME ZONE tz INTO DATE d TIME t DAYLIGHT
SAVING TIME dst.
 CONVERT DATE d TIME t DAYLIGHT SAVING TIME dst INTO TIME STAMP
tst TIME ZONE tz.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 120

JavaScript in ABAP
The JS engine has been integrated into the R/3 kernel
Basis is the reference implementation of Mozilla enhanced by:
 'Data binding ' of ABAP variables
ABAP variables (including structures, tables, and objects) can be
used in JS scripts
ABAP Objects instance methods can be called
 Reentrant capability
JS scripts can be interrupted at ABAP roll-out and continued at rollin
 Debugger functionality and interface
As in the ABAP debugger you can set breakpoints in JS scripts

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 121

JavaScript in ABAP Code Examples (1)


JS runtime as ABAP class
DATA: js TYPE REF TO cl_java_script,
js_result TYPE string.
js = cl_java_script=>create( ).

Starting JS scripts with method calls


js_result = js->evaluate( 'var d=new Date(); d.toLocaleString();' ).
WRITE:
/ 'JavaScript: today is ', js_result.

Status and errors of the JS engine in class attributes


WRITE:

/ 'Last condition: ', js->last_condition_code,


/ 'Last error message: ', js->last_error_message.

___________________________________________________________________
JavaScript: today is Mon Sep 18 14:49:43 2000
Last condition:
0
Last error message:

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 122

JavaScript in ABAP Code Examples (2)


Setting and getting JS object properties
js->set( name = 'a' value = '123' ).
js->set( name = 'b' value = '2' ).
js_result = js->evaluate( 'var c = a+b' ).
js_c = js->get( 'c' ).
WRITE: / 'JS: script output: ', js_result,
/ 'JS: variable c: ', js_c.
___________________________________________________________________
JS: script output:
JS: variable c:

125
125

Byte code caching: Translate once - execute multiple times


DATA: js_src TYPE string.
. . . " Load a script in js_src ...
js->compile( script_name = 'script1', script = js_src ).
js_result_1st_run = js->execute( 'script1' ).
js_result_2nd_run = js->execute( 'script1' ).

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 123

JavaScript in ABAP Data Binding (1)


ABAP variables are linked to JS...
DATA: i1 TYPE i VALUE 13.
js->bind( name_obj = 'abap'
name_prop = 'i1'
data = i1 ).

... are used in JavaScript ...


js_result = js->evaluate( 'abap.i1 * 2' ).

... and are visible in ABAP


WRITE:
/ 'ABAP & JS data binding: 13 * 2 = ', js_result.
___________________________________________________________________
ABAP & JS data binding: 13 * 2 = 26

Calling ABAP methods from within JavaScript


js_src = 'abap.myObj.myMeth (parm1, p1, parm2, 25)'.
js_result = js->evaluate( js_src ).

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 124

JavaScript in ABAP Data Binding (2)


Elementary ABAP types are converted into JavaScript strings
 Strings can be used for 'calculations' in JavaScript
 Type conversions are prevented

ABAP structures become JavaScript objects


 Nested structures are possible
 Only end nodes can be accessed

Internal tables become JavaScript arrays


 The array property 'length' specifies the current length of the table
 Nested tables are possible

ABAP objects become JavaScript objects


 All public attributes and methods of the ABAP object can be accessed in JS
 Structure changes are prevented

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 125

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 126

Tools

 Debugger
 Code Inspector
 Coverage Analyzer
[More details and more tools in workshops
New Tools in the ABAP Workbench,
Wed., 8:15:00 AM - 12:15:00 PM, 391
Tools for Troubleshooting ABAP,
Wed., 2:00:00 PM - 6:00:00 PM, 393 and
Thu., 8:15:00 AM - 12:15:00 PM, 391
Unicode Enabling of ABAP Programs,
Tue., 4:15:00 PM - 6:15:00 PM, 391 and
Wed., 4:15:00 PM - 6:15:00 PM, 298 / 299]

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 127

ABAP Debugger (1)


'Jump to statement' function (in the 'Debugging' menu)
 Forward and backward jumps possible within the same procedure
and along the call stack
 Allows you to modify the program flow
 Debugger change authorization required
 Logging in the SysLog

Improved source code display (positioning)


 Display of current statements (CALL FUNCTION) as complete as
possible
 Statement cursor moves accordingly

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 128

ABAP Debugger (2)


Display of data references
 Content is displayed starting with '->'
 Double-clicking the data reference content displays the data object
referenced (as with object references)
 Display data object referenced by appending '->*'

Display of program properties


 Fixed point arithmetic, Unicode checks, system program

Breakpoint at method

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 129

ABAP Debugger (3)


Special display for deep data objects (tables, strings and data
references)
 Reference display by means of preceding ampersand
 Header display by means of preceding asterisk
Can also be used for watchpoints (with offset/length)
 Function for comfortable header display
 Basis and experienced ABAP developers can use these special
display options to analyze particular problems

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 130

ABAP Debugger (4)


Breakpoint management improved / simplified
 Enhanced breakpoint display
 Breakpoints are saved in a better way

Saved breakpoints are used for update debugging (in new session)
Breakpoints for HTTP debugging
 Enabling debugging in transaction SICF

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 131

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 132

Code Inspector
Static analysis of TADIR objects, in particular ABAP programs and DDIC
objects
Better infrastructure than existing transaction SAMT
Could replace SLIN in the medium term
Different aspects:

Security

Performance

Statistics
Maintainability,
error resiliency

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 133

Code Inspector: Examples


Performance





SELECT * FROM dbtab WHERE ... without adequate index


SELECT which ignores the buffer when reading buffered tables
ALV parameter i_buffer_active set?
...

Error resiliency
 Query of SY-SUBRC missing
 ...CLIENT SPECIFIED without field of type CLNT in WHERE cond.
 ...

Security
 Access to certain DB tables
 ..CLIENT SPECIFIED usage
 ...

Statistics
 Usage of obsolete language elements
 ...

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 134

Code Inspector: Inspection

Inspection

Apply check
variant to
object set

Check variant
SLIN
Performance
DB commands
Check_x
Check_y
.
.

Result

Nested loops
.
.

ABC

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 135

Object set
Programs
....................
Function groups
....................
Classes
Interfaces
....................
DDIC objects
....................
Other?
....................

Code Inspector: Inspection


Inspection consists of
object set and check
variant
These are maintained
and managed
independently
For a 'quick inspection'
it is sufficient to
specify an object

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 136

Code Inspector: Check Variant


You set up a
check variant by
clicking on single
checks
Checks can have
parameters

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 137

Code Inspector: Check and Technical View


Class hierarchy of 'segments' (scanner/parser)
(Program) object read only once for all checks
Check can initiate required segmentation

CL_CI_TEST_ROOT

CL_CI_TEST_INCLUDE

Reads ABAP source code


into internal table

CL_CI_TEST_SCAN

Executes SCAN ABAPSOURCE

CL_CI_TEST_SELECT

Reads SELECT
statements into internal
table

CL_CI_TEST_WHERE

Performs check
(analysis of WHERE condition)

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 138

Code Inspector: Object Set


Object set is
generated
 By selection
(TADIR/
TRDIR
object)
 By
extraction /
filtering
from other
object sets
 From the
result of an
inspection

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 139

Code Inspector: Problems

Source code analysis using SCAN ABAP-SOURCE


(no syntax tree available)
-> no 100% results

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 140

Agenda

 Unicode
 ABAP Objects and Object Services
 New Exceptions
 Generic Programming
 Data Interfaces: EXPORT/IMPORT,
File Interface

 Handling ABAP Programs


 Miscellaneous Topics
 Tools: Debugger, Code Inspector,
Coverage Analyzer

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 141

ABAP Coverage Analyzer


Previous releases lacked a tool to persistently record on a systemwide basis which ABAP code is run through during tests and during
development. Such a tool is here now:

Coverage Analyzer (TA scov)

Program places monitored:

- Processing blocks

Information collected:

- Number of calls
- Number of runtime errors
- Number of program changes

Tool used for the first time in 5.0 for Unicode conversion

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 142

Target Group 1: Developers


Developers currently do not know which parts of their programs
are used how often and which parts are not used at all
The information provided by the Coverage Analyzer helps them to:
 Fully test their programs
 Detect 'dead' code
 Optimize performance for program sections called frequently
 Optimize load size by transferring normally unused functions into
separate modules
 ...

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 143

Coverage Analyzer: Detail View

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 144

Target Group 2: Quality Management


The quality management team currently cannot evaluate the
success of test activities
Using the Coverage Analyzer they can now determine:
 The percentage of the code run through in the current version
 The percentage of the code never run through before
 The usage degree of compilation units
 ...

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 145

Coverage Analyzer: Global View

Gelaufen seit Start

In der aktuellen
Version gelaufen

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 146

Summary

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 147

ABAP is alive !

There are a lot of new features to be


discovered in releases 6.10 and 6.20 !

As a programming language, ABAP


is almost complete with 6.10/6.20 !

Even better tool support and more


power user programming features
are in the pipeline for upcoming
releases !

Further Information / 1


Related Workshop at TechEd 2002


Essential ABAP Objects,
Wed., 2:00:00 PM - 6:00:00 PM, 391 and
Thu., 8:15:00 AM - 12:15:00 PM, 352
New Tools in the ABAP Workbench,
Wed., 8:15:00 AM - 12:15:00 PM, 391
Exception Handling in ABAP,
Wed., 10:30:00 AM - 12:30:00 PM, 392 and
Thu., 10:30:00 AM - 12:30:00 PM, 357
Unicode Enabling of ABAP Programs,
Tue., 4:15:00 PM - 6:15:00 PM, 391 and
Wed., 4:15:00 PM - 6:15:00 PM, 298 / 299
Traps and Pitfalls in ABAP,
Tue., 1:45:00 PM - 3:45:00 PM, 391
Fri., 10:30:00 AM - 12:30:00 PM, 357
Tools for Troubleshooting ABAP,
Wed., 2:00:00 PM - 6:00:00 PM, 393 and
Thu., 8:15:00 AM - 12:15:00 PM, 391

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 148

Further Information / 2


Related Workshop at TechEd 2002


Efficient Database Programming with ABAP,
Wed., 2:00:00 PM - 6:00:00 PM, 392 and
Fri., 8:15:00 AM - 12:15:00 PM, 395
XML Processing with ABAP,
Thu., 8:15:00 AM - 12:15:00 PM, 295
ABAP for Power Users,
Thu., 2:00:00 PM - 6:00:00 PM, 392 and
Fri., 8:15:00 AM - 12:15:00 PM, 392
Shared Memory Programming with ABAP,
Wed., 8:00:00 AM - 10:00:00 AM, 392
Fri., 10:30:00 AM - 12:30:00 PM, 292

Related Lectures at TechEd 2002


ABAP Workbench News,
Tue., 4:15:00 PM - 5:15:00 PM, 383 / 384 / 385
Thu., 9:00:00 AM - 10:00:00 AM, 388 / 389 / 390

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 149

Questions?

Q&A

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 150

Feedback

Please complete your session


evaluation and drop it in the box on
your way out.
Be courteous deposit your trash,
and do not take the handouts for the
following session.

The SAP TechEd 02 New Orleans Team

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 151

Copyright 2002 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, SAP Logo, R/2, R/3, mySAP, mySAP.com 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 trademarks of their respective
companies.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 152

Copyright 2002 SAP AG. Alle Rechte vorbehalten


 Weitergabe und Vervielfltigung dieser Publikation oder von Teilen daraus sind, zu welchem Zweck und in welcher
Form auch immer, ohne die ausdrckliche schriftliche Genehmigung durch SAP AG nicht gestattet. In dieser
Publikation enthaltene Informationen knnen ohne vorherige Ankndigung gendert werden.

 Die von SAP AG oder deren Vertriebsfirmen angebotenen Softwareprodukte knnen Softwarekomponenten auch
anderer Softwarehersteller enthalten.

 Microsoft, WINDOWS, NT, EXCEL, Word, PowerPoint und SQL Server sind eingetragene Marken der
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
und Informix Dynamic ServerTM sind Marken der IBM Corporation in den USA und/oder anderen Lndern.

 ORACLE ist eine eingetragene Marke der ORACLE Corporation.


 UNIX, X/Open, OSF/1 und Motif sind eingetragene Marken der Open Group.
 Citrix, das Citrix-Logo, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, MultiWin und
andere hier erwhnte Namen von Citrix-Produkten sind Marken von Citrix Systems, Inc.

 HTML, DHTML, XML, XHTML sind Marken oder eingetragene Marken des W3C, World Wide Web Consortium,
Massachusetts Institute of Technology.

 JAVA ist eine eingetragene Marke der Sun Microsystems, Inc.


 JAVASCRIPT ist eine eingetragene Marke der Sun Microsystems, Inc., verwendet unter der Lizenz der von
Netscape entwickelten und implementierten Technologie.

 MarketSet und Enterprise Buyer sind gemeinsame Marken von SAP AG und Commerce One.
 SAP, SAP Logo, R/2, R/3, mySAP, mySAP.com und weitere im Text erwhnte SAP-Produkte und -Dienst-leistungen
sowie die entsprechenden Logos sind Marken oder eingetragene Marken der SAP AG in Deutschland und anderen
Lndern weltweit. Alle anderen Namen von Produkten und Dienstleistungen sind Marken der jeweiligen Firmen.

2002 SAP Labs, LLC, ABAP202, Andreas Blumenthal 153

S-ar putea să vă placă și