Category Archives: coding

Show SQL generated by your WebFOCUS Report

Here are some settings you can play around with to show what SQL Statement is being passed to the Reporting Server:

-*** Show SQL statements ***********************************

-*** Show Optimization information *************************

-*** Show SQL generated statement trace ********************

-*** Show SQL generated sub-statement trace ****************

-*** Disable the trace stamp (Date/Time etc) ***************

-*** Set trace line wrapping – # of characters *************

-*** Write SQL tracing to a file ***************************
-*SET TRACEUSER=C:\ibi\apps\baseapp\ifds_insight_trace.trc

-*** Activate SQL tracing **********************************

Setting and using relative dates in WebFOCUS

There are times when you will want the user to be able to choose from a relative date vs. having to figure out the date or date range to select. For example, instead of picking the the first day of the current month , it would be much simpler to select the option of “Beginning of Current Month.”

The UI portion won’t be covered here; I will save that for another post. However, behind the scenes, you’ll want to add the following to your Reporting Server Profile:

-SET &&BOM=EDIT(&&YESTERDAY,’999999′) | ’01’;

What the above does is sets the global variable, &&BOM to the first day of the month.

When the user selects “Beginning of Current Month”, it will pass the value “&&BOM” to the WF content.

Here are some more calculations:

-* &YYMD is todays date




-SET &&CMTH_DATE=EDIT(&&YESTERDAY,’999999′) | ’01’;

-SET &&BOM=EDIT(&&YESTERDAY,’999999′) | ’01’;






-SET &&P6MTH=EDIT(&WS_P6MTH,’99999901′);


-SET &&LYEAR_DATE=&&LYEAR || ’01’||’01’;

-SET &&CYEAR_DATE=&&CYEAR || ’01’||’01’;







WebFOCUS: Simplifying Date Formatting

If you’re a software developer using popular languages such as C# and Java, you’re used to a lot of string formatting options for dates.

For example, in C#, this line of code will look familiar.

DateTime thisDate = new DateTime(2014,1,1);

string date_str=thisDate.ToString(“MMMM dd, yyyy”);

The variable date_str will look like this: January 1, 2014

Unfortunately, I wasn’t able to find something similar in WebFOCUS. There a lot of date functions to choose from, but that’s a double edge sword; you can do a lot of with dates which gives you flexibility, but it can be confusing when to use what functions and makes it difficult to remember.

I created a custom function that simplifies this task of turning dates into strings (ALPHAs). You can download this WebFOCUS date utility. Download WebFOCUS date utility file

Here’s an example of how you can use it:

-INCLUDE date_utils.fex

COMPUTE DATETIME/HYYMDs =‘2014-01-02 23:58:59’;

COMPUTE DATE/YYMD = ‘2013-01-03’;
Here are all the available formats you can use in my custom function – everything is case sensitive!
YYYY = four digit year; e.g. 2014
YY = two digit year; e.g. 14
MMMM = full month name; e.g. February
MMM = three letter month name; e.g. Feb
MM = two digit month padded with a 0; e.g. 02
M = varying 1-2 digit month; e.g. 2
DD = two digit day padded with a 0; e.g. 01
D = varying 1-2 digit day; e.g. 1

Of course, much more can be done, but this covers the majority of the use cases that I typically run into.

Feel free to extend as you need. If you need help, extending the functionality, shoot me an email at:


Custom WebFOCUS Double List Box Control

The double list box control that comes out-of-the-box with WebFOCUS meets most functional requirements. However, in one of my engagements, the double list box control didn’t have all the functionality required. So I took the challenge of creating my own in jQuery so it would be easy to integrate with WebFOCUS.

The additional functionality I added was:

  1. Being able to add more than 1 column to the boxes to provide more context on what was being selected
  2. Sorting of columns
  3. Search specific to only the double list box
  4. Custom sorting of items on the selected items using drag and drop functionality

Unfortunately, I can’t share this code with you, but the following video should give you a sense of what I created.

For those interested in learning more, feel free to reach me at: I will see what I can do for you!

WebFOCUS replace characters in string

Update: As of 8201, there is now a nice simple function called REPLACE. See this link.

A common piece of functionality in most programming languages is a search and replace character function; the more sophisticated languages allow for regular expressions. In any case, here’s how to do a search and replace character in a string using WebFOCUS:


This one was was buried in a forum thread. Note that this is as of WebFOCUS 7.1.3.



WebFOCUS – Showing / Suppressing leading zeroes

WebFOCUS is a rich language that you can do almost anything with. Unfortunately, the depth of the language makes it hard to find how to do certain tasks; I’ve had to search very hard in our documentation, Focal Point, and Google to accomplish what I would consider common tasks.

Here’s an example. When I first started to learn WebFOCUS, I was trying to show the leading zero of a fractional 0 value in a report.

I.e. a zero real value shows up like .00 instead of 0.00.

In most cases that’s fine to save real estate. However, I like it with the leading zero to help with visually aligning decimal places. Simple enough task right? It is, but you have to know the right command and what to search for.

I searched for (always preceding with WebFOCUS):

• Add a zero to a real number in a report

• Suppressing zero values in report (the opposite)

• Formatting numeric values

It took a while (20 minutes), to find what I was looking for. It was:


It’s easy to do, just hard to find how to do it.

This got me thinking; I thought it would be useful to start blogging about various features I’ve found and sharing them with Google. The trick is adding the right keywords to make it easier to find things.

Hopefully, everyone can benefit from this activity. I know I will when a have a mental lapse. 😀

WebFOCUS reports with sparklines – the jQuery approach


This post is going to provide step by step instructions on how to implement sparklines
within WebFOCUS reports using a jquery plugin rather than the standard Information
Builders approach. The major advantage with this technique is it’s quite simple to implement and maintain because of the small code footprint.

Who is this for?

  • Intermediate WebFOCUS knowledge is required
  • Some javascript / jquery knowledge would help but not required if you’re comfortable
    with reading APIs


In most reports, you typically have a column that represents a dimension (a grouping)
and values of measures for that row. Here’s an example:

Additional context that would be useful would be to provide how the measure is doing
over time. This is where sparklines can be used.

Wikipedia’s definition:

A sparkline is a very small line chart, typically drawn without axes or coordinates

Here is an example of a sparkline that shows the trend of a fictitious trading index:

Now I’m going to show you a way to do that with WebFOCUS.


  1. Download the Excel spreadsheet
    and upload it to your WebFOCUS application folder (mine is called sparkline-example)
    by right clicking on the folder, choosing ‘New’->’Upload Data’ and follow the wizard.
  2. This process will create a master file called Sheet1 assuming you choose all default
  3. Download this
    fex file
    and place into your WebFOCUS app folder that you added the Excel spreadsheet
    to. Read the in line comments to understand what’s going on.
  4. Finally, add the js files to your web application folder. You can download the js
    files here.

If you got everything set up properly, it should look like this when you run the
fex file.


The major gotcha is you will not be able to render this WebFOCUS report
as a PDF or do a page print with your browser. I.e. use this technique only if these are not required.