Starting a Debug Session

This step explains how you can interrupt processing of a Web Dynpro application by adding a breakpoint. This then enables you to analyze the status of the application at runtime.

Prerequisites

·         Debugging is activated – that is, the server process has been stopped and restarted in debugging mode.

·         You have imported the Welcome application to the Workspace of the Developer Studio and have opened it in the Web Dynpro Explorer.

Procedure

Setting a Breakpoint

       1.      Open the implementation page of the ResultView from the Welcome application. To do so, in the Web Dynpro Explorer, double-click Welcome  ®  Web Dynpro  ®  Web Dynpro Components  ®  Welcome Component  ®  Views  ®  ResultView and then choose the Implementation tab page.

       2.      Display the source code and navigate to the beginning of the onPlugFromStartView method. Right-click the left bar of the editor frame above the appropriate line (see below) to open the context menu and choose Add Breakpoint.

The breakpoint lines are highlighted with a blue dot.

Defining a Debug Configuration and Starting the Debug Mode

To start the Web Dynpro application in the debugger, you require a launch configuration.

...

       1.      Choose Run ® Debug... in the main menu.

       2.      In the list of possible configurations, select Web Dynpro Application and then choose New.

       3.      Under Name, enter MyWelcomeConfig as the name of the configuration.

       4.      Choose Browse... next to the Project field. Next, select the Welcome project and confirm with OK.

       5.      Choose Browse... next to the Web Dynpro Application field. Next, select the WelcomeApplication and confirm with OK.

       6.      If the Welcome application to be debugged has not yet been deployed on the server, select the Create and deploy archive checkbox.  

       7.      To select the server that you want to use for the debugging procedure, choose the J2EE engine tab page.

       8.      The configuration is now complete and you can start the debugger.

       9.      To start the debugger, choose Debug.

The SAP NetWeaver Studio automatically switches to the debug perspective. The Web application is started in an external Browser. When you enter a name, for example Michael and choose Go, it appears that it can no longer be executed. However, if you change back to the SAP NetWeaver Developer Studio, you will see that the application was stopped at the breakpoint and can now be analyzed.

Analyzing the Example Application

There are various different options for further processing on a step-by-step basis:

Key

Description

F5: Step Into

Jumps to the next statement

F6: Step Over

The next command is executed without jumping to the current statement

F7: Step Return

If you previously chose F5, you can choose F7 to cancel the debugging of the current command

F8: Resume

The application exits debug mode and continues with execution

   10.      Use F6 to execute all statements before the line ‘wdContext.currentContextElement().setHeaderText(headerText)‘ within the onPlugFromStartViewmethod and observe the variable contents in the Variables window of the debug perspective.

The local headerText variable changes your value in accordance with the executed program lines.

The debugging mode enables you to dynamically change the variable contents.

   11.      Double-click the headerText variable in the Variables window of the debug perspective.

   12.      Replace the name Michael in the input field with Thomas and choose OK.

   13.      Choose F8 to continue the execution of the application. The system then displays the following ResultView that displays the changed value of the variables.

Terminating Debugging

If you want to exit debugging, you must terminate the threads in the SAP NetWeaver Developer Studio.

Proceed as follows:

...

       1.      In the Debug View, call the context menu for the top node (MyWelcomeConfig[Web Dynpro Application]).

       2.      In the context menu that appears, choose Disconnect.