ABAP Debug Scripting - Intro Presentation

21
Use this title slide only with an image ABAP Debug Scripting Jared Coyle May 9, 2014 Inter nal

description

ABAP Debug Scripting - Intro Presentation

Transcript of ABAP Debug Scripting - Intro Presentation

Use this title slide only with an image

ABAP Debug ScriptingJared CoyleMay 9, 2014 Internal

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 2Internal

Agenda

ABAP Debug Scripting Basics The Debug Scripter Transaction SAS Script Wizard Functionality Project Deliverable: Guide to Debug

Scripting Wizard Scripts

Basic All Statements Trace Demo

Custom Scripts Demo Memory Analyzer RFC Tracer Code Deletion Code Insertion

Future Work

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 3Internal

The ABAP Debug Scripter

Integrated into ABAP debugger as of NW 7.0 EHP 2

Exists as an additional tab (Script) within the debugger

Allows automation of standard debugger functions through the execution of scripted ABAP at specific watchpoints/breakpoints

Key challenge: no documentation

Key utility: Can expedite repetitive debugging processes

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 4Internal

The ABAP Debug Scripter – How it works

Debuggee (Program)

6.Script Runs

Debugger (Script)

3.Program Executes

8.Program Continues

4.Scripter Breakpoint

5.Pass Control to Debugger

7.Return control

to Debuggee

10.Exit Script

1.Start Script2.Pass Control to Debugee

9.Manual Return to Debugger

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 5Internal

ABAP Debug Scripter Layout

Control Area

Breakpoint Area

Trace Area

Scripting Area

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 6Internal

ABAP Debug Scripter Layout

Control Area

Breakpoint Area

Trace Area

Scripting Area

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 7Internal

ABAP Debug Scripter Layout

Control Area

Breakpoint Area

Trace Area

Scripting Area

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 8Internal

ABAP Debug Scripter Layout

Control Area

Breakpoint Area

Trace Area

Scripting Area

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 9Internal

Class lcl_debugger_script

Prologue

Super->prologue() method necessary if source code information is to be used in the debug scripter

Init

Script

End

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 10Internal

Class lcl_debugger_script

Prologue

Init

Initializes script, only run once

Script

Contains the logic of the script

End

Called after script, useful if you close resources or aggregate data

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 11Internal

Transaction SAS: ABAP Debugger Scripting & Tracing

View List of All Debugger Trace Files

Display Traces

Script Editor

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 12Internal

Transaction SAS: ABAP Debugger Scripting & Tracing

View List of All Debugger Trace Files

Display Traces

Statement Traces

Call Hierarchy Traces

Custom Traces

Script Editor

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 13Internal

Transaction SAS: ABAP Debugger Scripting & Tracing

View List of All Debugger Trace Files

Display Traces

Script Editor rdisp/max_debug_lazy_time=600 More time is needed to write complex

scripts Has all functionality of debug scripter

except execute

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 14Internal

ABAP Debugger Script Wizard Functionality

Variable Information/Control

Set/get functionality for all variable types

Source Code Information

Read information on current source code type and location

Breakpoints/Watchpoints

Set breakpoints within the scripting itself

Debugger Control

F5, F6, F7, F8, GoTo

Script Control

Can interrupt or abort script in logic

Tracing

Statement, call hierarchy and custom traces

Table Operations Analysis

Allows limited analysis of table (internal and DB) related statements*

Pre-Packaged scripts

A variety of pre-made tools for RCA

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 15Internal

Project Deliverable: Guide to Debug Scripting Scripts (Sample)

Debug Step (F5, F6, etc.)

This is the basic script used to execute explicit debug steps within the execution of your script itself. That is, it lets you run an F5, F6, F7, and F8 step from the code itself. A guide to the codes is below, and additional codes can be found in interface IF_TPDA_CONTROL.

Debugger Keycode

Variable name in IF_TPDA_CONTROL

P_COMMAND value

F5 Mc_stepinto 1F6 Mc_stepover 2F7 Mc_stepout 3F8 Mc_continue 4

Ctrl+F6 Mc_layer_stepinto 8N/A Mc_stop 0

ABAP Debug Scripter BasicsIn-System Demo – Full Statement Trace

Sample ScenariosMemory Analyzer

RFC Tracer

Line Deletion

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 18Internal

Sample Scenario: Memory Utilization Analyzer

Business Scenario

Customer contacts SAP stating that memory utilization of a particular program/report is high. They would like to know where in the code this high memory utilization comes from.

Breakpoint at Stack Change*

*Break at stack change can cause performance problems for transaction codes with lots of stack changes on the system level

Breakpoint Declare Data Import Mem

Before Placeholders

for all data for custom trace

Strings for writing numerical values for custom traces

Current location in code

Brings in all memory parameters Mem allocated Mem used Heap Roll Paging Short

Assign Mem

Assign memory values to their own variables to be written to custom trace

Trace

Write current statement trace

Write Custom trace of all parameters

Write Stack Trace

Click Here for Script

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 19Internal

Sample Scenario: RFC Tracer

Business Scenario – OSS Incident 287778 2014

Customer contacts SAP and reports that loading of particular report from EH&S to ECC system is slow. STAD records indicate high RFC times, but STAD only contains the statistical average and the 5 longest RFC calls. An RFC trace only reveals 5 RFC calls as well, but the customer expects many more RFC calls. The customer wishes to clarify if only 5 RFCs are actually occurring, and how long each is taking.

At ‘RFC’ or ‘Call Function Destination’

Breakpoint Statement Trace Timestamp

Captures the statement (the function called and the destination) with a link to the call in the code

Gets a system timestamp for trace resolution down to ns time scale

Provides RFC start time

F5 Step

Executes the RFC itself

Timestamp

Provides RFC end time

Custom Trace

Write duration of RFC to custom trace

Click Here for Script

© 2014 SAP AG or an SAP affiliate company. All rights reserved. 20Internal

Sample Scenario: ‘Delete’ a Line of Code

Business Scenario – OSS Incident 302843 2014

Customer recently upgraded ECC. Upgrade included a modification to extractor 0CO_PC_PCP_30. For performance reasons, recursive materials are no longer considered by the extractor. The key value used for reporting from the extracted data now deviates from it’s target value by up to 0.4%, as opposed to 0.01%. The developer has provided an extension (deletion of a line of code) to Note 1597502 to include recursion in the process. Customer wants to verify that this simple line deletion will actually address the problem.

Break at specific line of code where deletion is desired

Breakpoint Source Position Conditional Logic

Reads the source position.

Input an IF or CASE statement in a situation where multiple line deletions are required

Statement Trace

To indicate the line being deleted

GoTo Statement

Initiate a GoTo to skip to the first ABAP statement after the deletion

Statement Trace

A statement trace to verify successfulGoTo

(if an incorrect value is passed to the GoTo function it will not raise an exception)Click here for ScriptSampleProgram.txt

© 2014 SAP AG or an SAP affiliate company. All rights reserved.

Thank you

Contact information:

Jared P. [email protected]