Documente Academic
Documente Profesional
Documente Cultură
Learning Objectives
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
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 ]
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.
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).
Stricter Checks
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)
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
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]
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
class|intf=>('comp') ...
ASSIGN
('class|intf')=>('comp') ...
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) ...
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
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
METHODS m1 ... mN
METHODS ABSTRACT
METHODS m1 ... mN
METHODS FINAL
Performance
Considerable method call improvements. Example:
Global get method for integer value: 1,8 microseconds
(on 800 MHz Pentium with optimized nUC kernel)
o->m(
o->m(
o->m(
o->m(
).
4711 ).
p1 = 4711 p2 = 4712 ).
EXPORTING p1 = input IMPORTING p2 = output ).
analogous to
CALL FUNCTION func
STARTING NEW TASK taskname
PERFORMING form ON END OF TASK.
Dynamic parameterization:
DATA:ptab TYPE abap_parmbind_tab.
" fill ptab
CREATE OBJECT oref TYPE (class_name)PARAMETER-TABLE ptab.
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
Object Services
class agent
common
abstract
cl_os_ca_common
abstract
cb_xxx
class specific
(generated)
managed class
cl_xxx
keys
attributes
final
ca_xxx
get_attribut/set_attribute
get_key
application methods
endtry.
Table A
CL_XXX
attributeA1
attributeAn
attributeB1
attributeBn
id(OID)
field1
fieldn
Table B
id(OID)
field1
fieldn
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.
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)
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
New Exceptions
Problem Description
Requirements
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
Triggering an Exception
From a conceptional point of view, triggering an exception
consists of two phases
Generating the exception object
Changing the control flow
Catching Exceptions
Catch exceptions in TRY blocks
Handle exceptions in CATCH blocks
DATA xref TYPE REF TO cx_root.
Monitored
section
Handler
code
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.
CLEANUP Clause
METHOD m1.
TRY.
CALL METHOD obj->m2.
CATCH cx_app1.
...
ENDTRY.
ENDMETHOD.
5
Solution: CLEANUP
Problem: Inconsistent
state due to premature
termination
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
TRY
CLEANUP
Declaring Exceptions
Exceptions as part of the signature of methods, forms, FMs
METHODS m1 IMPORTING ... EXPORTING ...
RAISING cx_app1 ... cx_appn.
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
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
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
Generic Programming
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.
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> ...
container BY dref->name or
SORT
container BY oref->name
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)
- 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.
LENGTH len.
LENGTH len
DECIMALS dec.
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)
DELETE
Dynamic WHERE clause
DELETE FROM dbtab WHERE (whereClause)
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
EXPORT / IMPORT
New Media
Controllable Compression Logic
Controllable IMPORT Logic
Administration Classes CL_ABAP_EXPIMP*
DATABASE:
Compression on
REPLACEMENT CHARACTER rc
Choose special replacement character in connection with IGNORING
CONVERSION ERRORS
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
cl_abap_expimp_shmem
cl_abap_expimp_shbuf
cl_abap_expimp_db
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
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
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
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)
Design Goals
Text exchange between
Application servers of a UC system
UC systems with different Unicode formats
UC systems and nUC systems
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
Summary: Syntax
OPEN DATASET dsn
Access type (required)
FOR INPUT
FOR
OUTPUT
FOR
APPENDING
FOR
UPDATE
Mode (required)
IN BINARY MODE
IN
IN
IN
POSITION pos
...
REPLACEMENT CHARACTER rc
...
ATRRIBUTES dsetAttribChng
...
POSITION pos
...
REPLACEMENT CHARACTER rc
...
ATTRIBUTES dsetAttrib
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
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.
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
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
Editor
Editor
Display
ENTRY trdir
TYPE subc
FIXED-POINT
UNICODE
KEEPING
ARITHMETIC fxpt
FLAG uccheck
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
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
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
Strings
String literals:
`some string literal
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.
VALUE
VALUE
VALUE
VALUE
VALUE
VALUE
VALUE
4711,
'AB'
`anton`,
IS INITIAL,
IS INITIAL,
IS INITIAL,
'3.14',
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)
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
TEXTPOOL
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
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
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
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)
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
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
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
___________________________________________________________________
JavaScript: today is Mon Sep 18 14:49:43 2000
Last condition:
0
Last error message:
125
125
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
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]
Breakpoint at method
Saved breakpoints are used for update debugging (in new session)
Breakpoints for HTTP debugging
Enabling debugging in transaction SICF
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
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
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
...
Inspection
Apply check
variant to
object set
Check variant
SLIN
Performance
DB commands
Check_x
Check_y
.
.
Result
Nested loops
.
.
ABC
Object set
Programs
....................
Function groups
....................
Classes
Interfaces
....................
DDIC objects
....................
Other?
....................
CL_CI_TEST_ROOT
CL_CI_TEST_INCLUDE
CL_CI_TEST_SCAN
CL_CI_TEST_SELECT
Reads SELECT
statements into internal
table
CL_CI_TEST_WHERE
Performs check
(analysis of WHERE condition)
Agenda
Unicode
ABAP Objects and Object Services
New Exceptions
Generic Programming
Data Interfaces: EXPORT/IMPORT,
File Interface
- 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
In der aktuellen
Version gelaufen
Summary
ABAP is alive !
Further Information / 1
Further Information / 2
Questions?
Q&A
Feedback
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.
HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C, World Wide Web Consortium,
Massachusetts Institute of Technology.
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.
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.
HTML, DHTML, XML, XHTML sind Marken oder eingetragene Marken des W3C, World Wide Web Consortium,
Massachusetts Institute of Technology.
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.