Wednesday, July 11, 2012

Digging Deeper into the FOCUS Language

Even though I have been using the FOCUS language since the 1980s (by the way, I intend to stop telling people how long it has been), I always seem to run across little quirks that stop me in my tracks and make me say, "I've never seen that before!"

Today it happened again while developing a new redundancy analysis for FOCUS applications. The BI Analyzer already had a feature for scanning SQL-based applications to find redundant reports, but for some reason we had never gotten around to building the same capabilities for FOCEXECs, the FOCUS programs.

Redundancy analysis is actually a very useful feature when you consider the history of end-user reporting tools such as the FOCUS 4GL.

Companies who purchased FOCUS decades ago turned it loose among the end users who then each started building computer applications on his or her own. Today, these companies are left with libraries full of legacy code that might be doing the exact same thing as other systems. Out of one thousand different reports, there may in reality only be about a dozen core reports and then lots of minor variations.

The BI Analyzer finds and groups all of those redundant reports, identifying them for consolidation during a modernization effort.

About seven years ago, while modernizing a financial services company's NOMAD 4GL legacy applications into WebFOCUS, I realized that the FOCUS language would not let you reformat a column being used for sorting. NOMAD could do that, but FOCUS and WebFOCUS could not. Strange. 

For example, in the FOCUS language you can specify a BY phrase to sort data by columns:

SUM RETAIL_COST 
BY COUNTRY 
BY CAR 
BY MODEL 

The display formats of these columns come from the underlying metadata instructions. So RETAIL_COST might have instructions associated with it to display as a number with five digits to the left of a decimal point and two to the right, along with commas. But the default rules might not say to put a dollar sign in there and that is what you want. 

In that case, inside the report logic you can override the metadata's default formatting and add your own instructions:

SUM RETAIL_COST/D9.2M 
BY COUNTRY 
BY CAR 
BY MODEL 

By putting a forward slash after the column name and some formatting commands of "D9.2M," I can make this decimal column bigger and add a dollar sign. 

The NOMAD language is (was) very similar to FOCUS and allowed you do this same type of formatting on the sort columns. So the BI Transformer (our software for translating legacy reporting applications into modern BI equivalents) tried to generate a replica for WebFOCUS like this:

SUM RETAIL_COST 
BY COUNTRY 
BY CAR 
BY MODEL/A12 

Surprisingly, FOCUS does not understand this reformatting on the BY sort columns. I shrugged, implemented a work-around, and moved on with the project. 

Today, I stumbled across some legacy code that looked like this:

SUM RETAIL_COST 
BY COUNTRY/C
BY CAR/C  
BY MODEL/C 

Wait, that can't be right! I've never seen that before. 

After some testing, I realized this was a little-used FOCUS feature--at least, I've only seen it once in three decades--for formatting not the sort column but its page title. 

You can Center, Left-Justify, and Right-Justify the titles. Here is another code example along with its PDF output:

SUM RETAIL_COST 
BY COUNTRY/L
BY CAR/R
BY MODEL/C


In the example above, I told FOCUS to left-justify the County title, right-justify the Car title, and center the title for the Model. 

Of course, in today's WebFOCUS environment you have at your disposal inline WebFOCUS stylesheets and HTML cascading stylesheets. This little FOCUS language trick is pretty arcane.

Still, it is always interesting to look into the history of the FOCUS language and understand what is going on under the covers.  Drop me a line the next time you stumble across something in the FOCUS language that makes you say, "Wait, that can't be right!"


If you are interested in more information about the core FOCUS 4GL, click here

No comments:

About Me

My photo

I am a project-based software consultant, specializing in automating transitions from legacy reporting applications into modern BI/Analytics to leverage Social, Cloud, Mobile, Big Data, Visualizations, and Predictive Analytics using Information Builders' WebFOCUS. Based on scores of successful engagements, I have assembled proven Best Practice methodologies, software tools, and templates.

I have been blessed to work with innovators from firms such as: Ford, FedEx, Procter & Gamble, Nationwide, The Wendy's Company, The Kroger Co., JPMorgan Chase, MasterCard, Bank of America Merrill Lynch, Siemens, American Express, and others.

I was educated at Valparaiso University and the University of Cincinnati, where I graduated summa cum laude. In 1990, I joined Information Builders and for over a dozen years served in regional pre- and post-sales technical leadership roles. Also, for several years I led the US technical services teams within Cincom Systems' ERP software product group and the Midwest custom software services arm of Xerox.

Since 2007, I have provided enterprise BI services such as: strategic advice; architecture, design, and software application development of intelligence systems (interactive dashboards and mobile); data warehousing; and automated modernization of legacy reporting. My experience with BI products include WebFOCUS (vendor certified expert), R, SAP Business Objects (WebI, Crystal Reports), Tableau, and others.