Tracing & Debugging is the process of finding and resolving of defects that prevent correct operation in script file.
How to enable Tracing & debugging for business user?
- Logon into SDK
- Go to Administration -> Options and Settings -> Debugging and Tracing.
- Here, we can maintain what user we want this to debug.
If you leave this checkbox unchecked, it’s going to debug for your user, the user that you are logged into the Studio. If you want to provide a different user, you can select this checkbox and give it a name.
Tracing
You can use tracing to record information about your code as it is being executed.
From the Trace Explorer,
- You can run a local trace,
- Run a trace for an end user,
- Use trace information for troubleshooting purposes,
- View the results of a recorded trace.
By inspecting the information recorded by a trace, you can obtain a better understanding about how your code works and troubleshoot problems.
You Can Access the Tracing Functions as Follows:
Trace Class and Methods
You can enhance the information that is recorded during a trace by adding methods from the Trace class to your script files. This way, you can record informational, error messages, and output variable values.
Trace information is only recorded while an active trace is running.
The Trace class provides methods:
- Informational Messages (Trace.Info)
Syntax Trace.Info(String); Trace.Info(String, String);
- Error Messages (Trace.Error).
Syntax Trace.Error(String); Trace.Error(String, String);
[pullquote] You import ABSL; namespace to access the Trace class.[/pullquote]
Example import ABSL; Trace.Info(“Start Test”, this.ID.Content); Trace.Error(“Invalid parameter”, this.ID.Content); Trace.Info(“End Test”);
Run Tracing
- To begin recording trace information, in the Trace Explorer window, click the Start Tracing
button.
- Run the script files that you want to trace.
- To stop recording trace information, in the Trace Explorer window, click the Stop Tracing
button.
- To view traces, in the Trace Explorer window, click the Local Traces tab.
- To update the list of traces, click the Refresh Traces button.
The completed trace appears in this list, identified by the time that trace was started, and the ID of the user executing the code.
Debugging
Debugging is an important process during the development of a solution which enables you to observe the runtime behavior of your solution and to locate logic errors.
[pullquote] Each time you start the debugger, tracing is also started automatically.[/pullquote]
Set a Breakpoint
- In the Solution Explorer, open a script file.
- You can set a breakpoint in the code editor by doing one of the following:
- In the left grey margin of the code editor, click a line of executable code.
- Click a line of executable code and press F9 .
Start and Stop Debugging
[pullquote] The debugger is in run mode and you cannot edit your code anymore.[/pullquote]
Debug Windows
The debug windows display information the debugger provides and support you in analyzing this information.
The following windows are provided:
- Locals: This window displays variables local to the current script file. You can view the name, the value, and the type of the variable.
- Breakpoints: This window lists all breakpoints that are set in your solution.
- Call Stack: The Call Stack window supports you in finding out which script file called the script file that is currently processed.
- Output: In the Debug view of the Output window you can view tracing information that the system is collecting during the debug run.
- DataTips: A DataTip is a box in the code editor that displays the value of a variable in your solution similar to the Locals window.
You Can Access the Debug Toolbar as Follows:
Run Debugging
- You open the script file in the code editor and set breakpoints.
- You start debugging.
- You open your screen, for example, by using the preview function, to observe the runtime behavior of your solution.
You can also debug your solution when you log on to the SAP cloud solution and select the relevant screen. - On the screen, you perform the actions that are implemented in your script file.
When the debugger hits a breakpoint, it breaks the execution of your solution and the system brings the code editor with the corresponding script file to the front.
You can now step through the code, display variable values, and analyze the tracing information. - When you have found an error, you stop debugging and correct the error.
- You start debugging again. Make sure that you have reactivated the solution and preview your screen again.
In this article, we saw about Tracing & Debugging. If you like to add some points with this article, kindly leave your points in comment box. Don’t forget to subscribe it.