Advanced Debugging in ABAP

46
IBM Global Business Services Advanced Debugging 06/08/22 © 2007 IBM Corporation Advanced features of ABAP debugger

description

Advanced Debugging in ABAP

Transcript of Advanced Debugging in ABAP

Page 1: Advanced Debugging in ABAP

IBM Global Business Services

Advanced Debugging 04/21/23 © 2007 IBM Corporation

Advanced features of ABAP debugger

Page 2: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation2 04/21/23Advanced Debugging

Objectives

Upon Completing the course the participant will be able to Use the advanced features of ABAP debugging

Debug SAPscripts, Smartforms and ALV Layout

Access runtime SAP and ABAP memory through debugging

Debug a background job

Set and use additional parameters during debugging

Page 3: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation3 04/21/23Advanced Debugging

Course Outline

Advanced features of ABAP debugger Split screen debugging Search in internal table during debugging Debugging from a pop-up screen Display Unicode alignment bytes during debugging Saving and loading of different sessions Downloading of internal tables into Excel files Accessing Higher level variables/ Internal Tables Debugging in Loops Debugging Remote Function Call Navigation

Debugging Sapscript, Smartforms and ALV layout Debug a SAPscript Debug a Smartform Debug a ALV Report

Page 4: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation4 04/21/23Advanced Debugging

Course Outline (Contd)

SAP and ABAP Memory To view data in SAP memory during debugging

To view data in ABAP memory during debugging

Debugging a Background Job How to debug a background job

Different settings and their use during debugging How to Use of System Debugging

How to use Update debugging

Use other settings during debugging

Page 5: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation5 04/21/23Advanced Debugging

Split Screen Debugging (the New Debugger)

Difference between a Classic Debugger and a Split Screen Debugger Classic Debugger is used for releases up to 6.40 and the Split Screen Debugger is

used for the releases after 6.40

The New Debugger is executed in one session while the application to be analyzed uses a separate external session.

The Classic Debugger runs in the same session, where the application is analyzed and so it is shown in the same window.

Page 6: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation6 04/21/23Advanced Debugging

Split Screen Debugging (the New Debugger)

Make settings for the new Debugger After executing the transaction, choose the Menu path Utilities - > Settings. In the User

Specific Settings, choose the Debugging tab in the ABAP Editor

Debugging Tab

New Debugger Radio Button

Page 7: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation7 04/21/23Advanced Debugging

Split Screen Debugging (the New Debugger)

Some Advantages of the New Debugger

Two tables are shown simultaneously

Internal tables can be edited easily

Page 8: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation8 04/21/23Advanced Debugging

Split Screen Debugging (the New Debugger)

Limitations of the new Debugger It is not possible to set Watch Points in the New Debugger.

Debugging special types (http, BSP, RFC, update task) are not possible in the new Debugger

Display of System areas are not possible in New Debugger

Page 9: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation9 04/21/23Advanced Debugging

Search in internal table during debugging

In Debug Mode, give the Internal table name and press the Find Button.

Internal Table name

Find Button

Page 10: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation10 04/21/23Advanced Debugging

Search in internal table during debugging

Put the values The required row is highlighted

Page 11: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation11 04/21/23Advanced Debugging

Debugging from a Pop-Up Screen

It is not possible to debug in a normal way from a pop-up screen since the transaction code cannot be given. So to debug from a pop-screen Create a SAP GUI shortcut on the desktop.

Edit the shortcut and edit it to Type = ’System Command’ and Command = ’/h’.

Edit Type and Command

Page 12: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation12 04/21/23Advanced Debugging

Debugging from a Pop-Up Screen

Drag and Drop the short cut on the pop-up screen. Now it is possible to debug from the pop-up screen.

Put the Icon in the Pop-Up Screen

Page 13: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation13 04/21/23Advanced Debugging

Display Unicode alignment bytes during debugging

While in the debugger, use menu option Goto->Display Data Object-> System Information to display the Unicode fragment view for a structure with mixed data types

Page 14: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation14 04/21/23Advanced Debugging

Saving and Loading of different sessions

After giving the Break-Points, go to the Menu Debugging- Sessions

Give the Name and the Expiration in the Next Screen to save the breakpoints

Page 15: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation15 04/21/23Advanced Debugging

Downloading of internal tables into Excel files

Press the Table Button and give internal table name and press the Save Excel Worksheet Button

Page 16: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation16 04/21/23Advanced Debugging

Downloading of internal tables into Excel files

Give the file name and path to save the internal table

Page 17: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation17 04/21/23Advanced Debugging

Accessing higher level variables/Internal tables

Enter internal name with its calling program name in format shown

While coding in an exit, you want to know the values contained in the internal table XKOMV of the SAP

program SAPLV61A.

But you do not have access to that internal

table. So how do you see the values in the

debugger??

Page 18: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation18 04/21/23Advanced Debugging

Accessing higher level variables/Internal tables

Double-click on the internal table name to see values stored in it

If required, we can define a field-symbol and gain access to

this table field values from an ABAP

program

Page 19: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation19 04/21/23Advanced Debugging

Debugging in Loops

Set a break point within Loop, where program needs to be stopped.

Page 20: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation20 04/21/23Advanced Debugging

Debugging in Loops

Go to Break Point Tab. Enter the Number of Counts (99) against the variable name

Page 21: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation21 04/21/23Advanced Debugging

Debugging in Loops

Press continue button, program will stop after the above mentioned loop passes plus one i.e. 100th record.

Page 22: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation22 04/21/23Advanced Debugging

Debugging Remote Function Calls

Go to Transaction SM58 (Transactional RFC)

Press Execute .

From the list displayed select your relevant record for the failed RFC

Failed transactional

RFC calls normally get

logged in SM58

Page 23: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation23 04/21/23Advanced Debugging

Debugging Remote Function Calls

Follow this Menu path in SM58 after selecting the relevant line

You reach the debugging screen and proceed for debugging as normal

Page 24: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation24 04/21/23Advanced Debugging

Navigation

Current Control

Go To Statement

Go To Control

Page 25: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation25 04/21/23Advanced Debugging

Navigation

But It is not possible to go to a statement of a previous Event which has already been executed.

Navigation From Line 85 to Line 74 is not

possible

Page 26: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation26 04/21/23Advanced Debugging

Debug a SAP Script

Go to SE71 and open the layout desired. Select menu Utilities -> Activate Debugger or execute the ABAP Program 'RSTXDBUG'

Go to Form Debugger

Page 27: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation27 04/21/23Advanced Debugging

Debug a SAP Script

SAP Script form debugger appears.

Page 28: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation28 04/21/23Advanced Debugging

Debug a SAP Script

To trace in a SAP Script give all the values * and press the Trace on/off

button. Print Layout is appeared.

Page 29: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation29 04/21/23Advanced Debugging

Debug a SAP Script

Click the Back Button and SAPscript debugger trace report will be displayed

Page 30: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation30 04/21/23Advanced Debugging

Debug a Smart Form

Execute the transaction ‘SMARTFORMS’ give the Form Name and Execute it to get the Function Module which is generated

Page 31: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation31 04/21/23Advanced Debugging

Debug a Smart Form

Error, message ID and number appears as an output

Page 32: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation32 04/21/23Advanced Debugging

Debug a Smart Form

.

To get the Error, execute the Function

Module in Debug Mode and set the Breakpoint

at Raise statement

Press F8 to check the type of formatting or internal error and observe the message number and tally the same with the initial message number displayed.

Page 33: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation33 04/21/23Advanced Debugging

Debug a Smart Form

Again Press F8 or Continue button. As the breakpoint has been set at the raise error statement now proceed by single step debugging or F5 to locate the function module SSFRT_READ_ERROR .

Page 34: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation34 04/21/23Advanced Debugging

Debug a Smart Form

Delete all the break-points and put the break-point at ‘CASE L_ERROR-ERRNUMBER(2)’ statement

Delete Break Point

Create Break Point

Page 35: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation35 04/21/23Advanced Debugging

Debugging an ALV Report

In the Function Module, set I_INTERFACE_CHECK = ‘X’

Debugging an ALV Report can be done only in the list format

Page 36: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation36 04/21/23Advanced Debugging

Debugging an ALV Report

The Fieldcatalogue, Layout and the errors are shown in screen

Execute the ALV Report to see the result

Page 37: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation37 04/21/23Advanced Debugging

SAP and ABAP Memory

How to get SAP Memory and ABAP Memory during debugging

In the debug Mode, go to this path

Page 38: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation38 04/21/23Advanced Debugging

Debugging a Background Job

(1) Set a breakpoint in the code to be debugged in background

(2) Schedule the job via SM36. While scheduling go to the Start Conditions tab & press the Date-Time button

(3) Set the start of execution time to a little late than the system time

Then go to Job Step and select your program’s name and the variant name. Then Save the job.

Page 39: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation39 04/21/23Advanced Debugging

Debugging a Background Job

(1) Go to job overview and select the job

(2) Enter the command “jdbg” and press enter

(3) Debugging screen appears

(4) Press F8 and you stop at your break-point set. Carry on normal debugging now

Page 40: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation40 04/21/23Advanced Debugging

How to Use System debugging

(2) Save the settings by clicking on the “Save” button in the debugger

(1) You are in Debug Mode. Press the “Settings” button and check the checkbox as shown

(3) Press continue to complete execution

How to switch on System debugging?

Page 41: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation41 04/21/23Advanced Debugging

How to use Update Debugging Update function modules do not run in the same user session as the program that is currently running in the ABAP Debugger. These function modules are therefore not included in debugging. Only if you select the Update Debugging option can you display and debug them after the COMMIT WORK

(1) Example: Go to transaction CJ20N (Project Builder)

(2) Change the Applicant Number, switch on Debugging using /H and Save

Update Function Module CJVB_MLST_POST is called somewhere on save whose properties are shown

Page 42: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation42 04/21/23Advanced Debugging

How to use Update Debugging How to switch on Update debugging?

(1) In debugging mode, use Menu path Settings - > Update debugging

(2) In Debugger Settings tab, tick Update Debugging checkbox

(3) Press F8 and continue execution. Success message appears in the same SAP session window

(4) Another SAP debugger session also opens up to take you into the update task function module

Page 43: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation43 04/21/23Advanced Debugging

Use of Other Settings during Debugging

Checkbox in Debugger: In background task – Do not process

When to use this setting in the Debugger?

One example: Debugging transactional RFC calls done during sending IDOC to external system using ALE technology

Send a material to another server via ALE using the standard transaction BD10

Switch on Debug Mode using /H and press execute

Page 44: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation44 04/21/23Advanced Debugging

Use of Other Settings during Debugging

(1) Now you are in Debug Mode. Press the “Settings” button and check the checkbox as shown

(2) Save the settings by clicking on the “Save” button in the debugger(3) Press continue to

complete execution

On completion of program execution, IDocs should get created in the database

Page 45: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation45 04/21/23Advanced Debugging

Use of Other Settings during Debugging (1) Note the Status text “Transaction Recorded” – means execution is delayed

(3) Then you reach the debugging screen and proceed for debugging as normal

Now go to SM58 list which will look something like this:

(2) To Debug RFC, now Follow menu path: EDIT->DEBUG LUW

Page 46: Advanced Debugging in ABAP

IBM Global Business Services

© 2007 IBM Corporation46 04/21/23Advanced Debugging

Summary

There are several advanced features of the ABAP Debugger

There is also a new version of ABAP debugger available in later SAP releases

It is possible to debug Sap Scripts, Smartforms and ALV reports

RFC debugging can be done via two different methods, via SM58 or using a special setting in the ABAP Debugger

It is possible to debug background jobs

It is possible to debug popups appearing during SAP screen navigations

Several special settings in the debugger have been discussed such as Update Debugging, System Debugging and Background Debugging

It is possible to display and access the SAP memory, ABAP memory and also SAP buffer data from the ABAP debugger