abap debugging basic
DESCRIPTION
How to debugging in SAP. Basic functionalitiesTRANSCRIPT
SPS102: ABAP DEBUGGING
Kasama RuangrongEMIT|SAS|SPS26-Oct-2007
Based on a Presentation byJohn C Benson(1st Edition) June 06
Mike Bradshaw(2nd) June 06Kylie Sng Yen Leng(3rd) Oct19, 07
Agenda
23.04.08. -2-
1. Debugging Overview
2. Debugging Components
3. Breakpoints
4. Displaying Data Values
5. Changing Data Values
6. Watchpoints
7. ABAP Dump(ST22)
8. Tips & Tricks
1. Debugging Overview (DM1)
23.04.08. -3-
Components
Breakpoint
Watchpoint
DebugData Values
Component
Breakpoint
Data Value Watchpoint
OVERVIEW
1. Debugging Overview (DM1)
23.04.08. -4-
ABAP Program: Y_ABAP_DEBUG_DEMO
or
Transaction: Y_ABAP_DEBUG_DEMO
Selection Screen:
1. Debugging Overview (DM1)
ABAP Debug Screen
23.04.08. -5-
2. Debugging Components (DM1)
23.04.08. -6-
• Basic understanding of the ABAP Debug Components
Components
2. Debugging Components (DM1)
Description Icon Fkey Action
Single Step <F5> go to the next instruction regardless of program level
Execute <F6> go to next instruction in the current program level
Return <F7> return to the calling program level
Continue <F8> continue execution to the next breakpoint or complete processing.
23.04.08. -7-
Execution within the Debugger
2. Debugging Components (DM1)
23.04.08. -8-
Execution Flow within the ABAP Debugger
• Demonstrating the use of within the program execution levels.
• Breakpoint in the program executing the Perform.
• Breakpoint in the Perform.
• Breakpoint in the Function Module
2. Debugging Components (DM1)
23.04.08. -9-
Display Options within the ABAP Debugger
• Display program lines before and after the current line to be executed.
or
• Display the current line to be executed.
• Increase Program Section Size
• Display the current Call or Program Level
2. Debugging Components (DM1)
23.04.08. -10-
Display Options within the ABAP Debugger (cont’d)
• or Reset the ABAP Debug Display.
• Cancel Execution.
3. Breakpoints (DM3)
23.04.08. -11-
• Setting Breakpoints
Breakpoint
3. Breakpoints (DM3)
23.04.08. -12-
Start the ABAP Debugger Before Start of Execution
• Enter “/h” in the Command Line:
or
Menu Path: System>Utilities>Debug ABAP
Bottom of the Screen:
• SE38>Select the Debug ICON:
3. Breakpoints (DM3)
23.04.08. -13-
Breakpoints
• Initial Breakpoints are set using SE38/SE39 or SE37.
With the line highlighted click the on the toolbar to set the breakpoint.
Click again to delete
3. Breakpoints (DM3)
23.04.08. -14-
Breakpoints (cont’d)
• The complete list of breakpoints can be displayed/deleted in SE38 (Utilities>Breakpoint>Display).
3. Breakpoints (DM3)
23.04.08. -15-
Breakpoints (cont’d)
• Breakpoints can be added or deleted during the debug session.
Double click on a line to add or delete a breakpoint.
3. Breakpoints (DM3)
23.04.08. -16-
Breakpoints (cont’d)
• Displaying all breakpoints during a debug session.
Breakpoints can be deleted in the breakpoint list by double clicking .
3. Breakpoints (DM3)
23.04.08. -17-
Breakpoints (cont’d)
• Display a dropdown list to deactivate or reactivate breakpoints for the current execution.
indicates a deactivated breakpoint.
3. Breakpoints (DM3)
23.04.08. -18-
Breakpoints (cont’d)
• Breakpoints added or deleted during a debug session can be saved for subsequent executions.
Initial execution
Subsequent executions after saving the
deletion of the original breakpoint and the setting of a new breakpoint in a
previous debug session.
3. Breakpoints (DM3)
23.04.08. -19-
Breakpoints (cont’d)
• Breakpoints are only active for the user that sets the breakpoints.
• Breakpoints are active for all sessions within a user logon.
• Breakpoints are not active for additional user logons.
4. Displaying Data Values (DM2+DM4)
23.04.08. -20-
• Displaying Data Values in Fields, structure & Internal Tables
• Changing Data Values
Data Values
4. Displaying Data Values (DM2+DM4)
23.04.08. -21-
• Displaying the Output List in the ABAP Debugger
• is added to the execution task bar after output has been created.
• Click on to display the current Output List.
4. Displaying Data Values (DM2+DM4)
23.04.08. -22-
• Displaying Data Values
Standard System Values
4. Displaying Data Values (DM2+DM4)
23.04.08. -23-
Displaying Data Values (cont’d)
• Single Fields
• Type or double click the single field.
• Double click the field to display the field attributes.
4. Displaying Data Values (DM2+DM4)
23.04.08. -24-
Displaying Data Values (cont’d)
• Structures
• Type or double click the structure name.
• Double click the structure name to display the values for each structure field.
• Double click the structure field to display its attributes.
4. Displaying Data Values (DM2+DM4)
23.04.08. -25-
Displaying Data Values (Cont’d)
• Internal Tables
• Type or Double Click the Internal Table Name
• Hit <Enter> to display the internal table contents
Current Values in the Table Header
4. Displaying Data Values (DM2+DM4)
Icon Table Field
First
Previous
Next
Last
23.04.08. -26-
Displaying Data Values (Cont’d)
• Parsing the Internal Table:
• Table Paging:
• Finding a Record:
Icon Page
First
Previous
Next
Last
Icon In Table
Find
Find Next
4. Displaying Data Values (DM2+DM4)
23.04.08. -27-
Displaying Data Values (Cont’d)
• Internal Tables (Cont’d)
• Fields can be excluded from the internal table display. Highlight the fields to be excluded, depress <Delete>, then depress <Enter>.
• To redisplay all fields, click on .
4. Displaying Data Values (DM2+DM4)
23.04.08. -28-
Displaying Data Values (Cont’d)
• Download Internal Tables (Cont’d)
4. Displaying Data Values (DM2+DM4)
23.04.08. -29-
Displaying Data Values (Cont’d)
• Download Internal Tables (Cont’d)
5. Changing Data Values (DM5)
23.04.08. -30-
• Changing Data Values
• Display the fields in the ABAP Debugger
• Overtype the field value and select to make the change to the field value.
5. Changing Data Values (DM5)
23.04.08. -31-
• Changing Data Values (cont’d)
• Display the Internal table in the ABAP Debugger
• To change the Value, place cursor at the column & click “Change”. Press Enter to confirm changes.
5. Changing Data Values (DM5)
23.04.08. -32-
• Changing Data Values (cont’d)
• To insert a new row into the Internal Table. Click on the “Insert”. Press Enter to confirm the changes.
5. Changing Data Values (DM5)
23.04.08. -33-
• Changing Data Values (cont’d)
• To add a new record at the END of the Internal Table. Click on the “Append”. Press Enter to confirm the changes.
5. Changing Data Values (DM5)
23.04.08. -34-
• Changing Data Values (cont’d)
• To remove an record. Place your cursor at that row. Click on “Delete”. Press Enter to confirm the changes.
5. Changing Data Values (DM5)
23.04.08. -35-
• Changing Data Values (cont’d)
• To remove a record, place your cursor at record and click on the “Delete”.
6. Watchpoints (DM6)
23.04.08. -36-
• Setting Watchpoint
Watchpoint
6. Watchpoints (DM6)
23.04.08. -37-
Watchpoints
• Uses an ABAP field to create a conditional breakpoint while in the ABAP Debugger
6. Watchpoints (DM6)
23.04.08. -38-
Watchpoint (Cont’d)
• Displaying and changing the watchpoints that have been set in the ABAP Debugger.
is used to change the watchpoint condition.
is used to delete the watchpoint.
7. ABAP Dump (ST22)
23.04.08. -39-
ABAP DUMP ANALYSIS (ST22)
7. ABAP Dump (ST22)
23.04.08. -40-
ABAP Dump Analysis
• An ABAP Dump occurs when the program intentionally triggers a dump when current conditions cannot be handled.
Examples: Divide by ZeroNumeric field too small for the result (field overflow)Timeout
• Use transaction ST22 to view and analyze an ABAP Dump.
7. ABAP Dump (ST22)
23.04.08. -41-
ABAP Dump Analysis (cont’d)
Summary of What Happened!
Where it Happened!
Click here to View the code
7. ABAP Dump (ST22)
23.04.08. -42-
ABAP Dump Analysis (cont’d)
Contents of System Variables!
Contents of Chosen Variables!
7. ABAP Dump (ST22)
23.04.08. -43-
ABAP Dump Analysis (cont’d)
Where it has been and
where it is!
• The program was at line 197 in the Form “DEMO_07” which was called from line 77 in the Event “Start_of_Selection”.
• IMPORTANT : Please kindly save the short dump into a file and send to SPS for analysis.
8. Tips & Tricks
23.04.08. -44-
Tips & Tricks
8. Tips & Tricks
23.04.08. -45-
To Debug Dialog Screen• Save the below into a .txt on the desktop (can be any name).
[FUNCTION] Command=/H Title=Debugger Type=SystemCommand
8. Tips & Tricks
23.04.08. -46-
To Debug Dialog Screen (cont’d)• Drag and drop the above file onto the Dialog screen.
• Debugging will be activated.
8. Tips & Tricks
23.04.08. -47-
To Debug Background job• Transaction SM37• Function code JDBG
• Transaction SM66 > Debugging
8. Tips & Tricks
23.04.08. -48-
Transaction Codes• AL21 – ABAP Program Analysis
8. Tips & Tricks
23.04.08. -49-
Transaction Codes (cont’d)• SE30 – ABAP Runtime Analysis
Click here for more analysis
8. Tips & Tricks
23.04.08. -50-
Transaction Codes (cont’d)• SE93 – Maintain Transaction (good for finding the program name).
ABAP Debugging Summary
23.04.08. -51-
Potential Pitfalls
• Running code in the debugger is not exactly the same as normal execution.
• The debugger may perform commits which can cause: - Abends the code by breaking the database cursor (Select/Endselect). - Inadvertently commits changes to the database that would otherwise be rolled
back.
• Timing is changed in the debugger: - Problems related to the timing and sequence of database updates may
not show up when in the debugger.
• Restarting without leaving the debugger completely may retain prior information in global memory that would normally be refreshed.
• Record locks are not released within an appropriate timeframe thereby impacting other processing.
• A limited number of processes are available in production so try to avoid extended debug sessions.
• Start a secondary session to be able to terminate a runaway session.
ABAP Debugging Summary
23.04.08. -52-
Summary
• The debugger can be useful to isolate hard to locate problems.
• The debugger changes the environment so some problems are very difficult or impossible to debug.
• Breakpoints and watchpoints help to get to the suspected problem area faster.
• Variables can be changed to create tests and bypass checks, but debug with replace is not normally used or allowed in production.
SPS102: Revisions
23.04.08. -53-
1. Debugging Overview
2. Debugging Components
3. Breakpoints
4. Displaying Data Values
5. Changing Data Values
6. Watchpoints
7. ABAP Dump(ST22)
8. Tips & Tricks