Debugging Tools

 

Debugging User-exits

If you get a Java stack dump when rendering a form, then firstly use transaction ST22 on the ABAP stack to analyse the error.

In order to add a break-point to analyse your user-exit code, you need to use an 'external break-point'.  This may need to be added under a different user depending on how the java connectors have been configured between the Java and ABAP stacks.

Indentifying the correct External User to Debug.

Logon to the Java Server Main Index URL ex: http://server:50000/index.html

Choose Web DynPro Tools > Content Administration

Expand out flm.com until you see the below

Click on FLMPortal under the Applications, Then Click on JCO Connections Tab that appeared in the new Panel, and select the highlighted entry and click Preview and then Click Security.

In this case we have a user Defined User.  This means we need to remote debug for this user, if SSO is shown then you need to remote debug for the user you log in as when using the FLM Portal.

Setting up your Function Module / FLM User Exit to Debug.

Log into SAP GUI as you normally would.

Now Navigate to either SE37 if you want to debug a Function Module or FLM in IMG if you want to debug a User Exit.

Now we need to set-up our user that we want to debug from the above step.

Select Utilities>Settings…  from the SAP GUI Menu

Select ABAP Editor from the Panels, and then Debugging Tab.  Update the Users field with the correct ID

Click Continue.

Now Select a Line in your ABAP code when you want to apply a Breakpoint.  And from the menu Select Utilities > External Breakpoints > Set/Delete External Breakpoint.
Your Breakpoint is now set.  Now run the FLM Portal as you want and when the Breakpoint is reached it will launch the ABAP Debugger.

Using the ABAP Debugger

When the ABAP Debugger launches it will show the below screen

At this point you can add variable to watch there values of by simply double clicking them in the code, in this example I clicked the variable w_return and w_org_name in the highlighted line

And you can also type them in, in this case I typed in w_user_id and w_pers_id, and pressing enter will show the value.

To then execute the code you have a number of options to select from the top of the debugger, normally Execute and Continue will be enough for you to step through your code

Execute will run the highlighted line and step to the next one in your ABAP Code.

Continue will run the ABAP code until the end or another Breakpoint is set.

Removing Breakpoints

Once you have finished testing your code in Debug, it important you remove any Breakpoints as they by default have a life span of 2 hours, which means anyone else running code will hit these.

To do this go back to your ABAP Source Code, and select the line with the Breakpoint ICON on it and then from the menu Select Utilities > External Breakpoints > Set/Delete External Breakpoint.

With Breakpoint set

With Breakpoint cleared

 

 Investigating PDF Render Issues

If there are issues rendering the PDF form, then the ADS trace can be activated and the logs reviewed.

There are two ways to activate ADS trace and retrieve the details.

The first is by activating ADS trace via the Java Stack Visual Administrator as described in the SAP Documentation.

The second is to activate ADS trace in FLM via the Customer Code Configuration IMG Activity.

To increase the ADS Trace Level, change the setting on the custom code configuration table to "Highest".

If the PDF form is rendered successfully, then the ADS trace files will be added as attachments to the PDF form.

While ADS trace is on all PDFs rendered will contain the trace information as attachments so be sure to set ADS Trace level back to "No trace" once the required trace information has been gathered.

If ADS was not able to render a PDF form, then the trace entries of the Adobe document services runtime are written to the default trace file defaultTrace.trc which is located in the log directory of the server node for example, C:\usr\sap\J2E\JC00\j2ee\cluster\server0\log on a Windows machine. 

 

 JavaScript Debugging

Acrobat Debugger

If you have Acrobat Professional installed then you can activate the JavaScript Debugger through Preferences -> JavaScript.

This enables the debugger to automatically be triggered when a problem is encountered.

 

Logging to the Console

It is possible to programmatically write messages to the 'console' part of the JavaScript debugger even if Acrobat Professional is not installed.

The FLM Master Template is shipped with a script object soLogger. This is used to allow developers to log messages into the Adobe Reader Console.

NB to allow Adobe Reader to show the Console Adobe, Reader must be started from the Start>Programs Menu and have an active window open

Function soLogger.setLogLevel this takes an input Parameter which allows three levels of logging 0 (zero) off, H (High) or L (Low).

For Example to turn Logging on to High Level you would do this

 

soLogger.setLogLevel("H");

This will ensure that only messages marked with 'High' logging level would be sent to the console.

 

To write a message, use function soLogger. logMessage passing in two parameters.  The first is the level you want to log at H (High) or L (Low) and the second is the message.

For Example:

 

soLogger. logMessage("H", "Test Message");

The message can contain field values from the form, so at run-time, key form data and calculations can be monitored.

 

Note that xfa.form.saveXML() will output the entire XML of the form, and xfa.data.saveXML() will output the form data.  So the following script can be useful to see the values of all the form fields:

 

var formdata = xfa.data.saveXML();

soLogger. logMessage("H", formdata);