|
||||
|
|
||||
|
McGyver Revisited
Many of you are familiar with the infamous "McGyver Technique," that can solve a myriad of reporting problems with a DEFINE-based JOIN, and some additional DEFINEs. Over the years, we have published many of these techniques, as well as providing the overview on our Web site at: http://techsupport.informationbuilders.com/tech/cof/cof_tcn_m00.html
Today, as even more people use FOCUS in its various flavors, we see growing need and opportunities for employing this technique. As most are centered on concepts involving sorting, here's a new slant on the venerable McGyver technique. Say, for example, you need this report from the EMPLOYEE file:
If you look closely, this actually looks like two reports. The first is a sum of current salary sorted by department and job code (showing job code descriptions). The second, while similar, is simply the sum of current salary by job code and job description. Certainly, in these days of compound PDF reports, we could code two requests, combining them into one after the fact. However, that may not be optimal with a large input file, as two passes will require too much time and CPU; or when you don't want to transfer the output to a PC; or if you want to number the pages one of n, etc., and incorporate both reports. So, what to do? What if the EMPLOYEE file actually had a "report number" field, containing two values for each employee?
Then it would be relatively easy to code with a DEFINE:
OK, but who in their right mind actually codes a report number into a database? The answer, of course, is no one. However, we can create a flat file with a report number (-TYPE flatfile R12) and describe it, adding a constant at the beginning in order to give us something to join to (previous iterations of McGyver used BLANK).
Then, the JOIN and DEFINE give us basically the same structure:
So, everything is right in the FOCUS world. With this, you can get up to nine reports in one pass. Should you actually need more, or not want to rewrite the FSEQ file for each difference in the report, FOCUS provides another option in describing sequential files. When you have a segment that contains an OCCURS clause, you may describe a field that FOCUS will create as an index to the OCCURS entries. It must have an ALIAS = ORDER, and ACTUAL of I4. So, being very generic, that same FSEQ master might look like this:
And, the FILEDEF/ALLOCATE points to any existing file with an R in the first column. Of course, if you don't like R, you can use any constant, blank, X, whatever).
Once you have this set up, the sky's the limit. Use REPORT_NUMBER as an ACROSS field, rather than BY. Use it to determine verb objects, rather than Sort fields. Make it a month, so that you can get details by month when you only have a start date and end date. You'll find additional examples at: http://techsupport.informationbuilders.com/tech/contents/cof_tcn_toc.html?prod=FOCUSforS/390#MACGYVER.
|