You are on page 1of 48

Getting Back to

Standard How to
Address Your
Modification
ASUG Upgrade Symposium
June 2007
Thomas Jung
SAP NetWeaver Product
Management

Modification Adjustment
Unicode Enablement
Enhancement Framework

Introduction
Today we will focus on an upgrade from 4.6C to SAP ERP 6.0
(Formerly mySAP ERP 2005) from the view of the ABAP
development team. We will look at the tasks and challenges your
developers will face, showing some of the program changes that will
need to be made. Also we will see some of the new ABAP features
that you will be able to leverage once you are upgraded.

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 3

Modification Adjustment
Unicode Enablement
Enhancement Framework

Program Adjustments - Experiences


Made the Unicode Adjustments to programs during the Upgrade
Must adjust Customer Functions for Unicode
Of the 2000 Objects approx 200 needed to be touched
Dev System adjustments 3 developers for 3 days
Used the Sandbox system and Standalone Netweaver system to
fix difficult problems in advance
Polish HR Add-in was messy

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 5

SPAU Modification Adjustment During Upgrade

SPAU
The upgrade
process stops and
provides the
opportunity to make
Modification
Adjustments

Only Objects
touched by the
upgrade are listed
Split Screen Editor
for before and after
view of source code

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 6

DEMO
Demo SPAU

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 7

SE95 Modification Browser

SE95
Allows you to view
ALL modifications
regardless of how
they may or may not
have been touched by
the Upgrade
Note Corrections are
also listed (separately
if made via Note
Assistant)

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 8

DEMO
Demo SE95

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 9

SAMT Extended Program Check

SAMT
General Tool for
performing multiple
types of system wide
program scans

Can create separate


scan sets broken
down by Object
Name, Package, etc.
Large Scans can be
ran in the
background
Stops scanning an
object upon finding
the first syntax error

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 10

DEMO
Demo SAMT

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 11

Modification Adjustment
Unicode Enablement
Enhancement Framework

Representation of Unicode Characters


UTF-16 Unicode Transformation Format, 16 bit encoding
Fixed length, 1 character = 2 bytes (surrogate pairs = 2 + 2 bytes)
Platform dependent byte order
2 byte alignment restriction

UTF-8 Unicode Transformation Format, 8 bit encoding

Variable length, 1 character = 1...4 bytes


Platform independent
no alignment restriction
7 bit US ASCII compatible
Character

Unicode
code point

UTF-16
big endian

UTF-16
little endian

U+0061

00 61

61 00

61

U+00E4

00 E4

E4 00

C3 A4

U+03B1

03 B1

B1 03

CE B1

U+3479

34 79

79 34

E3 91 B9

U+2007B

DA00 DC7B

00DA7BDC

F0A081BB

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 13

UTF-8

Unicode-Enabled ABAP Programs


Program attribute Unicode checks active
Required to run on a Unicode system
Non-Unicode
system

Unicode
system

ok

ok

ok

not allowed

Attribute set
(Unicode enabled)
Attribute not set
(not Unicode
enabled)

If attribute is set, additional restrictions:


apply at compile and at run time
apply in Unicode systems and in non-Unicode systems
ensure that program will run on non-Unicode and Unicode systems with
(almost) identical behavior

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 14

Program Attribute Unicode Checks Active

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 15

UCCHECK Unicode Scan

UCCHECK
Similar tool to SAMT,
except it is
specifically designed
for Unicode
Compatibility Checks

Does NOT stop


scanning an object
after the first problem
is found
Can be used to set
the Unicode Attribute
on a group of objects

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 16

DEMO
Demo UCCHECK

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 17

Unicode Enabled ABAP Overview


Design Goals
Platform independence
Identical behavior on Unicode and non-Unicode systems

Highest level of compatibility to the pre-Unicode world


Minimize costs for Unicode enabling of ABAP Programs

Improved security, maintainability, and readability of ABAP programs

Main Features
Clear distinction between character and byte processing
1 Character 1 Byte
Enhanced checks prevent programming based on memory layout
assumptions
Improved conversion facilities
Improved dataset interface
Improved support for dynamic programming
SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 18

Unicode Restrictions String Processing


Character Processing
CONCATENATE cf1 cf2 TO cf3.
IF cf1 CS cf2. ...

String operations are only allowed for character-like operands


ABAP types C, N, D, and T, STRING
Structures consisting only of characters (C, N, D, T)
X and XSTRING are no longer considered character-like types

Byte Processing
CONCATENATE xf1 xf2 TO xf3 IN BYTE MODE.
IF xf1 BYTE-CS xf2. ...
Variants of string operations for byte processing
Addition IN BYTE MODE for statements
Prefix BYTE- for comparison operations

Only operands of type X or XSTRING allowed

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 19

Unicode Restrictions Length And Distance


Determining the Length and Distance
Counted in bytes or in characters? Specify!
DESCRIBE FIELD...LENGTH... IN (BYTE | CHARACTER) MODE
DESCRIBE DISTANCE BETWEEN ... AND ... INTO ...
IN (BYTE | CHARACTER) MODE.

Example

FORM write3 USING fld TYPE c.


DATA: fldlen TYPE i.
DESCRIBE FIELD fld LENGTH fldlen IN CHARACTER MODE.
IF fldlen >= 3.
WRITE: / fld(3).
ENDIF.
ENDFORM.

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 20

Unicode Restrictions MOVE


MOVE Between Incompatible Structures
Matching data layout (fragment views) required
C(6)

struc1

struc2

C(4)

N(4)

C(3)

C(3)

C(10)

X(3)

N(4)

X(3)

C(4)

X(3)

C(4)

P(8)

P(8)

fragments

Example
DATA:
BEGIN OF cstru,
first(10) TYPE c,
tab(1)
TYPE c,
last(10) TYPE c,
END OF cstru.
cstru = xstru.

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 21

DATA:
BEGIN OF xstru,
first(10) TYPE c,
tab(1)
TYPE x VALUE '09',
last(10) TYPE c,
END OF xstru.
"Unicode error!

Unicode Restrictions Access With Offset or Length


Access To Structures With Offset/Length
Structure must begin with characters
Offset/length counted in characters

Access only allowed within the character type prefix of a structure

N(6)

C(4)

X(3)

C(5)

+off(len)

ASSIGN fld+off(len) TO ...


Access must not exceed field boundaries

If ASSIGN fails, field-symbol is set to unassigned


New ... RANGE addition allows the permissible boundaries
to be expanded

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 22

New ABAP Features Character Utilities


Class CL_ABAP_CHAR_UTILITIES
Constant attributes with system specific values
charsize
length of 1 character in bytes
newline
cr_lf
form_feed
horizontal_tab
vertical_tab
backspace
minchar
X00 in non-Unicode systems, U+0000 in Unicode systems
maxchar
XFF in non-Unicode systems, U+FFFD in Unicode systems

Example
CLASS cl_abap_char_utilities DEFINITION LOAD.
DATA: text TYPE string.
REPLACE cl_abap_char_utilites=>horizontal_tab
WITH space INTO text.
SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 23

New ABAP Features Extended File Interface


Reading / Writing Different Text Formats
OPEN DATASET dsn IN TEXT MODE
ENCODING (DEFAULT | UTF-8 | NON-UNICODE).
TRANSFER text TO dsn.
READ DATASET dsn INTO text.
Only character-like fields allowed for reading / writing text files
Explicit open required in Unicode enabled programs

Reading / Writing Legacy Formats


OPEN DATASET dsn IN LEGACY (TEXT | BINARY) MODE
... (LITTLE | BIG) ENDIAN
... CODEPAGE cp.
Reading or writing data in a format compatible to non-Unicode systems
Not character-like structures allowed

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 24

New ABAP Features Conversion Classes


Conversion classes
Code page conversion
Unicode / non-Unicode code pages

Endian conversion
little endian / big endian byte order

Character conversion
Unicode code point / ABAP character

ABAP Class

Conversion

CL_ABAP_CONV_IN_CE

any code page system code page

CL_ABAP_CONV_OUT_CE

system code page any code page

CL_ABAP_CONV_X2X_CE

any code page any code page

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 25

New ABAP Features Includes With Group Names


Symbolic Access to Includes of Structures
TYPES: BEGIN OF t_key,
k1(2) TYPE x,
k2(2) TYPE c,
END OF t_key.

TYPES: BEGIN OF t_rest,


r1(10) TYPE c,
r2(10) TYPE c,
END OF t_rest.

DATA: BEGIN OF stru.


INCLUDE TYPE t_key as key.
INCLUDE TYPE t_rest as rest.
DATA: END OF stru.
DATA: skey TYPE t_key,
srest TYPE t_rest.

Pre-Unicode
skey = stru(4).
srest = stru+4(20).
WRITE: stru-r2.

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 26

stru
k1 k2
key

r1 r2
rest

Unicode enabled with group names


skey = stru-key.
srest = stru-rest.
WRITE: stru-r2.

Modification Adjustment
Unicode Enablement
Enhancement Framework

Evolution of SAP Enhancement Technology


Application

User
Exits
Form
routines

Business
Transaction
Events
Industries

Business
Add Ins
Function
modules
Customer
Exits

Filters
Classe
s

Workbench

Enhancement Framework

Kernel based
Business
Add Ins

Kernel
SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 28

Enhancement Browser
Search for
Enhancements possibilities (Definitions typically provided by SAP)

Enhancement Implementations (typically done by Customer)

Integrated into Object Navigator (SE80)


SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 29

Source Code Enhancements Overview

Modification-free enhancement of source code


Implicit Enhancement Option
At common enhancement places, implicit Enhancement options are
available. Examples:
End of Executable Program, Include, Function group, Dialog module

Begin/End of Form routine / Function module / Method


End of a structure
End of Private/Protected/Public Section of a local class
...

Explicit Enhancement Option


Predefined enhancement options can be defined in source code.
They are additionally stored inside Enhancement Spots.
SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 30

Implicit Enhancement Options

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 31

Explicit Enhancement Options

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 32

Source Code Plugin Technology - Example


PROGRAM p1.
WRITE Hello World.

ENHANCEMENT-POINT ep1 SPOTS


s1.
..
..
..
ENHANCEMENT-SECTION ep2
SPOTS s1.
WRITE Original.
END-ENHANCEMENT-SECTION.

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 33

ENHANCEMENT 1.
WRITE Hello
Paris.
ENDENHANCEMENT.
ENHANCEMENT 2.
WRITE Hello
London.
ENDENHANCEMENT.

ENHANCEMENT 3.
WRITE Enhanced.
ENDENHANCEMENT.

Editor Modes for Enhancements

Use Change Mode for creating enhancement points &


sections.
use button
mode.

Display <-> Change to switch to change

Use Enhancement Mode for creating enhancement


implementations.
use button Change Enhancements
Enhancement mode

use button Display <-> Change


mode

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 34

to switch to

to leave Enhancement

DEMO
Source Code Plugin

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 35

Class/Interface Enhancements

Class/Interface Enhancements allow addition of:


optional parameters to existing methods
methods
events and event handlers
references to interfaces
Exits to existing methods
Pre-Exit Called at the beginning of a method
Post-Exit Called at the End of a method
Overwrite-Exit Replaces the original method

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 36

Adding Methods & Parameters


Adding new methods

Adding optional parameters to existing methods

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 37

Pre/Post Exits

Call method instance->hugo( ).

Method Hugo.
Coding.
Coding.
Coding.
Endmethod.

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 38

Method Pre.

.
Endmethod.
Method Post.
.
.
Endmethod.

DEMO
Class Enhancement

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 39

BADIs - Overview
What are BAdIs?
Business Add-Ins
is an anticipated point of extension these points act like
sockets and exist in the original coding
has a well-defined interface in contrast to source code plug-ins
and is therefore more stable to changes in the original coding
Kernel BAdIs - New Features
Are integrated directly in the ABAP Language/Runtime
Improved filter support allows non-character filter types
(packed, numeric, string) and complex filter conditions
Enable reusable implementation instances (Stateful BAdI)
Control of the lifetime of implementations (BAdI-context)
Allow for inheritance of implementations
Can be switched by the Switch Framework

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 40

Comparison: Usage of Old BAdIs vs. new BAdIs

With Classic BAdI


DATA: bd TYPE REF TO if_intf.
DATA: flt TYPE flt.
CALL METHOD cl_exithandler=>
get_instance
EXPORTING
exit_name = `BADI_NAME`
CHANGING
instance = bd.

flt-lang = `D`.
CALL METHOD bd->method
EXPORTING
x
= 10
flt_val = flt.

selecting implementations and issuing calls is


mixed up
calls cause DB access
calls are redirected over a proxy class
SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 41

With New BAdI


data bd type ref to badi_name.
get badi bd filters lang = `D`.
call badi bd->method
exporting x
= 10.
selection occurs when the handle is requested
no DB access during runtime
Implementations are called directly (without a proxy)

Active implementations are evaluated at compile time


and included in the load of the BAdI-handle.

Old BAdIs are more expensive


than the new ones.

New BADIs and Enhancement Framework


Switch_1
Definition
Simple Enhancement Spot
Spot_1

Implementation
BAdI Implementation 1
Simple Enhancement Implementation SEI1

Package A

BAdI Implementation 2

BAdI BADI_A
BAdI BADI_B

BAdI Implementation 3

BAdI BADI_C

BAdI Implementation 4
Simple Enhancement Implementation SEI2

BAdI Implementation 5

Switch_2
SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 42

Package B

Creating BADI in SE80

BADI Implementation (Creating Filters)

BADI Definition under Enhancement Spot

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 43

DEMO
Kernel-BAdI

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 44

BAdI Migration (Automatic Migration)

Automatic migration
by selecting
utilitiesmigration
from BAdI
Automatic
migration
by selecting
utilitiesmigrate
from
BAdI
Builder (SE18)
Builder
(se18)
Specify
Enhancement
BAdI Definition
Specify
Enhancement
Spot forSpot
BAdIfor
Defintion
Specify
Enhancement
Implementation
for BAdI
Specify
Enhancement
Implementation
for BAdI Implementation
Implementation

no special knowledge necessary

no special knowledge necessary

effort: 5 minutes per BAdI (with some implementations). The migration

effort: approximately 5 minutes per BAdI.

can be automated.

SE18 -> utilities -> Migrate

ONLY when you have created Custom-BADI definitions in old systems


SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 45

Performance Comparison

Classic BAdI

Migrated BAdI

2-27

40-600

x faster as classic BAdI

x faster as classic BAdI

200%-2600%

New BAdI

4000%-60000%

The more implementations defined, the


higher is the improvement on performance

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 46

Further Information

Documentation
Transaction ABAPDOCU
Books ABAP Objects and Official ABAP Reference by Horst Keller and Next
Generation ABAP Development by Rich Heilman and Thomas Jung; SAP
Press

Public Web
SAP Developer Network: www.sdn.sap.com
NetWeaver Application Server ABAP
SAP Customer Services Network: www.sap.com/services/

Related SAP Education Training Opportunities


http://www.sap.com/education/

SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 47

QUESTIONS
How to contact me:
Thomas Jung
thomas.jung@sap.com
SAP AG 2007, SAP ERP: Upgrades for ABAP Developers/ Thomas Jung / 48

You might also like