+ All Categories

CD265

Date post: 19-Jan-2016
Category:
Upload: tamanam-kiran-kumar
View: 55 times
Download: 6 times
Share this document with a friend
Description:
CD 265
Popular Tags:
121
Boris Gebhardt / SAP AG Ekaterina Zavozina / SAP AG October, 2012 CD265 ABAP Test and Troubleshooting Tools - Including New ABAP Test Cockpit
Transcript
Page 1: CD265

Boris Gebhardt / SAP AG Ekaterina Zavozina / SAP AG October, 2012

CD265

ABAP Test and Troubleshooting Tools - Including New ABAP Test Cockpit

Page 2: CD265

© 2012 SAP AG. All rights reserved. 2

Disclaimer

This presentation outlines our general product direction and should not be relied on in making a

purchase decision. This presentation is not subject to your license agreement or any other agreement

with SAP. SAP has no obligation to pursue any course of business outlined in this presentation or to

develop or release any functionality mentioned in this presentation. This presentation and SAP's

strategy and possible future developments are subject to change and may be changed by SAP at any

time for any reason without notice. 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 assumes no responsibility for errors or omissions in this

document, except if such damages were caused by SAP intentionally or grossly negligent.

Page 3: CD265

© 2012 SAP AG. All rights reserved. 3

SAP NetWeaver Application Server ABAP Empowering classic & new SAP products

• 50.000+ customers of ABAP-based products

• Millions of ABAP developers, SCN as community

• A thriving partner ecosystem

• Proven, robust and scalable

• Extends into HANA, Mobility and Cloud

• Evolves continuously w/o disruption

• Enables hybrid on-premise/on-demand scenarios

SAP NetWeaver Application Server ABAP, a strong pillar In SAP‟s product strategy

HANA

MOBILITY

CLO

UD

SAP NetWeaver in 2013

SAP NetWeaver

Application

Server ABAP

Page 4: CD265

© 2012 SAP AG. All rights reserved. 4

Agenda

Motivation

Static Checks with brand-new ABAP Test Cockpit

Unit Testing

ABAP Unit Basics

Coverage Analyzer

Our Test Strategy

Troubleshooting Tools

ABAP Debugger

ABAP Runtime Analysis

Outlook: ABAP Development Tools for SAP NetWeaver

Page 5: CD265

Motivation

Page 6: CD265

© 2012 SAP AG. All rights reserved. 6

Custom ABAP code

A lot of code (e.g.100.000+ programs)

Really old code (decades!)

Code comes from service providers,

in house developers, consultants,…

The code is essential for your

key business processes,…

Page 7: CD265

© 2012 SAP AG. All rights reserved. 7

Why is ABAP quality essential?

What is the impact on your business?

Page 8: CD265

© 2012 SAP AG. All rights reserved. 8

Status quo: What are customers doing to assure high quality of

custom code today?

Test DEV Production

Plus guidelines, Q reporting, …

Manual tests

Page 9: CD265

© 2012 SAP AG. All rights reserved. 9

Question

How this situation can

be improved?

Page 10: CD265

© 2012 SAP AG. All rights reserved. 10

Static Checks Unit &

Integration Testing

Manual Testing

Main pillars to achieve high quality ABAP software

Static checks – find functional, performance, security, … bugs

Unit & integration tests – create a safety net of unit tests which

always validates your functionality

Manual tests – to find sophisticated bugs

Page 11: CD265

© 2012 SAP AG. All rights reserved. 11

Done Criteria

Static Checks Unit &

Integration Testing

Manual Testing

Testing is important

Testing should be a central part of development and every body should have the same view on quality:

• Show relevant errors directly in the IDE of the developer

• Automate your tests whenever possible and run them periodically

• Define common (minimum) quality standards (which checks/errors are valid)

Page 12: CD265

© 2012 SAP AG. All rights reserved. 12

Target picture:

Let‟s build together a “perfect world” target picture…

Page 13: CD265

© 2012 SAP AG. All rights reserved. 13

Target picture: Let‟s build together a “perfect world” target picture

Step 1: Enrich the toolset of the developers

DEV

Manual tests

Acceptance and support of developers is key!

Static Checks

Unit Tests

Page 14: CD265

© 2012 SAP AG. All rights reserved. 14

Target picture: Let‟s build together a “perfect world” target picture

Step 2: Automate and block faulty transports

DEV

Periodic regression runs Static Checks

Manual tests

Unit Tests

Q-Gate:

Check during

transport release

Page 15: CD265

© 2012 SAP AG. All rights reserved. 15

Target picture: Let‟s build together a “perfect world” target picture

Step 3: Sleep well – safety net and a central Q gate

DEV Test Q-Gate:

Check during

transport release

Q-Gate:

Mass regression

run OK

Mass regression

runs

Page 16: CD265

© 2012 SAP AG. All rights reserved. 16

Target picture: Let‟s build together a “perfect world” target picture

Summary

Development System 1

Consolidation System

Development System 2

Q-experts run mass checks and distribute the results

i Use ONE quality

standard for Q-Gates

Developer run static/unit/scenario tests on their objects

Periodic check runs to validate the code of a development team

Q-Gate:

Check during

transport release

Q-Gate:

Check during

transport release

Q-Gate:

Mass check run and

consolidation test

Page 17: CD265

© 2012 SAP AG. All rights reserved. 17

Target picture: Let‟s build together a “perfect world” target picture

Scale it and do your reporting

Development

System 1

Development

System 2

Consolidation

System 1

Development

System 3

Development

System 4

Consolidation

System 2

Development

System 5

Development

System 6

Consolidation

System 3

Q-Governance: Monitors the quality of development areas and defines the quality standard

BI system for reporting:

Aggregates all mass

test runs

Page 18: CD265

© 2012 SAP AG. All rights reserved. 18

Which tools do we offer?

Let‟s start …

Page 19: CD265

Static Checks Introducing brand-new ABAP Test Cockpit

Page 20: CD265

© 2012 SAP AG. All rights reserved. 20

ABAP Test Cockpit

ABAP Test Cockpit (ATC) is a framework for running static code checks on ABAP code to find

functional, usability, performance, security, … bugs

Page 21: CD265

© 2012 SAP AG. All rights reserved. 21

ABAP Test Cockpit: What is it and what is the background/history?

ATC is the standard ABAP check frame work at SAP (for ERP, CRM, SCM, NetWeaver, ...)

ATC has been piloted successfully with two big customers with a lot of custom code

ATC customer version has been developed together with three big customers, who

reviewed the product after each development takt

Page 22: CD265

© 2012 SAP AG. All rights reserved. 22

ABAP Test Cockpit: What is it and what is the background/history?

SAP plans to release ATC for customers with:

SAP EhP 2 for SAP NetWeaver 7.0 Support Package 12

planned RTC = 14.09.2012

SAP NetWeaver AS ABAP 7.03 Support Package 05

planned RTC = 22.10.2012

The customer version of ATC is based on Code Inspector

Very easy migration: Just reuse your current global Code Inspector check variant

Page 23: CD265

© 2012 SAP AG. All rights reserved. 23

Outlook: ABAP security code scan tool

The Extended Program Check (SLIN) enhanced with security checks, with the ATC as

framework, serves as SAP‟s ABAP security code scan tool. The tool is being enhanced for the

use of customers to scan customer coding, and will be available earliest by 2013.

Integrates tightly into developer workbench and transport tools, along with instant navigation, documentation

and fix recommendation

Supports quality management processes like quality gates, regression testing and exemption handling

Developed by the ABAP Language Group, synchronous with latest ABAP developments

Incorporates input from various channels such as international security standards (OWASP, CWE), SAP‟s

product security requirements, SAP‟s security response process, development programs and task forces.

PLANNED INNOVATIONS

Page 24: CD265

© 2012 SAP AG. All rights reserved. 24

Code Inspector compatible - what does it mean?

Maintain your global check variants using Code Inspector

Code new checks using well-known Code Inspector API (independent from release)

ATC uses the global Code Inspector variant and provides many additional features

Page 25: CD265

Demo ABAP Test Cockpit for developers

Page 26: CD265

© 2012 SAP AG. All rights reserved. 26

Demo summary - ATC developer role

ATC Features

Start ATC within different ABAP workbench tools: SE80, SE24, SE38, SE11…

ATC automatically runs during release of transport requests

Easy access to central ATC results in the development systems

User-centric display of ATC results - incl. powerful filter, navigation, re-check…

Checks code during development and transport release

Corrects bugs

Requests exemptions for false-positives

Page 27: CD265

Exercise 1 ABAP Test Cockpit

Page 28: CD265

© 2012 SAP AG. All rights reserved. 28

Exemption process

Motivation

How should the developers take care of false-positive findings?

What if fix is not possible, for example, it leads to destabilization of legacy coding?

Page 29: CD265

© 2012 SAP AG. All rights reserved. 29

Exemptions process is a four-eye principle

Need an exemption?

(E.g. for false-positive) Let‟s have a look at it!

Exempted finding is marked

accordingly in the ATC result

Page 30: CD265

Demo ABAP Test Cockpit: Apply for an exemption

Page 31: CD265

Exercise 2 ABAP Test Cockpit: Apply for an exemption

Page 32: CD265

Demo ABAP Test Cockpit for quality experts and administrators

Page 33: CD265

© 2012 SAP AG. All rights reserved. 33

Demo summary - ATC quality expert role

ATC Features

Exemption approval process

E-mail ATC result to “responsible” contact person

Statistics showing aggregation of ATC findings using different criteria

Execution of ABAP Unit tests

Defines commonly used check variant

Monitors quality of the whole code base

Appoves exemptions

Page 34: CD265

© 2012 SAP AG. All rights reserved. 34

Planned ATC integration in SAP Solution Manager

ATC results from different systems can be

viewed centrally from Solution Manager

Drill down results by „User‟ and „Package‟

Overview of „Open‟ exemptions from different

consolidation systems

Navigation from Solution Manager to managed

system to access exemptions

Planned to be released with SAP Solution

Manager 7.1 SP08

i For further information, please attend the following Tech Ed 2012 courses:

ALM 220: Revitalizing Your Custom Code Strategy Professionally

ALM 270: Coding “Back to the Standard” with Custom Code Management

Page 35: CD265

© 2012 SAP AG. All rights reserved. 35

Demo summary - ATC administrator role

ATC Features

Powerful parallelization engine to run mass tests very effectively

Restart capability in case of a canceled/crashed ATC run

Possibility to schedule regular ATC runs

Powerful monitoring tool and flexible logging

Distribute ATC results to multiple target systems (e.g. from consolidation to dev. systems)

Configures ATC in development and consolidation systems

Monitors execution of ATC check runs and regular jobs

Page 36: CD265

© 2012 SAP AG. All rights reserved. 36

Static code checks Summary

Static checks are being used to automatically analyze source code for errors such as defects,

code convention violations, etc.

Major advantages

• Quick feedback, can be used early in the development cycle

• A lot of defects can be found for nearly no costs (checks come for free)

Known limitations

• Cannot verify the code against the requirements

• Certain errors only happen during runtime

Page 37: CD265

Unit Testing ABAP Unit Basics

Coverage Analyzer

Page 38: CD265

© 2012 SAP AG. All rights reserved. 38

Unit testing

Unit testing is a software verification and validation method in which a unit (method,

function module) is tested to verify that it satisfies its functional requirements.

Why unit testing?

• Allows to find problems early in the development cycle

• Unit tests can be used for regression test suits

• Provides safety net for further changes and refactorings

• Helps developers to get to know a piece of software written by someone else

Page 39: CD265

© 2012 SAP AG. All rights reserved. 39

ABAP Unit introduction

ABAP Unit is the official xUnit

testing framework for ABAP. The

most remarkable features are:

Tightly integrated into the programming

language

Production code and unit test code are

bundled and transported together

Test code cannot be executed in a

production system.

i ABAP Unit is available

with NetWeaver 04.

Page 40: CD265

© 2012 SAP AG. All rights reserved. 40

ABAP Unit syntax

ABAP Unit tests are usually implemented as local ABAP Objects classes in the main program

that contains the tested modularization units.

CLASS ltc_calculator DEFINITION FOR TESTING

RISK LEVEL HARMLESS DURATION SHORT.

PRIVATE SECTION.

METHODS: add_two_numbers FOR TESTING.

ENDCLASS.

Define class as test class

Define method as test method

Page 41: CD265

© 2012 SAP AG. All rights reserved. 41

Structure of an unit test

Establish pre

condition

Execute code

under test

Verify post condition

Clean up (optional)

Page 42: CD265

© 2012 SAP AG. All rights reserved. 42

Structure of an unit test

Establish pre

condition

Execute code

under test

Verify post condition

Clean up (optional)

CLASS ltc_calculator IMPLEMENTATION.

METHOD add_two_numbers.

CREATE OBJECT calculator.

result = calculator->add( a = 2 b = 3 ).

cl_aunit_assert=>assert_equals( exp = 5

act = result ).

ENDMETHOD.

ENDCLASS.

Page 43: CD265

© 2012 SAP AG. All rights reserved. 43

Structure of an unit test

Establish pre

condition

Execute code

under test

Verify post condition

Clean up (optional)

CLASS ltc_calculator IMPLEMENTATION.

METHOD add_two_numbers.

CREATE OBJECT calculator.

result = calculator->add( a = 2 b = 3 ).

cl_aunit_assert=>assert_equals( exp = 5

act = result ).

ENDMETHOD.

ENDCLASS.

Page 44: CD265

© 2012 SAP AG. All rights reserved. 44

Structure of an unit test

Establish pre

condition

Execute code

under test

Verify post condition

Clean up (optional)

CLASS ltc_calculator IMPLEMENTATION.

METHOD add_two_numbers.

CREATE OBJECT calculator.

result = calculator->add( a = 2 b = 3 ).

cl_aunit_assert=>assert_equals( exp = 5

act = result ).

ENDMETHOD.

ENDCLASS.

Page 45: CD265

© 2012 SAP AG. All rights reserved. 45

Structure of an unit test

Establish pre

condition

Execute code

under test

Verify post condition

Clean up (optional)

CLASS ltc_calculator IMPLEMENTATION.

METHOD add_two_numbers.

CREATE OBJECT calculator.

result = calculator->add( a = 2 b = 3 ).

cl_aunit_assert=>assert_equals( exp = 5

act = result ).

ENDMETHOD.

ENDCLASS.

Page 46: CD265

© 2012 SAP AG. All rights reserved. 46

Assertion methods

Used to determine whether a test is successful or not

The utility class CL_AUNIT_ASSERT offers various methods

All assert methods allow you to add a message via the parameter (MSG) which will be displayed in the UI

Assertion Method Description

ASSERT_EQUALS Ensure equality of two data objects

ASSERT_INITIAL Ensure that object has its initial value

ASSERT_NOT_INITIAL Ensure that object does not have its initial value

ASSERT_SUBRC Ensure that return code subrc has specific value

FAIL Terminate test due to an error

i Release SAP NetWeaver 7.0 EhP 2

use CL_ABAP_UNIT_ASSERT

Page 47: CD265

© 2012 SAP AG. All rights reserved. 47

ABAP Unit runtime

All test methods are executed

independently from each other

Execution is in undefined order

Multiple test classes are executed

in sequence

One rollback at the end of each

test class

Page 48: CD265

© 2012 SAP AG. All rights reserved. 48

Execute unit tests

Page 49: CD265

Exercise 3 Write simple ABAP unit test

Page 50: CD265

© 2012 SAP AG. All rights reserved. 50

Is this test sufficient?

METHOD divide. “ Test method

CREATE OBJECT calculator.

result = calculator->divide(

a = 12

b = 4 ).

cl_abap_unit_assert=>assert_equals(

exp = 3

act = result ).

ENDMETHOD.

METHOD divide. “ Production method

IF ( b <> 0 ).

result = a / b.

ELSE.

RAISE EXCEPTION TYPE

lcx_invalid_parameter.

ENDIF.

ENDMETHOD.

Page 51: CD265

© 2012 SAP AG. All rights reserved. 51

Find untested code by measuring code coverage

METHOD divide. “ Test method

CREATE OBJECT calculator.

result = calculator->divide(

a = 12

b = 4 ).

cl_abap_unit_assert=>assert_equals(

exp = 3

act = result ).

ENDMETHOD.

METHOD divide. “ Production method

IF ( b <> 0 ).

result = a / b.

ELSE.

RAISE EXCEPTION TYPE

lcx_invalid_parameter.

ENDIF.

ENDMETHOD.

Page 52: CD265

© 2012 SAP AG. All rights reserved. 52

Measure coverage your unit tests produce

From ABAP Unit Browser (SAP EhP 2 for SAP

NetWeaver 7.0)

Create a favorite and adjust options to execute it

with coverage measurement

Access combined result

From Editor (SAP NetWeaver AS ABAP 7.03)

Via menu “Run -> Unit Tests -> With Coverage”

Page 53: CD265

Demo Measuring code coverage with ABAP Unit Browser

Page 54: CD265

Exercise 4 Measure code coverage with ABAP Unit Browser

Page 55: CD265

© 2012 SAP AG. All rights reserved. 55

Is it possible to write a unit test for this piece of code?

Page 56: CD265

© 2012 SAP AG. All rights reserved. 56

The correct answer is …

NO

Page 57: CD265

© 2012 SAP AG. All rights reserved. 57

What makes unit testing hard?

No separation between business logic, database

and user interface

Dependencies, e.g. to other components

Legacy code

Page 58: CD265

© 2012 SAP AG. All rights reserved. 58

Best practices for testability

Developing new software

Make use of object oriented programming

Take control of dependencies

Write clean code

Try to write test and domain code simultaneously

Page 59: CD265

© 2012 SAP AG. All rights reserved. 59

Question

What about legacy

code?

Page 60: CD265

© 2012 SAP AG. All rights reserved. 60

Write unit tests for legacy code while…

Fixing a bug

Adding new functionality

Optimizing resources

Refactoring

Page 61: CD265

© 2012 SAP AG. All rights reserved. 61

How to make legacy code testable?

Cover & Modify

Identify change points

Find & break dependencies

Write characterization tests

Refactor and write unit tests

Make changes (bug fix, new feature…)

Use unit tests for regression

Page 62: CD265

© 2012 SAP AG. All rights reserved. 62

Is this code easier to test? ;-)

Page 63: CD265

© 2012 SAP AG. All rights reserved. 63

Start your journey…

1) Realize that writing good automated tests is a competence which requires practice and experience

2) Try to find someone who starts this journey with you. It is much more motivating if you can share your

experiences with another person

3) Review a small report you wrote and see if you can write tests for it. If you can't, find out why (look for hard

coded dependencies, etc.)

4) Experiment with dealing with database code. How to encapsulate it, how to replace it, ...

5) Try to write tests for your next program

If you need motivation then read this inspiring blog post from an ABAP developer who already successfully

managed to acquire this new competency.

Page 64: CD265

© 2012 SAP AG. All rights reserved. 64

Recommended reading

• Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin)

ISBN 978-0-13-235088-4

• xUnit Test Patterns: Refactoring Test Code (Gerard Meszaros)

ISBN 978-0-13-149505-0

• Working Effectively With Legacy Code (Michael C. Feathers)

ISBN 0-13-117705-2

Page 65: CD265

Our Test Strategy

Page 66: CD265

© 2012 SAP AG. All rights reserved. 66

Wrap up: testing pyramid

Manual Testing

Integration Tests

Unit Tests

Static checks Static analysis of source code to find defects. Allows

quick feedback for developers. Executed daily

Fast running tests written for a single unit. Ensure that the

unit works as specified. Executed after every code change

Combine all units and make sure that they work correctly

together. Executed daily

Designed to find requirements violations and complex

defects (What if?). Executed before the release of software

Page 67: CD265

© 2012 SAP AG. All rights reserved. 67

Manual testing

Manual testing technique we use is Exploratory Testing

i http://en.wikipedia.org/wiki/Exploratory_testing

Test Tour Session Based Session Notes

Less time consuming,

low planning effort

Creative, but still

focused on

something particular

Traceable

Page 68: CD265

© 2012 SAP AG. All rights reserved. 68

Key take-aways

ABAP Test Cockpit for static checks

ABAP Unit and Coverage Analyzer for unit and integration tests

Exploratory Testing for finding the complex bugs

Page 69: CD265

Troubleshooting Tools ABAP Debugger

ABAP Runtime Analysis (SAT, previous SE30)

Page 70: CD265

ABAP Debugger

Page 71: CD265

© 2012 SAP AG. All rights reserved. 71

ABAP Debugger: Agenda

Basic features

Advanced features

Exercise

Expert features

Page 72: CD265

© 2012 SAP AG. All rights reserved. 72

ABAP Debugger: Agenda

Basic features

Advanced features

Exercise

Expert features

Page 73: CD265

© 2012 SAP AG. All rights reserved. 73

ABAP Debugger: Basic features

I am still using the classic ABAP debugger…

The “new” ABAP debugger has so many buttons…

Why should I change, the old one is good enough…

Page 74: CD265

Demo ABAP Debugger basics & motivation

Page 75: CD265

© 2012 SAP AG. All rights reserved. 75

ABAP Debugger: Agenda

Basic features

Advanced features

Exercise

Expert features

Page 76: CD265

© 2012 SAP AG. All rights reserved. 76

ABAP Debugger: Advanced features

When do I use the different breakpoint types and what

are watchpoints good for?

Why do I never stop at my breakpoints?

Page 77: CD265

© 2012 SAP AG. All rights reserved. 77

Line breakpoint: Stop at a specific source line

Page 78: CD265

© 2012 SAP AG. All rights reserved. 78

Breakpoints types and breakpoint scope

How many different breakpoint types do exist?

Debugger breakpoints

scope: debugging session

set in: debugger

Session breakpoints

scope: logon session

set in: development workbench

User (external) breakpoints

scope: all logon sessions (for one user on one server)

set in: development workbench

4. type:

BREAK-POINT.

BREAK <User-Name>.

Break-POINT ID <Group-ID>

Page 79: CD265

© 2012 SAP AG. All rights reserved. 79

Breakpoint at …

Page 80: CD265

© 2012 SAP AG. All rights reserved. 80

Watchpoints: Watch the content of variables

If you set a watchpoint on the field matnr

(+ condition matnr = '1234'), then the debugger stops as soon as matnr changes and contains the

value „1234'.

If you do not specify a condition, the debugger stops as soon as the field matnr changes.

Matnr = 0000

Watchpoint: Matnr = 1234

Matnr = 0120 Matnr = 1234

Program flow

Page 81: CD265

© 2012 SAP AG. All rights reserved. 81

Create a watchpoint

Specify variable

stop on change of variable

all global, local variables

including internal tables

not possible: debugger symbols pointing into internal tables e.g.: “itab[1]-comp”

Specify variable & condition

stop when variable changes AND condition is true

condition restricted to two operands and 1 operator

built-in functions ( “lines( )” and “strlen( )” ) possible e.g.: “sy-subrc <> 0” or “strlen( string ) > 10”

Can be activated / inactivated

Page 82: CD265

© 2012 SAP AG. All rights reserved. 82

News in Breakpoints and Watchpoints with SAP EhP2 for SAP

NetWeaver 7.0

Now you can set a breakpoint

on ABAP command (incl. F4 Help support)

on method of a class

on a row of a Simple Transformation template

on Web Dynpro entities (component, controller, method)

on a (special) message

…and add condition to it

Now you can set a watchpoint

on internal table

on object

on object attribute

… and add condition to it

Page 83: CD265

Demo ABAP Debugger: Breakpoints and watchpoints

Page 84: CD265

© 2012 SAP AG. All rights reserved. 84

Compare variables in the debugger

Use the debugger Diff tool !

Why is XLINE <> XLINE2?

Find the difference !!

(XLINE and XLINE2 are only 2000 bytes long …)

Page 85: CD265

Demo ABAP Debugger: Comparing variables with the Diff tool

Page 86: CD265

© 2012 SAP AG. All rights reserved. 86

ABAP Debugger: Agenda

Basic features

Advanced features

Exercise

Expert features

Page 87: CD265

Exercise 5 ABAP Debugger basics

Page 88: CD265

© 2012 SAP AG. All rights reserved. 88

ABAP Debugger: Agenda

Basic features

Advanced features

Exercise

Expert features

Page 89: CD265

© 2012 SAP AG. All rights reserved. 89

ABAP Debugger: Expert features I

Layer aware debugging

I debug through tons of standard code…

I want to focus on my code which I added yesterday!

Page 90: CD265

© 2012 SAP AG. All rights reserved. 90

Layer aware ABAP debugging:

Layer aware ABAP debugging

Define your zone of interest (e.g. custom code) and hide the rest

during debugging

Jump from layer to layer or from component to component instead of

single stepping through the code

UI

Application DB

Page 91: CD265

© 2012 SAP AG. All rights reserved. 91

Step 1: Defining object set (“layer”)

Selection Set

S1

Packages: P1, P2, P3

Selection Set

S2

Class: CL_1, CL_2

Selection Set Criteria: Packages (w/ or w/o sub-packages)

Programs / Classes

Function Modules

Implementing interface

Expression

„S1 AND ( NOT S2 )“

Object Set („Layer“)

L1 S1 S2

Expr

Expression:

Use selection set names as operands

Use any logical operand, ABAP-like

Object Set (Layer)

Transport Object

Global, Local, Favorites

Page 92: CD265

© 2012 SAP AG. All rights reserved. 92

Step 2: Define how the debugger behaves in the layers: debugger profile

L1(e.g. my package)

<<REST>>

L2( e.g. ALV stuff)

Visible Point of

Entry

Point of

Exit

Incl.

System

Code

„Rest code“,

not covered by any other

layer, can be excluded

Normal debugger stepping:

not visible = „system code“,

line breakpoints not hidden

„Layer stepping“:

Stop at layer entry

„Layer stepping“:

Stop at layer exit

What to do with

system code inside

layer

Page 93: CD265

Demo ABAP Debugger: Layer aware debugging

Page 94: CD265

Exercise 6 Layer aware debugging

Page 95: CD265

© 2012 SAP AG. All rights reserved. 95

ABAP Debugger: Expert features II

Debugger scripting

Why waiting for new debugger features delivered

by SAP?

I want to add my own specific breakpoint types, a

new variable display, specific traces …

Page 96: CD265

© 2012 SAP AG. All rights reserved. 96

Automated debugging: Debugger scripting

Session 1 - Debuggee

ABAP VM

Session 2 - Debugger

UI

Debugger Engine

A

D

I

… doDebugStep( SingleStep )

setBreakpoint ( )

setWatchpoint( )

getValue( „SY-SUBRC‟ )

getStack ( )

Page 97: CD265

© 2012 SAP AG. All rights reserved. 97

Automated debugging: Debugger scripting

Session 1 - Debuggee

ABAP VM

Session 2 - Debugger

UI

Debugger Engine

A

D

I

ABAP-

Script

“doDebugStep( )”

“setBreakpoint ( )”

“setWatchpoint( )”

“getValue( „SY-SUBRC‟ )”

“getStack ( )”

“writeTrace( )”

Page 98: CD265

© 2012 SAP AG. All rights reserved. 98

Automated debugging: Debugger scripting

The debugger script can be triggered for:

• Each single step in the application

• Breakpoint is reached

• Watchpoint is reached

Session 2 - Debugger

UI

A

D

I

ABAP-

Script

It‟s ABAP !

Page 99: CD265

© 2012 SAP AG. All rights reserved. 99

Automated debugging: Debugger scripting

Examples

Statement trace

Conditional break-points

„Stop only for special programs“

Whatever you can imagine …

Use standard ABAP enriched by

debugger functionality in your

debugger script

Page 100: CD265

Demo ABAP debugger: Debugger scripting

Page 101: CD265

ABAP Runtime Analysis

Page 102: CD265

© 2012 SAP AG. All rights reserved. 102

ABAP Runtime Analysis: Overview I

ABAP Runtime Analysis – Overview

Enables you to execute a performance and program flow analysis

of any ABAP application.

Program flow analysis - ABAP trace

Only this tools is able to trace the flow of ABAP programs on statement level. (except debugger scripting…)

Find the location of the statement you are interested in

Compare the flow of the application in different clients / systems

Find special function modules, e.g. your USER EXITS

Trace the memory consumption of your application

Performance analysis - Hit lists

Determine the specific bottleneck area of the program (ABAP vs. SQL, a special method or function module)

Determine the SQL or ABAP statement causing the highest load

Page 103: CD265

© 2012 SAP AG. All rights reserved. 103

ABAP Runtime Analysis: Overview II

What is measured?

Not all ABAP statements, but only those which are potentially expensive in terms of CPU time.

The most significant of these are:

DB accesses: Select, Exec SQL,

Modul. units: Module, CALL Function, CALL Screen, CALL Transaction,

CALL Dialog

Internal tables: Append, Collect, Sort, Read Table, Read Dataset

File handling: Transfer, Open Dataset

Others: EXPORT … TO …, IMPORT … FROM …, Rollback, …

SET PF-STATUS, SET TITLEBAR, MESSAGE, ASSIGN

How is it measured?

During runtime analysis the system measures the statements listed above.

The system stores the measurements in central trace containers on the database.

You can evaluate the measurement on any server of the system immediately or at a later time.

The system subtracts the CPU consumption needed for doing the measurement from the total CPU consumption.

Page 104: CD265

© 2012 SAP AG. All rights reserved. 104

ABAP Runtime Analysis: SAT – ABAP Trace

New runtime analysis (SAT) is available

with SAP EhP2 for SAP NetWeaver 7.0

Page 105: CD265

Demo ABAP Runtime Analysis: Basics and program flow analysis

Page 106: CD265

© 2012 SAP AG. All rights reserved. 106

ABAP Runtime Analysis

SAT – performance analysis

Page 107: CD265

© 2012 SAP AG. All rights reserved. 107

ABAP Runtime Analysis: Performance problems

Strategy

Restrict the trace file as much as possible (variant) - especially for long

running programs. Otherwise the file quota will be exceeded quickly.

Start with “by call” aggregation (only hit list available)

Restrict the statements – e.g. only modules (functions, forms, methods …)

Restrict the analysis in a second trace to the performance killing modules

Trace only the relevant part of the transaction with the restriction “Explicit Switching on and Off of Measurement”

Page 108: CD265

Demo ABAP Runtime Analysis – performance analysis

Page 109: CD265

Outlook: ABAP Development Tools

for SAP NetWeaver

Page 110: CD265

© 2012 SAP AG. All rights reserved. 110

ABAP Development Tools for SAP NetWeaver

• ABAP Test Cockpit

• ABAP Unit Test Runner

• Coverage Analyzer

• ABAP Debugger

• ABAP Profiling tools

Page 111: CD265

Demo ABAP Development Tools for SAP NetWeaver

Page 112: CD265

© 2012 SAP AG. All rights reserved. 112

Further information

Watch SAP TechEd Online

www.sapteched.com/online

Related Workshops/Lectures at SAP TechEd 2012

CD101, The Brand-New ABAP Test Cockpit – A New Level of ABAP Quality Assurance, Lecture (1hr)

ALM220, Revitalizing Your Custom Code Strategy Professionally, Lecture (1hr)

ALM270, Code “Back to Standard” with Custom Code Management, Hands-on (2hr)

CD164, Modern ABAP with ABAP Development Tools for Eclipse, Hands-on (4hr)

CD201, ABAP Development Tools for Eclipse – Develop Like Never Before, Lecture (1hr)

Page 113: CD265

© 2012 SAP AG. All rights reserved. 113

Further information

SAP Public Web

Agile Software Development under ABAP

http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/20d4036a-8d9b-2e10-6f82-

c807290b91a2

The ABAP Workbench and the Test-Driven Development Cycle in EHP1

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/20447

Managing Dependencies in TDD: Constructor Injection in ABAP in EHP1

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/20616

Page 114: CD265

Feedback Please complete your session evaluation for CD265.

Thanks for attending this SAP TechEd session.

Page 115: CD265

© 2012 SAP AG. All rights reserved. 115

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, Excel, Outlook, PowerPoint, Silverlight, and Visual Studio are registered trademarks of

Microsoft Corporation.

IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System

z10, z10, z/VM, z/OS, OS/390, zEnterprise, PowerVM, Power Architecture, Power Systems, POWER7,

POWER6+, POWER6, POWER, PowerHA, pureScale, PowerPC, BladeCenter, System Storage, Storwize,

XIV, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, AIX, Intelligent Miner, WebSphere,

Tivoli, Informix, and Smarter Planet are trademarks or registered trademarks of IBM Corporation.

Linux is the registered trademark of Linus Torvalds in the United States and other countries.

Adobe, the Adobe logo, Acrobat, PostScript, and Reader are trademarks or registered trademarks of Adobe

Systems Incorporated in the United States and other countries.

Oracle and Java are registered trademarks of Oracle and its affiliates.

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.

Apple, App Store, iBooks, iPad, iPhone, iPhoto, iPod, iTunes, Multi-Touch, Objective-C, Retina, Safari, Siri,

and Xcode are trademarks or registered trademarks of Apple Inc.

IOS is a registered trademark of Cisco Systems Inc.

RIM, BlackBerry, BBM, BlackBerry Curve, BlackBerry Bold, BlackBerry Pearl, BlackBerry Torch, BlackBerry

Storm, BlackBerry Storm2, BlackBerry PlayBook, and BlackBerry App World are trademarks or registered

trademarks of Research in Motion Limited.

© 2012 SAP AG. All rights reserved.

Google App Engine, Google Apps, Google Checkout, Google Data API, Google Maps, Google Mobile Ads,

Google Mobile Updater, Google Mobile, Google Store, Google Sync, Google Updater, Google Voice,

Google Mail, Gmail, YouTube, Dalvik and Android are trademarks or registered trademarks of Google Inc.

INTERMEC is a registered trademark of Intermec Technologies Corporation.

Wi-Fi is a registered trademark of Wi-Fi Alliance.

Bluetooth is a registered trademark of Bluetooth SIG Inc.

Motorola is a registered trademark of Motorola Trademark Holdings LLC.

Computop is a registered trademark of Computop Wirtschaftsinformatik GmbH.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjects Explorer, StreamWork,

SAP HANA, 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 other countries.

Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web

Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their

respective logos are trademarks or registered trademarks of Business Objects Software Ltd. Business Objects

is an SAP company.

Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere, and other Sybase products and services

mentioned herein as well as their respective logos are trademarks or registered trademarks of Sybase Inc.

Sybase is an SAP company.

Crossgate, m@gic EDDY, B2B 360°, and B2B 360° Services are registered trademarks of Crossgate AG

in Germany and other countries. Crossgate is an SAP company.

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.

Page 116: CD265

© 2012 SAP AG. All rights reserved. 116

Test Coverage – Mass Run

Prepare system for activation of coverage analysis

Execute unit tests via Code Inspector

Collect coverage results

Access coverage results in transaction SCOV

Procedure

Page 117: CD265

© 2012 SAP AG. All rights reserved. 117

Test Coverage – Mass Run

Create a special user account – grant authorizations

Create in SCOV test group

Register special user to test group

Preparation

Page 118: CD265

© 2012 SAP AG. All rights reserved. 118

Test Coverage – Mass Run

Launch unit tests via Code Inspector

Wait until inspection is finished

Collect results – Report RSCVR_TRIGGER_COLLECT

(can be scheduled from SCOV\admin)

Execution

Page 119: CD265

© 2012 SAP AG. All rights reserved. 119

Test Coverage – Mass Run

Start Transaction SCOV

Choose detail display

Use test group and package name as filter

Evaluation

Page 120: CD265

© 2012 SAP AG. All rights reserved. 120

Test Coverage – Mass Run

Reset coverage data for test group

Launch unit test from Code Inspector

Wait until Inspection is finished

Collect coverage results

Start a new measurement

Page 121: CD265

© 2012 SAP AG. All rights reserved. 121

Test Coverage – Mass Run

Create a measurement with help of CL_SCV_COVERAGE_API

Start Measurement

Launch unit test from Code Inspector

Wait until Inspection is finished

Stop Measurement

Get Result

Coverage API (Release 7.32 Onwards)