SAP ByD – Tracing & Debugging

Posted on Posted in SAP Business ByDesign

Tracing & Debugging is the process of finding and resolving of defects that prevent correct operation in script file.

sap byd tracing and debugging

 

How to enable Tracing & debugging for business user?

  1. Logon into SDK
  2. Go to Administration -> Options and Settings -> Debugging and Tracing.
  3. Here, we can maintain what user we want this to debug.

sap byd tracing and debugging

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,

  1. You can run a local trace,
  2. Run a trace for an end user,
  3. Use trace information for troubleshooting purposes,
  4. 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:

sap byd tracing and debugging

 

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:

  1. Informational Messages (Trace.Info)
    Syntax 
       Trace.Info(String);
       Trace.Info(String, String);
    
  2. Error Messages (Trace.Error).
    Syntax 
      Trace.Error(String);
      Trace.Error(String, String);
    

  You import ABSL; namespace to access the Trace class.

Example
   import ABSL;
   Trace.Info(“Start Test”, this.ID.Content);
   Trace.Error(“Invalid parameter”, this.ID.Content);
   Trace.Info(“End Test”);
Run Tracing
  1. To begin recording trace information, in the Trace Explorer window, click the Start Tracing  icon button.
  2. Run the script files that you want to trace.
  3. To stop recording trace information, in the Trace Explorer window, click the Stop Tracing icon  button.
  4. To view traces, in the Trace Explorer window, click the Local Traces tab.
  5. 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.

   Each time you start the debugger, tracing is also started automatically.

Set a Breakpoint
  1. In the Solution Explorer, open a script file.
  2. 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
    1. To start debugging, in the Debug toolbar, click start dub or press F5 .
    2. To stop debugging, in the Debug toolbar, click stop debus or press SHIFT + F5.

The debugger is in run mode and you cannot edit your code anymore.

Debug Windows

The debug windows display information the debugger provides and support you in analyzing this information.

The following windows are provided:

  1. Locals:  This window displays variables local to the current script file. You can view the name, the value, and the type of the variable.
  2. Breakpoints: This window lists all breakpoints that are set in your solution.
  3. Call Stack: The Call Stack window supports you in finding out which script file called the script file that is currently processed.
  4. Output: In the Debug view of the Output window you can view tracing information that the system is collecting during the debug run.
  5. 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:

sap byd tracing and debugging

Run Debugging
    1. You open the script file in the code editor and set breakpoints.
    2. You start debugging.
    3. 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.
    4. 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.
    5. When you have found an error, you stop debugging and correct the error.
    6. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *