An Overview of the New Features in ABAP
© SAP AG 2006, SAP TechEd ’06 / CD200 / 2
Agenda
Horst KellerKnowledge Architect, SAP AG
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
© SAP AG 2006, SAP TechEd ’06 / CD200 / 5
Learning Objectives
As a result of this lecture, you will have an overview
of many of the new ABAP features available with SAP NetWeaver 04 and SAP NetWeaver 2004sof the new ABAP features coming with the follow-up release
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
© SAP AG 2006, SAP TechEd ’06 / CD200 / 7
Regular Expressions (Regexes, REs) are more powerful than traditional SAP patterns (SEARCH txt FOR pat, IF txt CP pat)
Well understood– Developed by mathematician Kleene in the 1950s
Powerful– Highly focused special purpose language– Many common text processing tasks turn into
simple one-liners
Standardized and widely used– Made popular by Unix tools: grep, sed, awk, emacs– Built into some languages like Perl and Java;
add-on libraries available for many others– Early Unix de-facto standard formalized in PCRE and POSIX
ABAP supports POSIX regular expressions as of Release 7.00
Improved Text Processing With REs
Stephen C. KleeneImage © U. of Wisconsin
© SAP AG 2006, SAP TechEd ’06 / CD200 / 8
Regular Expression Terminology
Regular expressions are built fromLiterals
Special operators (metacharacters)
Prepending \ turns operators into literals
REs match or represent sets of text stringsRE matches text if complete text is represented by RE
REs are commonly used for searching textText to be searched may contain one or more matchesUsually interested in left-most, longest match contained in text
a b c 1 2 3 ä à ß , / = …
. * + ? \ ^ $ ( ) [ ] { }
Match
Search
© SAP AG 2006, SAP TechEd ’06 / CD200 / 9
Regular Expressions Quick Check
What is the main difference betweens file system wildcardslike *.jpg and regular expressions?
How are SAP patterns
written as regular expressions?
pat pat+ *pat p#*t
pat pat. .*pat p\*t
files: * = sequence of charactersREs: * = general repetition, requires specification
of what should be repeated;sequence of characters becomes .*
© SAP AG 2006, SAP TechEd ’06 / CD200 / 10
Regex Reference Chart (1)
Name Operator MatchesLiterals a
\*literal characterturn special operator * into literal character *
Sets [abc][^abc][a-z]
any literal character listedany literal character NOT listedany literal character within range listed (can be combined with above)
Classes(to be used within sets)
[:alpha:][:digit:] [:xdigit:] [:alnum:] [:word:][:upper:] [:lower:][:space:] [:blank:][:punct:] [:graph:][:print:] [:cntrl:][:unicode:]
any letter, including non-latin alphabets any digit 0-9/hex digit 0-9A-F[:alpha:] plus [:digit:]/same plus '_' characterany uppercase/lowercase characterany whitespace character/blank or horizontal tabany punctuation/graphical characterany printable/control code characterany Unicode character above ASCII 255
Wildcard . any characterRepetitions r*
r+r{m}r{m,n}r?
zero or more repetitions of rone of more repetitions of rexactly m repetitions of rat least m and at most n repetitions of roptional r, i.e., zero or one repetition of r
Alternatives r|s either r or s
© SAP AG 2006, SAP TechEd ’06 / CD200 / 11
Regex Reference Chart (2)
Name Operator MatchesAbbreviations \n \t \a
\w \W \d \D\s \S\u \U\l \L
newline/tab/bell characterequivalent to [[:word:]] and [^[:word:]] equivalent to [[:digit:]] and [^[:digit:]]equivalent to [[:space:]] and [^[:space:]] equivalent to [[:upper:]] and [^[:upper:]]equivalent to [[:lower:]] and [^[:lower:]]
Quote \Q … \E interpret quoted sequence as literal characters
Anchors \A \z^ $\< \>\b\B
begin and end of buffer (i.e., text to search)begin and end of line (buffer separated into lines by \n chars)begin and end of wordeither begin or end of wordinside of a word, i.e., between two \w's
Back references ( )\1 \2 \3 …(?: )
group subexpression and save submatch into registermatches contents of n-th registergroup subexpression, but do not store in register
Look-ahead r(?=s)r(?!s)
matches r iff r is followed by smatches r iff r is NOT followed by s
Cuts (?>r) do not backtrack for left-most longest match once r has matched
© SAP AG 2006, SAP TechEd ’06 / CD200 / 12
Searching for Matches with FIND
New addition REGEX to the FIND statement:
Detailed match information is available with RESULTS addition.
FIND returns left-most longest match within text.
FIND[{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF] REGEX regxIN text [{RESPECTING|IGNORING} CASE][MATCH COUNT mcnt][RESULTS result_tab].
© SAP AG 2006, SAP TechEd ’06 / CD200 / 13
Replacing Matches with REPLACE
New addition REGEX to the REPLACE statement:
Search works exactly as in FIND.
REPLACE[{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF] REGEX regxIN text WITH repl[{RESPECTING|IGNORING} CASE][REPLACEMENT COUNT mcnt][RESULTS result_tab].
© SAP AG 2006, SAP TechEd ’06 / CD200 / 14
Grouping and Submatches
Parentheses structure complex expressionsDefine scope of operators
Store submatches for later reference– Submatches easily available with FIND additions– Groups numbered left-to-right, can be nested– No upper limit on number of groups– Can refer to submatches within pattern and replacement
Non-registering parentheses (?:…) do not store submatch
– Increased performance over ( )
tick*tock* (tick)*(tock)* (ticktock)*
(?:tick)*(?:tock)*
veryuseful
© SAP AG 2006, SAP TechEd ’06 / CD200 / 15
Example: Match-Based Replacements
The replacement string can refer to submatches of match being replaced
$0 contains complete match$1,$2, ... contain submatches
Result:
DATA: html TYPE string,repl TYPE string,regx TYPE string.
html = `<title>This is the <i>Title</i></title>`.
repl = `i`.CONCATENATE repl '(?![^<>]*>)' INTO regx.
REPLACE ALL OCCURRENCES OF REGEX regx IN html WITH <b>$0</b>`.
<title>Th<b>i</b>s <b>i</b>s the <i>T<b>i</b>tle</i></title>
© SAP AG 2006, SAP TechEd ’06 / CD200 / 16
Classes for Regular Expressions
ABAP Objects provides two classes for using REsRegex CL_ABAP_REGEX– Stores compiled automaton for RE pattern– Should be reused to avoid costly recompilation– Offers simplified syntax and disabling of
submatches– Can be used in FIND and REPLACE statements
instead of textual pattern
Matcher CL_ABAP_MATCHER– Main class for interaction with REs– Stores copy of text to process (efficient for
strings, costly for fixed-length fields)– Links text to regex object and tracks matching
and replacing within text
CL_ABAP_MATCHER
$0_________
CL_ABAP_REGEX
a*b
© SAP AG 2006, SAP TechEd ’06 / CD200 / 17
Matcher Class Reference Chart (1)
CL_ABAP_MATCHER Instance Methods
find_next( ) find next unprocessed match
replace_found( new ) replace match found by new *)
get_match( ) return match information (MATCH_RESULT) *)
get_offset( [n] ) return offset of current (sub)match *)
replace_all( new ) replace all remaining matches
get_submatch( n ) return n-th submatch *)
get_length( [n] ) return length of current (sub)match *)
find_all( ) return all remaining matches
replace_next ( new ) find and replace next unprocessed match
*) throws exception if no current match stored
© SAP AG 2006, SAP TechEd ’06 / CD200 / 18
Matcher Class Reference Chart (2)
CL_ABAP_MATCHER Class Methods
create( pattern text ) create and return matcher object
matches( pattern text ) returns abap_true if pattern matches text
contains( pattern text ) returns abap_true if text contains pattern match
get_object( ) returns matcher object containing match information about last matches( ) or contains( ) invocation
© SAP AG 2006, SAP TechEd ’06 / CD200 / 19
Creating Regex Objects
There are two ways of setting up objects for RE processing
Using CREATE
Using factory method
CREATE OBJECT regex EXPORTING pattern = '^a*'ignore_case = abap_true.
CREATE OBJECT matcher EXPORTING regex = regextext = text.
DATA: regex TYPE REF TO cl_abap_regex,matcher TYPE REF TO cl_abap_matcher.
matcher = cl_abap_matcher=>create( pattern = '^a*'text = text ).
© SAP AG 2006, SAP TechEd ’06 / CD200 / 20
Example: Pattern Matching
Checking the format of an Email address:
PARAMETERS email TYPE c LENGTH 30 LOWER CASEdefault '[email protected]'.
DATA matcher TYPE REF TO cl_abap_matcher.
matcher = cl_abap_matcher=>create(pattern = `\w+(\.\w+)*@(\w+\.)+(\w{2,4})`ignore_case = 'X'text = email ).
IF matcher->match( )IS INITIAL.MESSAGE 'Wrong Format' TYPE 'I'.
ELSE.MESSAGE 'Format OK' TYPE 'I'.
ENDIF.
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
© SAP AG 2006, SAP TechEd ’06 / CD200 / 22
Data Access without Buffering
DB
User XSession
© SAP AG 2006, SAP TechEd ’06 / CD200 / 23
Data Access with Buffering by Copy
Common dataretrieved from DB
User XSession
CommonData
DB
© SAP AG 2006, SAP TechEd ’06 / CD200 / 24
Data Access without Buffering
Common dataretrieved from DB andaggregated
User XSession
DB
© SAP AG 2006, SAP TechEd ’06 / CD200 / 25
Data Access without Buffering
User YSession
CommonData
User XSession
CommonData
DB
Common dataretrieved from DB andaggregated foreach user session
User ZSession
CommonData
CommonData
CommonData
© SAP AG 2006, SAP TechEd ’06 / CD200 / 26
Data Access with Buffering by Copy
DB
User XSession
© SAP AG 2006, SAP TechEd ’06 / CD200 / 27
Data Access with Buffering by Copy
Common dataretrieved from DB
User XSession
CommonData
DB
© SAP AG 2006, SAP TechEd ’06 / CD200 / 28
Data Access with Buffering by Copy
Common dataretrieved from DB,aggregated
User XSession
DB
© SAP AG 2006, SAP TechEd ’06 / CD200 / 29
Data Access with Buffering by Copy
Common dataretrieved from DB,aggregated,copied (EXPORT) to SHM
User XSession
CommonData
DB
Shared Memory (SHM)Common
Data
© SAP AG 2006, SAP TechEd ’06 / CD200 / 30
Data Access with Buffering by Copy
User XSession
CommonData
DB
Common dataretrieved from DB,aggregated,copied (EXPORT) to SHM,and copied (IMPORT) toeach user session
Shared Memory (SHM)Common
Data
User YSession
CommonData
User ZSession
CommonData
© SAP AG 2006, SAP TechEd ’06 / CD200 / 31
Data Access with in Place Buffering
Common dataretrieved from DBdirectly into SHM
User XSession
DB
Shared Memory (SHM)Common
Data
© SAP AG 2006, SAP TechEd ’06 / CD200 / 32
Data Access with in Place Buffering
Common dataretrieved from DBdirectly into SHM,aggregated in place
DB
Shared Memory (SHM)Common
Data
User XSession
© SAP AG 2006, SAP TechEd ’06 / CD200 / 33
Data Access with in Place Buffering
User XSession
DB
Common dataretrieved from DBdirectly into SHM,aggregated in placeaccessed copy-free byother user sessions
Shared Memory (SHM)Common
Data
User YSession
User ZSession
© SAP AG 2006, SAP TechEd ’06 / CD200 / 34
Areas and Area Instances
Shared Objects memoryPart of the shared memory
Shared Objects areasOrganizational unitsDefined at design time
Shared Objects area instancesContent stored at runtimeIdentified by unique name
Shared Memory
Area AreaInstance
Instance
Instance
Shared Objects Memory
© SAP AG 2006, SAP TechEd ’06 / CD200 / 35
Working with Area Instances
InstanceAttach for write
RootFill the contents
© SAP AG 2006, SAP TechEd ’06 / CD200 / 36
Working with Area Instances
Attach for write Instance
RootFill the contentsCommit changes
© SAP AG 2006, SAP TechEd ’06 / CD200 / 37
Working with Area Instances
Attach for write Instance
RootFill the contentsCommit changes
Attach Reader1
© SAP AG 2006, SAP TechEd ’06 / CD200 / 38
Working with Area Instances
Attach for write Instance
RootFill the contentsCommit changes
Attach Reader1
Attach Reader2
© SAP AG 2006, SAP TechEd ’06 / CD200 / 39
Working with Area Instances
Attach for write Instance
RootFill the contentsCommit changes
Attach Reader1
Attach Reader2
Detach Reader1
© SAP AG 2006, SAP TechEd ’06 / CD200 / 40
Working with Area Instances
Attach for write Instance
RootFill the contentsCommit changes
Attach Reader1
Attach Reader2
Detach Reader1
Detach Reader2
© SAP AG 2006, SAP TechEd ’06 / CD200 / 41
Additional Features
Versioning
Auto-Build (e.g. at 1st Read-Attach)
Transactionality
Propagation
Client Dependency
Displacement
Customizable Memory- and Lifetime Restrictions
Multi-Attach to different areas at once
Shared Objects Monitor
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
© SAP AG 2006, SAP TechEd ’06 / CD200 / 43
ABAP / XML Mapping: Simple Transformations
ABAP Data
… .. ….…. … ..
.. …. …. ..… …. .. ..
XML Doc
XSLT
… .. ….…. … ..
.. …. …. ..
HTML / Text
XSLT
XSLTSimpleTransformations
DB
Network
XSLT
XSLT
new in
NetWeaver
04
© SAP AG 2006, SAP TechEd ’06 / CD200 / 44
ABAP / XML Mapping Languages
XSLT (since 6.10)works on canonical XML representation of ABAP data (asXML)builds DOM for source sidearbitrarily complex transformations
Simple Transformations (since NetWeaver 04)only for ABAP ↔ XMLonly linear transformations (no DOM)speedup over XSLT: 10 – 30; “unlimited” size of datareversible (one program for both directions)
Bothsymmetric: no generation of ABAP code / XML schemasintegrated in workbench (maintenance / transport)integrated in ABAP: CALL TRANSFORMATION
© SAP AG 2006, SAP TechEd ’06 / CD200 / 45
Simple Transformations: Expressive Power
Anything that can be done with ...accessing each node in the data treeany number of timesaccessing each node in the XML treeat most once,in document order (with "lookahead 1" on XML source)
... which includes (any combination of) ...renamings (e.g.: structure-component / element names)projections (omission of sub-trees)permutations (changes in sub-tree order)constants (e.g.: constant values, insertion of tree levels)defaults (for initial / special values)conditionals (e.g.: existence of sub-trees, value of nodes)value maps
covers most data mappings in practice
© SAP AG 2006, SAP TechEd ’06 / CD200 / 46
Simple Transformations: Program Structure
Programs are XML templatesliteral XML withinterspersed instructionsdeclarative, straightforward semantics
Data tree access bynode references
instructions access data by simple “reference expressions”all named children of a data node are accessible by nametables are accessible as a whole (all lines or none)
<Customers>
<tt:loop ref="CUSTTAB">
<LastName>
<tt:value ref=
"NAME.LAST"/>
</LastName>
</tt:loop>
</Customers>
© SAP AG 2006, SAP TechEd ’06 / CD200 / 47
Simple Transformations: Example
<?sap.transform simple?><tt:transform xmlns:tt="http://www.sap.com/transformation-templates"><tt:root name="table"/><tt:template>
<TABLE><tt:loop ref=".table"><ITEM>
<tt:value /></ITEM>
</tt:loop></TABLE>
</tt:template></tt:transform>
DATA: itab TYPE TABLE OF i,xmlstr TYPE xstring.
DO 3 TIMES. APPEND sy-index TO itab. ENDDO.CALL TRANSFORMATION z_simple_table
SOURCE table = itabRESULT XML xmlstr.
CALL FUNCTION 'DISPLAY_XML_STRING'EXPORTING xml_string = xmlstr.
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
© SAP AG 2006, SAP TechEd ’06 / CD200 / 49
Checkpoints in ABAPsy
stem
sta
te
program flow
consistent state
norm
al te
rmin
atio
n
© SAP AG 2006, SAP TechEd ’06 / CD200 / 50
Checkpoints in ABAPsy
stem
sta
te
program flow
consistent state
norm
al te
rmin
atio
n
unexpected behavior
© SAP AG 2006, SAP TechEd ’06 / CD200 / 51
Checkpoints in ABAP
syst
em s
tate
program flow
consistent state
norm
al te
rmin
atio
n
: assertion
runtime error
syst
em s
tate
program flow
consistent state
norm
al te
rmin
atio
n
unexpected behavior
find cause of error in shorter time
© SAP AG 2006, SAP TechEd ’06 / CD200 / 52
Checkpoints in ABAP
syst
em s
tate
program flow
consistent state
norm
al te
rmin
atio
n
: assertion
runtime errorsy
stem
sta
te
program flow
consistent state
norm
al te
rmin
atio
n
undetected error
find more errors enhance program correctness
© SAP AG 2006, SAP TechEd ’06 / CD200 / 53
Checkpoints in ABAP
ASSERT - Statement:
BREAK-POINT - Statement:
LOG-POINT - Statement:
ASSERT ID group
SUBKEY subkeyFIELDS dobj1 dobj2 ...CONDITION log_exp.
BREAK-POINT ID group.
LOG-POINT ID group.
© SAP AG 2006, SAP TechEd ’06 / CD200 / 54
Checkpoints in ABAP
Activation methoddynamic, while system is running
Activation granularityLogical „checkpoint groups“Compose „variants“ from
Checkpoint groups, variants, All checkpoints in programs, function groups, classesExtract checkpoint groups from programs, function groups, classes, packages, development components
User, server
Assertion mechanismAbort, debug or protocol
© SAP AG 2006, SAP TechEd ’06 / CD200 / 55
Checkpoints in ABAP
ABAP checkpoints support developers in writing correct code
Activated in SAP development systems ( abort, protocol )
Code instrumented with checkpoints is easier to support and maintain
Can be activated on the fly in productive systems ( activation for dedicated user, server )
No activation, no performance loss !!!
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
© SAP AG 2006, SAP TechEd ’06 / CD200 / 57
New ABAP Editor
Modern Editor control with syntax coloring and many additional features
Automatic syntax check!
© SAP AG 2006, SAP TechEd ’06 / CD200 / 58
Editor Features - Outlining
See Start / End / Middle of language block
Collapse/Expand Block
Collapse same type blocks
Collapse Comments
User defined “Outlining Regions”
See current scope
See collapsed text
© SAP AG 2006, SAP TechEd ’06 / CD200 / 59
Editor Features - Templates
User and language dependent
Expandable by Ctrl + Enter
Built in runtime tags (Date Time, Clipboard Content, Document Name)
Interactive tags
Suggested by Code Hints
Extract template from selected text
Surround by template
© SAP AG 2006, SAP TechEd ’06 / CD200 / 60
Editor Features - Code Hints
Code HintsSuggest valid keywordsand recently used identifiers
Runs automatically as you type
For templates shortcuts
For misspelling from auto correction dictionary
Customizing of suggestions
© SAP AG 2006, SAP TechEd ’06 / CD200 / 61
Editor Features - Clipboard
Clipboard Ring
Extended Paste Menu
Normal and block format
Multiple Clipboard Formats:
Paste in MS Outlook with syntax highlightingPaste in MS Word with syntax highlighting
Copy/Cut Append to clipboard
Insert Special
Unicode or ASCII format support
© SAP AG 2006, SAP TechEd ’06 / CD200 / 62
Editor Features - Current Scope
Highlight of current scope tags in source
Highlight current scope on outline margin
See current code hierarchy in status panel
See current brackets highlighted in source
See mismatching brackets highlighted in error color
© SAP AG 2006, SAP TechEd ’06 / CD200 / 63
Editor Features - Extended Find/Replace
Incremental search
History of search/replace items
Mark all occurrence with bookmark
Search in collapsed text
Saving of search parameters between sessions
Use of regular expression
© SAP AG 2006, SAP TechEd ’06 / CD200 / 64
Editor Features - Edit Functions
Block Selection
Mistyping Correction
Auto Brackets
Keyword Case correction
Auto Indent
Caps Lock correction
Smart Tab
Surround Selection
Format After Paste
Line operations
Sort Lines
Change Case
Indent/Unindent
AutoSave
…
© SAP AG 2006, SAP TechEd ’06 / CD200 / 65
Editor Features - Quick Info in ABAP Debugger
Quick Info for variables on hovering
Quick Info for variables by Ctrl-Shift-Space
Customizing of quick info
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
© SAP AG 2006, SAP TechEd ’06 / CD200 / 67
Classic Debugger – Current Status
Classic Debugger
TechnologyDebugger and debuggee run in the same (internal) session
Debugger dynpros placed “in-between”
ConsequencesNot all ABAP code can be debugged (no conversion / field exits)
Not free of side effects (F1, F4 help, list output)
Implementation of new features not always straight-forward
No chance to use modern UI techniques (no ABAP allowed in the debugger !)
A new ABAP debugger technology
© SAP AG 2006, SAP TechEd ’06 / CD200 / 68
Goals – New ABAP Debugger
Higher productivity for development & support
using ABAP Debugger
More robust debugger architecture (no side effects)
Possibility to implement new features (e.g. a diff tool for internal tables) faster and with less risks
More flexible & extensible state-of-the-art debugger UI
Use two separated sessions for the debugger and the application
© SAP AG 2006, SAP TechEd ’06 / CD200 / 69
New ABAP Debugger, Two Process Architecture
The New Debugger is attached to an “external session”
Session 1 - Debuggee
ABAP VM
Session 2 - Debugger
UI
/h Debugger Engine
© SAP AG 2006, SAP TechEd ’06 / CD200 / 70
New ABAP Debugger – GUI
Process InformationsProcess Informations
DesktopsDesktops
Control AreaControl Area
11
22
Source Code Informations,System FieldsSource Code Informations,System Fields
33
44
ToolsTools55
© SAP AG 2006, SAP TechEd ’06 / CD200 / 71
New ABAP Debugger – Customizing the GUI
1. Close Tool1. Close Tool
2. New Tool2. New Tool
3. Replace Tool3. Replace Tool
4. Full Screen4. Full Screen
5. Maximize Horizontally5. Maximize Horizontally
6. Exchange6. Exchange
7. Services of the Tool7. Services of the Tool
Enlarge SizeEnlarge Size
Reduce SizeReduce Size
© SAP AG 2006, SAP TechEd ’06 / CD200 / 72
New ABAP Debugger – Tools, Breakpoints, Watchpoints
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
© SAP AG 2006, SAP TechEd ’06 / CD200 / 74
ABAP Unit – What Should I Know ?
What is ABAP Unit?
ABAP Unit is the ABAP framework for module/unit tests.
What is an Unit?
An unit can be considered as a non-trivial, accessible code portion (method, function or form) where a given input or action causes a verifiable effect. Ideally it is the smallest code part which can be tested in isolation.
How does an ABAP Unit test looks like?
The ABAP Unit tests are realized as methods of a local class (with the addition “FOR TESTING”).This local class is part of the class, function group or program you want to test.
© SAP AG 2006, SAP TechEd ’06 / CD200 / 75
ABAP UNIT – What Should I Know ?
Why is the test class part of the productive code?ABAP Unit tests and the linked production code are in syncIn a productive system the ABAP Unit tests are not part of the productive program load. (-> No performance or security drawbacks)
Which services are provided by ABAP UNIT?
ABAP Unit provides a service class CL_AUNIT_ASSERT, which contains static methods (e.g. ASSERT_EQUALS) to compare e.g. strings or internal tables in order to verify test results.
© SAP AG 2006, SAP TechEd ’06 / CD200 / 76
ABAP UNIT – Example for Test Class
CLASS test_sflight_selectionDEFINITION DEFERRED.
CLASS demo DEFINITIONFRIENDS test_sflight_selection.
PUBLIC SECTION.METHODS get_carrier_flights
IMPORTING carrier TYPE string.PRIVATE SECTION.DATA sflight_tab TYPE TABLE OF sflight.
ENDCLASS.
CLASS demo IMPLEMENTATION.METHOD get_carrier_flights.SELECT * FROM sflight
INTO TABLE sflight_tabWHERE carrid = 'LH'.
ENDMETHOD.ENDCLASS.
CLASS test_sflight_selection IMPLEMENTATION.METHOD setup.CREATE OBJECT demo_ref.APPEND 'LH' TO test_carrids.APPEND 'UA' TO test_carrids.APPEND 'AA' TO test_carrids.
ENDMETHOD.METHOD test_get_carrier_flights.DATA: act_carrid TYPE string,
msg TYPE string,sflight_wa TYPE sflight.
LOOP AT test_carrids INTO test_carrid.CONCATENATE 'Selection of' test_carrid
'gives different airlines'INTO msg SEPARATED BY space.
demo_ref->get_carrier_flights( test_carrid ).LOOP AT demo_ref->sflight_tab INTO sflight_wa.act_carrid = sflight_wa-carrid.cl_aunit_assert=>assert_equals(
act = act_carridexp = test_carridmsg = msgquit = cl_aunit_assert=>no ).
IF act_carrid <> test_carrid.EXIT.
ENDIF.ENDLOOP.
ENDLOOP.ENDMETHOD.
ENDCLASS.
CLASS test_sflight_selectionDEFINITION "#AU Risk_Level HarmlessFOR TESTING. "#AU Duration Short
PRIVATE SECTION.METHODS: test_get_carrier_flights
FOR TESTING,setup.
DATA: demo_ref TYPE REF TO demo,test_carrid TYPE string,test_carrids TYPE TABLE OF string.
ENDCLASS.
PROGRAM z_abap_unit.
© SAP AG 2006, SAP TechEd ’06 / CD200 / 77
ABAP UNIT – Example for Test Execution and Result
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
© SAP AG 2006, SAP TechEd ’06 / CD200 / 79
Memory Inspector: Motivation
What is the Memory Inspector ?
Tool to analyze dynamic memory consumption
Why do we need the Memory Inspector ?
Increasing usage of dynamic memory objects, likeInternal Tables StringsClass Instances (Objects) Anonymous Data Objects
Increasing number of long-running transactions
T1 T2 T3 T4 T1
© SAP AG 2006, SAP TechEd ’06 / CD200 / 80
Memory Inspector: Features Summary
In ABAP Debugger
TopN-Consumer-Lists– Aggregation of types (class/data)– Find References
Memory consumption overview
In Stand-Alone TA
Analyzing memory snapshots
Comparing memory snapshots– Growth of memory objects in different views
Available in Release 6.20 ( SP 29, Sept.2003 )
© SAP AG 2006, SAP TechEd ’06 / CD200 / 81
Memory Inspector: GUI
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
© SAP AG 2006, SAP TechEd ’06 / CD200 / 83
Adapting SAP Software
One of the advantages of SAP software is the possibility to adapt the software to own requirements and the possibility of keeping the adaptations during upgrade.
Ways of adaptation:Customizing
Enhancement new concept!
Modification
© SAP AG 2006, SAP TechEd ’06 / CD200 / 84
Evolution of SAP Enhancement Technology
Kernel basedBusiness Add Ins
User Exits
Formroutines
Application
Workbench
Kernel
CustomerExits
Functionmodules
Business Transaction
EventsIndustries
Business Add Ins
FiltersClasses
© SAP AG 2006, SAP TechEd ’06 / CD200 / 85
Components of new Enhancement Framework
Enhancement options (in original system):Part of a development object that can be enhancedCan be explicitly defined or implicitly availableAre organized and documented in Enhancement SpotsExamples are– BAdIs– Parameter Interfaces of Functiongroups or Methods– Components of Classes/Interfaces – ABAP statements ENHANCEMENT-POINT, ENHANCEMENT-SECTION – …
Enhancements (in follow-up system):Switchable by Switch FrameworkSupport automatic UpgradeAre organized and documented in Enhancement ImplementationsOffer multilayer support
© SAP AG 2006, SAP TechEd ’06 / CD200 / 86
Multilayer Support of Enhancements
Core DevelopmentOriginal Object
Enhancement 1 Enhancement 2
Enhancement 11 Enhancement 12
Application Development
Add On Development
Customer Development
Enhancement 121 Enhancement 201
Enhancement 01
Enhancement 001
© SAP AG 2006, SAP TechEd ’06 / CD200 / 87
Enhancement Spot Editor (Original System)
Organization of Predefined Enhancement Options (Source Code Enhancements & BAdIs)Integrated in Object Navigator (SE80)Tab Properties & Objects common for all Enhancement SpotsTab 3 dependent on enhancement technology: BAdIs or Source Code Enhancements
© SAP AG 2006, SAP TechEd ’06 / CD200 / 88
Enhancement Implementation Editor (Follow-up System)
Organization of EnhancementsIntegrated in Object Navigator (SE80)Tab Properties & Objects common for all enhancement typesTab 3 dependent on enhancement technology: e.g. BAdI-Implementation or Source Code Enhancements
© SAP AG 2006, SAP TechEd ’06 / CD200 / 89
Enhancement Browser (Original and Follow-up System)
Tool to Search forEnhancement SpotsExisting Enhancement ImplementationsEnhancement Implementations to be adjusted after upgrade
© SAP AG 2006, SAP TechEd ’06 / CD200 / 90
Implicit and Explicit Enhancement Options
Features of explicit enhancement optionsDefined by developerMore stableFew changes in definition to expectOnly at valid source code locationsTarget-orientedOrganized by Enhancement Spots
Features of implicit enhancement optionsDefined implicitlyEnhancement of „arbitrary“ objectsNo enhancement spots for management necessary
© SAP AG 2006, SAP TechEd ’06 / CD200 / 91
Example 1 - Source Code Enhancements
Modification-free enhancement of source code either by
Explicit Enhancement Options– Explicit enhancement options can be defined in source code. – They are organized by Enhancement Spots.
Implicit Enhancement Options– Implicit Enhancement options are available at common enhancement
places. – Examples:
- Begin/End of Include- Begin/End of Method/Function Module/Form Routine- End of a structure- End of Private/Protected/Public Section of a local class- ...
© SAP AG 2006, SAP TechEd ’06 / CD200 / 92
Explicit Enhancement Options in Source Code
© SAP AG 2006, SAP TechEd ’06 / CD200 / 93
Enhancement by Source Code Plug-In Technology
PROGRAM p1.
WRITE ‘Hello World’.
ENHANCEMENT-POINT ep1 SPOTS s1.
..
..
..
ENHANCEMENT-SECTION ep2 SPOTS s1.WRITE ’Original’.
END-ENHANCEMENT-SECTION.
ENHANCEMENT 1.WRITE ’Hello
Paris’.ENDENHANCEMENT.
ENHANCEMENT 2.WRITE ’Hello
London’.ENDENHANCEMENT.
ENHANCEMENT 3.WRITE ’Enhanced’.
ENDENHANCEMENT.
Source Code Plug-Ins
© SAP AG 2006, SAP TechEd ’06 / CD200 / 94
Example 2 - Class/Interface Enhancements
Implicit Enhancement Options allow adding of:optional parameters to existing methods methodsevents and event handlersreferences to interfacesExits to existing methods– Pre-Exit – Called at the beginning of a method– Post-Exit – Called at the End of a method
© SAP AG 2006, SAP TechEd ’06 / CD200 / 95
Example 3 – New BAdIs
A new BAdI is an Explicit Enhancement Optionthat:
is a predefined anchor point for Object Plug-Inshas a well-defined interface in contrast to Source Code Plug-Ins and is therefore more stable to changes in the original codingis integrated into ABAP language and has much better performance than classic BAdIs
© SAP AG 2006, SAP TechEd ’06 / CD200 / 96
Usage of New BAdIs
Classic BAdI New BAdIDATA: bd TYPE REF TO if_intf.DATA: flt TYPE flt.
CALL METHOD cl_exithandler=>get_instanceEXPORTING
exit_name = `BADI_NAME`CHANGING
instance = bd.
flt-lang = `D`.CALL METHOD bd->methodEXPORTING
x = 10flt_val = flt.
DATA bd TYPE REF TO badi_name.
GET BADI bd FILTERS lang = `D`.
CALL BADI bd->methodEXPORTING x = 10.
© SAP AG 2006, SAP TechEd ’06 / CD200 / 97
Integration of new BAdIs into ABAP Runtime
BAdIs are represented by a reference to BAdI-Handles:
If there are two implementations of badi_name that are selected for the filter value f=5, this yields:
DATA bd type ref to badi_name.
GET BADI bd FILTER f = 5.
Inst1 Inst2
Cl_imp1 Cl_imp2
bdbadi_name
Object Plug-Ins
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
© SAP AG 2006, SAP TechEd ’06 / CD200 / 99
Disclaimer
This preview is a preliminary version and not subject to your license agreement or any other agreement with SAP. This documentcontains only intended strategies, developments, and functionalities of the SAP® product and is not intended to be binding upon SAP to any particular course of business, product strategy, and/or development. Please note that this document is subject to changeand may be changed by SAP at any time without notice. SAP assumes no responsibility for errors or omissions in this document.
© SAP AG 2006, SAP TechEd ’06 / CD200 / 100
ABAP Language Preview – Enhanced Expression Enabling
As of next Release:You can use computational expressions, functional methods and built-in functions in expression positions:– Logical expressions: a + b < oref->meth( )
– Method call parameters: oref1->meth1( oref2->meth2( ... ) )
You can use numerical expressions in numerical positions:– Examples: DO abs( n ) + 1 TIMES.
READ TABLE itab INDEX lines( itab ) – 1 ...
You can use functional methods in functional positions:– Examples: FIND|REPLACE REGEX oref->get_regex( ... ) IN ...
READ TABLE itab FROM oref->get_wa( ... ) ...
© SAP AG 2006, SAP TechEd ’06 / CD200 / 101
ABAP Language Preview – Decimal Floating Point Numbers
As of next Release:New data types for decimal floating point numbers (based on IEEE-754r):– decfloat16: 8 bytes, 16 digits, exponent -383 to +384 – decfloat34: 16 bytes, 34 digits, exponent -6143 to +6144
Exact representation of decimal numbers within range (no rounding necessary as for binary floating point numbers of type f).
Range larger than f!Calculation accuracy like p!
Supported by new generic type decfloat, new Dictionary types, new rounding functions round and rescale, new methods in CL_ABAP_MATH, and new format options in WRITE [TO].
© SAP AG 2006, SAP TechEd ’06 / CD200 / 102
ABAP Language Preview – Internal Tables
As of next Release:Dynamic WHERE condition:– LOOP At itab ... WHERE (cond_syntax) ...
Secondary keys for internal tables:– Secondary key definition:TYPES itab TYPE ... TABLE OF ...
WITH {UNIQUE HASHED}|{{UNIQUE|NON_UNIQUE} SORTED} KEY keynamei COMPONENTS comp1 comp2 ...
– Key specification for key access: ... WITH [TABLE] KEY keynamei COMPONENTS ...
– Key specification for index access: ... USING KEY keynamei ...
Boosting internal table performanceReal key access to standard tablesIndex access to hashed tables
© SAP AG 2006, SAP TechEd ’06 / CD200 / 103
ABAP Language Preview – Class Based Exceptions
As of next Release:Resumable exceptions:– Raising a resumable exceptionRAISE RESUMABLE EXCEPTION TYPE cx_class.
– Resuming (continue processing behind RAISE):TRY.
...CATCH cx_class BEFORE UNWIND....RESUME.
ENDTRY.
Retry:– Retrying (continue processing behind TRY):TRY.
...CATCH cx_class....RETRY.
ENDTRY.
© SAP AG 2006, SAP TechEd ’06 / CD200 / 104
ABAP Development Preview – Packages
As of next Release:Role of Packages:– Packages encapsulate repository objects– Reusable components must be published in package interfaces
Operational Package Concept:– A "server package" has to expose everything that is meant for public
usage in an interface.– A "client package" has to be allowed to use that interface.– A "client package" has to declare the usage of that interface.– Package checking is integrated into the ABAP compiler and ABAP
runtime and package violations are treated as ‘first order errors’.
Enhancement of ABAP Objects:– CLASS cls DEFINITION OPEN WITHIN PACKAGE
– PACKAGE SECTION
© SAP AG 2006, SAP TechEd ’06 / CD200 / 105
ABAP Development Preview – ABAP Editor
As of next Release:Code Completion:– Suggests valid
keywords andvalid identifiers
– Invoked explicitlyby pressing specialkey combination
– Autofilters resultby typed prefix
Entities completed include …– Variables, including structures and components – Types (including ABAP Dictionary), classes – Methods, attributes, constants, events– Functions– Subroutines– Formal parameters and exceptions of methods, functions, and subroutines – Database tables– Keywords
Completion suggestions may be inserted …– Verbatim as shown– As pattern with parameters prefilled
(CALL METHOD, CALL FUNCTION, PERFORM, …)
© SAP AG 2006, SAP TechEd ’06 / CD200 / 106
ABAP Development Preview – Refactoring
As of next Release:Refactoring of ABAP programs:– Renaming of local & global elements– Code Extraction (convert marked code into procedure)– Deletion of superflous declarations– Create GET/SET-methods ...
© SAP AG 2006, SAP TechEd ’06 / CD200 / 107
ABAP Development Preview – Class Builder
As of next Release:Source code based editing of global classes:
© SAP AG 2006, SAP TechEd ’06 / CD200 / 108
ABAP Testing Preview – ABAP Debugger
As of next Release:New Dynpro analysis toolNew Web Dynpro analysis toolSimple Transformation DebuggingAutomated Debugging: Debugger ScriptingLayer Debugging– Define your active software
- Packages - Free-style expressions
– Dynamically assign your „system code“– Layer-step through code
Miscellaneous:– Upload of Internal Tables– Table View: view and configure sub-components of embedded structures– Changing long fields– Call Stack of the internal session of the caller
© SAP AG 2006, SAP TechEd ’06 / CD200 / 109
ABAP Testing Preview – Coverage Analyzer
As of next Release:Code Coverage measured on statement levelCondition Coverage for logical expressionsCoverage of empty branchesStatement results visualized using new ABAP Edit ControlIntegrated to ABAP Unit
© SAP AG 2006, SAP TechEd ’06 / CD200 / 110
ABAP Testing Preview – Runtime Analysis
As of next Release:Controls based UI (like ABAP Debugger)Multiple Tools on Customizable DesktopsMore flexible and powerful Analysis ToolsTrace Data stored on Database (Server and Platform independant)Cross System/Release Trace Comparison
© SAP AG 2006, SAP TechEd ’06 / CD200 / 111
ABAP Connectivity Preview – bgRFC & LDQ
As of next Release:
tRFC
qRFC
Processed byScheduler
directly
No-SendScenario
bgRFCSequencing:
Type “T” or Type “Q”Serialization:
RFC Protocol
LDQSequencing:
Type “Q”Serialization:
XML or binary
© SAP AG 2006, SAP TechEd ’06 / CD200 / 112
ABAP Connectivity Preview – Alternatives to tRFC & qRFC
As of next Release:Optimized alternatives for tRFC, qRFC, and qRFC No-Send:
bgRFC (Background RFC)– CALL FUNCTION IN BACKGROUND UNIT oref (TYPE REF TO IF_BGRFC_UNIT)– Remote Function Calls are recorded, and execution takes place at a later point in
time, which is controlled automatically by a scheduler process.– The execution scales with O(n*log(n)), i.e. linear-logarithmic, which is determined
by the I/O system only.– The inbound procedure is executed at the caller system and serves for load-
balancing purposes.– The outbound procedure is executed at the receiver system and serves for de-
coupled, remote system environments with load-balancing at the receiver.
LDQ (Local Data Queue)– Persistency layer to provide first-in first-out (queue) access to data.– Receiver actively pulls data from such a queue, similar to a mailbox.– Access is locally within one SAP system.– The data model of LDQ is absolutely de-coupled from any RFC database tables.
© SAP AG 2006, SAP TechEd ’06 / CD200 / 113
ABAP Connectivity Preview – Quality of Services
As of next Release:RFC Communication– Binary asXML serialization replaces the different RFC serialization concepts, e.g.
“xRFC”.- Available for ABAP Application Server, Java Application Server, and
SAP NetWeaver RFC SDK– SAP NetWeaver RFC SDK replaces the classic RFC SDKs for ASCII and Unicode.
- Homogeneous handling of all RFC parameter types.- Compatible with all backend system variants R/3, mySAP, …- Classic RFC SDKs are still maintained.
RFC-based SAP J2EE Connectivity– SAP Java Resource Adapter compliant with JCA 1.5 replaces the direct usage of
the SAP JCo API.- Supports stateful connections and callback connections.- Provides shareable client connections for increased robustness and scalability .- SAP JCo API within SAP J2EE is still maintained.
– IDoc class library for SAP J2EE simplifying the handling of SAP IDocs.
ABAP DebuggerABAP UnitMemory Inspector
Regular ExpressionsShared Objects
CheckpointsABAP Editor
Enhancement Framework
Simple Transformations
Preview of Next Release
© SAP AG 2006, SAP TechEd ’06 / CD200 / 115
THANK YOU FOR YOURATTENTION !
QUESTIONS – SUGGESTIONS – DISCUSSION
© SAP AG 2006, SAP TechEd ’06 / CD200 / 116
Please complete your session evaluation.
Be courteous — deposit your trash, and do not take the handouts for the following session.
Feedback
Thank You !
© SAP AG 2006, SAP TechEd ’06 / CD200 / 117
Further Information
Public Webwww.sap.comSAP Developer Network: http://www.sdn.sap.com/sdn/developerareas/abap.sdnSAP Help Portal: http://www.help.sap.com
ABAP Keyword-DocumentationTransaction ABAPHELP, always the first source of information
Related Workshops/Lectures at SAP TechEd ’06 All lectures and workshops about ABAP
© SAP AG 2006, SAP TechEd ’06 / CD200 / 118
Copyright 2006 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, Outlook, and PowerPoint 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, and Informix are trademarks or registered trademarks of IBM Corporation in the United States 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, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.HTML, XML, XHTML and W3C 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. MaxDB is a trademark of MySQL AB, Sweden.SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.
The information in this document is proprietary to SAP. No part of this document may be reproduced, copied, or transmitted in any form or for any purpose without the express prior written permission of SAP AG.This document is a preliminary version and not subject to your license agreement or any other agreement with SAP. This document contains only intended strategies, developments, and functionalities of the SAP® product and is not intended to be binding upon SAP to any particular course of business, product strategy, and/or development. Please note that this document is subject to change and may be changed by SAP at any time without notice.SAP assumes no responsibility for errors or omissions in this document. SAP does not warrant the accuracy or completeness of the information, text, graphics, links, or other items contained within this material. This document is provided without a warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement.SAP shall have no liability for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. This limitation shall not apply in cases of intent or gross negligence.The statutory liability for personal injury and defective products is not affected. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third-party Web pages nor provide any warranty whatsoever relating to third-party Web pages.