Producing Headings and Footings

In this section:

You can use a variety of headings and footings to clarify the information presented in your reports. The following diagram illustrates the available options:

Limits for Headings and Footings

The following limitations apply to report headings and footings, page headings and footings, and sort headings and footings:

Report and Page Headings

How to:

A report heading is text that appears at the top of the first page of a report. A page heading is text that appears at the top of every page of a report. In general, the heading is composed of text that you supply in your report request, enclosed in double quotation marks.

Note: If the end quotation mark of the heading text is omitted, all subsequent lines of the request are treated as part of the heading.

Syntax: How to Create a Report Heading

To create a report heading, the syntax is:

ON TABLE [PAGE-BREAK AND] SUBHEAD
"text"

where:

PAGE-BREAK

Is an optional phrase that positions the report heading on a separate page, which is then followed by the first page of the report itself. If you do not use PAGE-BREAK, the report heading appears on Page 1, followed immediately by the page heading and column titles.

text

Is text that you supply between quotation marks that appears as a heading. The text must be on a line by itself and must immediately follow the SUBHEAD command.

Syntax: How to Create a Page Heading

To place a heading on every page of the report, the syntax is:

TABLE FILE filename 
[HEADING [CENTER]]
"text"

where:

HEADING

Is optional if you place the text before the first display command; otherwise, it is required to identify the text as a heading. The command CENTER centers the heading over the text automatically.

text

Is the text placed within quotation marks that appears on every page. The text can be split over multiple lines, and must begin on the line immediately following the HEADING command.

If you supply two or more text lines between quotation marks, the lines are automatically adjusted into pairs to provide coverage across the printed page.

To position heading text, use spot markers as described in Using Data in Headings and Footings.

Example: Creating a Report Heading

The following request creates a report heading:

TABLE FILE EMPLOYEE
SUM GROSS
BY DEPARTMENT BY HIGHEST PAY_DATE
ON TABLE PAGE-BREAK AND SUBHEAD
"PLEASE RETURN THIS TO MARY SMITH"
END

The first two pages of output follow (only the page preceding the body of the report has the subhead):

PAGE 1 
PLEASE RETURN THIS TO MARY SMITH 
PAGE 2 
DEPARTMENT       PAY_DATE                    GROSS 
----------       --------                    ----- 
MIS              82/08/31                    $9,000.00 
                 82/07/30                    $7,460.00 
                 82/06/30                    $7,460.00 
                 82/05/28                    $6,649.51 
                 82/04/30                    $5,890.84 
                 82/03/31                    $3,247.75 
                 82/02/26                    $3,247.75 
                 82/01/29                    $3,247.75 
                 81/12/31                    $2,147.75 
                 81/11/30                    $2,147.75 
PRODUCTION       82/08/31                    $9,523.84 
                 82/07/30                    $7,048.84 
                 82/06/30                    $7,048.84 
                 82/05/28                    $7,048.84 
                 82/04/30                    $4,959.84 
                 82/03/31                    $4,959.84 
                 82/02/26                    $4,959.84 

Example: Creating a Page Heading

The following request prints a heading on each page:

TABLE FILE EMPLOYEE
"ACCOUNT REPORT FOR DEPARTMENT"
PRINT CURR_SAL BY DEPARTMENT BY HIGHEST BANK_ACCT
BY EMP_ID
ON DEPARTMENT PAGE-BREAK
END

This request produces the following two-page report:

PAGE 1 
ACCOUNT REPORT FOR DEPARTMENT 
DEPARTMENT   BANK_ACCT   EMP_ID          CURR_SAL
----------   ---------   ------          --------
MIS          163800144   818692173       $27,062.00
             122850108   326179357       $21,780.00
             40950036    117593129       $18,480.00
                         112847612       $13,200.00
                         219984371       $18,480.00
                         543729165        $9,000.00
PAGE 2 
ACCOUNT REPORT FOR DEPARTMENT 
DEPARTMENT   BANK_ACCT   EMP_ID          CURR_SAL
----------   ---------   ------          --------
PRODUCTION   819000702   123764317       $26,862.00
             136500120   451123478       $16,100.00
                160633   119329144       $29,700.00
                         071382660       $11,000.00
                         119265415        $9,500.00
                         126724188       $21,120.00

Example: Creating a Multi-Line Heading

The following request creates a two-line report heading:

TABLE FILE PROD
" DETAIL LISTING OF AREA SALES
   DISTRIBUTION"
"   FIRST QUARTER OF YEAR
   BRANCH MANAGERS"
BY PROD_CODE NOPRINT
END

The report heading across the top of each page appears as:

DETAIL LISTING OF AREA SALES                                      DISTRIBUTION 
  FIRST QUARTER OF YEAR                                             BRANCH MANAGERS

DISTRIBUTION and BRANCH MANAGERS are on the far right of the report because of trailing blanks in the procedure. The open and closing quote marks indicate the length of the text. To avoid extra blanks, code <0X at the end of the line to be continued. For more information, see Positioning Text.

Report and Page Footings

How to:

A report footing is text that appears at the bottom of the last page of a report. A page footing is text that appears on the bottom of every page of a report. In general, the footing is composed of text that you can supply between quotation marks in a report request.

Note: If the ending quotation mark of the footing text is omitted, all subsequent lines of the request are treated as part of the footing.

Syntax: How to Create a Report Footing

To place a footing on the last page of the report, the syntax is:

ON TABLE [PAGE-BREAK AND] SUBFOOT
"text"

where:

PAGE-BREAK

Is an optional phrase that positions the report footing on the last page by itself. If not used, the report footing appears as the last line on the report.

Note: If PAGE-BREAK is specified in the BY phrase and not in the ON TABLE phrase, the report footing appears as the last line on the last page of the report.

text

Is the text you supply in quotation marks that appears as a footing. The text begins on the line following the keyword SUBFOOT.

Syntax: How to Create a Page Footing

To display a footing on every page of a report, the syntax is:

FOOTING [CENTER] [BOTTOM]
"text"

where:

FOOTING

Is the keyword that identifies the text as a footing.

CENTER

Centers the footing automatically.

BOTTOM

Places the footing at the bottom of the page. If BOTTOM is not specified, the footing text appears two lines below the report.

text

Is the text you place within quotation marks that appears on every page.

Example: Creating a Page Footing

The following request creates a page footing:

TABLE FILE CAR
WRITE SALES BY COUNTRY
FOOTING
"THIS IS HOW A FOOTNOTE IS ADDED TO EACH"
"PRINTED PAGE"
END

The output is:

COUNTRY      SALES                     
-------      -----                     
ENGLAND      12000                     
FRANCE           0                     
ITALY        30200                     
JAPAN        78030                     
W GERMANY    88190                     
                                       
THIS IS HOW A FOOTNOTE IS ADDED TO EACH
PRINTED PAGE                           

Creating Multiple Conditional Headings and Footings

How to:

Reference:

A TABLE request can have more than one page heading or footing. For each heading or footing, a WHEN clause against the data being retrieved can determine whether the heading or footing displays on the report output.

In a heading, the data for the WHEN clause and data field values displayed in the heading are based on the first line on the page. In a footing, the data for the WHEN clause and the data field values displayed in the footing are based on the last line on the page.

The CONDITION StyleSheet attribute enables you to identify a specific WHEN clause, so that you can style each heading or footing separately.

Syntax: How to Specify a Heading or Footing With a WHEN Clause

{HEADING [CENTER]|FOOTING}
"text_and_data1"
   .
   .
   .
"text_and_datan"
WHEN expression

where:

text_and_data1, text_and_datan

Is the text and data for each heading or footing line.

expression

Is an expression that resolves to TRUE or FALSE (1 or 0). If its value resolves to TRUE, the heading or footing is displayed. If the expression resolves to FALSE, the heading or footing is not displayed.

Reference: Usage Notes for Multiple Headings

  • HEADING CENTER and FOOTING CENTER apply only to the specific heading or footing in which they are specified.
  • A request can have a total of 120 headings, 120 footings, 120 subheadings, and 120 subfootings.
  • Once you use the BOTTOM option on a footing, all subsequent footings also go to the bottom of the page.

Syntax: How to Style a Specific Heading or Footing

TYPE = {HEADING|FOOTING}, CONDITION = n, ... ,$

where:

n

Is the number of the WHEN condition in the heading or footing from top to bottom. If not specified, formatting applies to all headings and footings.

Example: Using Multiple Headings With WHEN Clauses

The following request against the EMPLOYEE data source displays a page for each employee with salary and job code information for that employee. If the employee is female, the page starts with a heading that refers to the employee as Ms. If the employee is male, the page starts with a heading that refers to the employee as Mr. If the department is MIS, the signature is Barbara Cross. If the department is PRODUCTION, the signature is John Banning.

DEFINE FILE EMPLOYEE                                             
GENDER/A1 = DECODE FIRST_NAME(ALFRED 'M' RICHARD 'M' JOHN 'M'    
  ANTHONY 'M' ROGER 'M' MARY 'F' DIANE 'F' JOAN 'F' ROSEMARIE 'F'
  BARBARA 'F');                                                  
MIXEDNAME/A15 = LCWORD(15, LAST_NAME, MIXEDNAME);                
NAME/A16 = MIXEDNAME||',';                                       
END                                                              
                                                                 
TABLE FILE EMPLOYEE                                              
PRINT LAST_NAME NOPRINT GENDER NOPRINT      NAME NOPRINT         
HEADING                                                          
"Dear Ms. <NAME"                                                 
   WHEN GENDER EQ 'F';                                           
HEADING                                                          
"Dear Mr. <NAME>"                                                
      WHEN GENDER EQ 'M';                                        
HEADING                                                           
" "                                                 
HEADING                                             
"This is to inform you that your current salary is "
"<CURR_SAL and your job code is <CURR_JOBCODE>."
" "                                                 
"Sincerely,"                                       
HEADING                                             
"Barbara Cross "                                   
  WHEN DEPARTMENT EQ 'MIS';                         
HEADING                                             
"John Banning   "                                  
  WHEN DEPARTMENT EQ 'PRODUCTION' ;                 
WHERE LAST_NAME NE 'BANNING' OR 'CROSS'             
BY EMP_ID NOPRINT PAGE-BREAK                        
ON TABLE SET PAGE NOPAGE
END

The first page of output is for a male in the PRODUCTION department.

Dear Mr. Stevens,                                
                                                 
This is to inform you that your current salary is
     $11,000.00 and that A07 is your job code.   
                                                 
Sincerely,                                       
John Banning

The second page of output is for a female in the MIS department.

Dear Ms. Smith,                                  
                                                 
This is to inform you that your current salary is
     $13,200.00 and that B14 is your job code.   
                                                 
Sincerely,                                       
Barbara Cross

Example: Styling Multiple Headings With WHEN

The following request displays a page for each employee with salary and job code information for that employee. The first WHEN condition applies if the employee is female. The second WHEN condition applies if the employee is male. The third WHEN condition applies if the department is MIS. The fourth WHEN condition applies if the department is PRODUCTION. The StyleSheet declarations include styling elements for the second and third conditions.

DEFINE FILE EMPLOYEE                                             
GENDER/A1 = DECODE FIRST_NAME(ALFRED 'M' RICHARD 'M' JOHN 'M'    
  ANTHONY 'M' ROGER 'M' MARY 'F' DIANE 'F' JOAN 'F' ROSEMARIE 'F'
  BARBARA 'F');                                                  
MIXEDNAME/A15 = LCWORD(15, LAST_NAME, MIXEDNAME);                
NAME/A16 = MIXEDNAME||',';                                       
END                                                              
                                                                 
TABLE FILE EMPLOYEE                                              
PRINT LAST_NAME NOPRINT GENDER NOPRINT NAME NOPRINT         
HEADING                                                          
"Dear Ms. <NAME"                                                 
   WHEN GENDER EQ 'F';                                           
HEADING                                                          
"Dear Mr. <NAME>"                                                
      WHEN GENDER EQ 'M';                                        
HEADING                                                           
" "                                                 
HEADING                                             
"This is to inform you that your current salary is "
"<CURR_SAL and your job code is <CURR_JOBCODE>."
" "                                                 
"Sincerely,"                                       
HEADING                                             
"Barbara Cross "                                   
  WHEN DEPARTMENT EQ 'MIS';                         
HEADING                                             
"John Banning   "                                  
  WHEN DEPARTMENT EQ 'PRODUCTION' ;                 
WHERE LAST_NAME NE 'BANNING' OR 'CROSS'             
BY EMP_ID NOPRINT PAGE-BREAK                        
ON TABLE SET PAGE NOPAGE
ON TABLE HOLD FORMAT PDF     
ON TABLE SET STYLE *                     
TYPE=HEADING, CONDITION=2, STYLE=ITALIC,$
TYPE=HEADING, CONDITION=3, STYLE=BOLD,$  
ENDSTYLE                                 
END

In the StyleSheet for the request, heading lines displayed because of the first condition are in an italic typeface and heading lines displayed because of the third condition are in a bold typeface.

The first page of output is for a male employee, so the greeting line is in an italic typeface.

The second page of output is for an employee in the MIS department, so the signature line is in a bold typeface.

Subheads and Subfoots

How to:

Reference:

A subhead is text that can be placed before the sort field values change. A subfoot is text that can be placed after the sort field values change. You can use NEWPAGE on a subheading or subfooting to start a new page after the subheading or before the subfooting. It separates the subheading or subfooting from its associated data but does not separate the data from the next subheading or prior subfooting.

In conjunction with the PAGE-BREAK command, this enables you to create a cover page for each section of a report.

Note:

By default, FOCUS generates a blank line before a subheading or subfooting. You can eliminate these automatic blank lines by issuing the SET DROPBLNKLINE=ON command. For more information, see the Developing Applications manual.

Syntax: How to Create a Subhead

{ON|BY}  fieldname SUBHEAD [NEWPAGE]
"text"
[WHEN expression;]

where:

fieldname

Is the sort field before which the text is inserted.

NEWPAGE

Inserts a new page after the sort heading or before the sort footing. Column titles appear on every page. In HTML reports, blank space is added instead of a new page.

text

Is the text you supply between double quotation marks that is printed following the SUBHEAD phrase.

WHEN expression

Specifies a conditional subhead in the printing of a report, as determined by a Boolean expression. Used with SUBHEAD, the WHEN clause must be placed on a line following the text you enclose in double quotation marks.

Example: Using Subheads

This request creates a subheading whenever the PROD_NAME field changes:

TABLE FILE PROD
SUM PACKAGE AND UNIT_COST
BY PROD_NAME NOPRINT BY PROD_CODE
ON PROD_NAME SUBHEAD
" SUMMARY FOR <PROD_NAME"
END

The output is:

PROD_CODE  PACKAGE       UNIT_COST 
---------  -------       --------- 
 SUMMARY FOR AMERICAN CHEESE       
C7         8 OUNCES          $2.19 
 SUMMARY FOR BUTTER MILK           
C14        32 OUNCES         $1.89 
 SUMMARY FOR CHEDDAR CHEESE        
B19        7 OUNCES           $.95 
 SUMMARY FOR CHOCOLATE MILK        
B20        32 OUNCES         $1.79 
 SUMMARY FOR HEAVY CREAM           
C17        32 OUNCES         $1.89 
 SUMMARY FOR LARGE EGGS            
E2         ONE DOZEN          $.79 
 SUMMARY FOR MEDIUM EGGS           
E1         ONE DOZEN          $.59 
 SUMMARY FOR SALTED BUTTER         
D15        8 OUNCES           $.69 
 SUMMARY FOR SOUR CREAM            
C13        16 OUNCES         $1.49
 SUMMARY FOR SWISS CHEESE         
B17        16 OUNCES         $1.65
 SUMMARY FOR WHIPPED BUTTER       
D12        16 OUNCES         $1.79
 SUMMARY FOR WHOLE MILK           
B10        16 OUNCES          $.65
B12        32 OUNCES         $1.15
 SUMMARY FOR X-LARGE EGGS         
E3         ONE DOZEN          $.89

Syntax: How to Create Subfoots

The syntax is:

{ON|BY}  fieldname SUBFOOT  [WITHIN] [MULTILINES] [NEWPAGE]
"text"
[WHEN expression;]

where:

fieldname

Is the field after which the text is inserted.

WITHIN

Causes the fields in the SUBFOOT to be calculated within each value of fieldname. Without this option, a field in the SUBFOOT is taken from the last line of report output above the subfooting.

text

Is the text you supply between double quotation marks that is printed following the SUBFOOT phrase.

MULTILINES

Is used to suppress the SUBFOOT when there is only one line of output for the BY group. Note that MULTI-LINES is a synonym for MULTILINES.

FOCUS also allows you to suppress grand totals using the NOTOTAL phrase as described in Including Totals and Subtotals.

NEWPAGE

Inserts a new page after the heading or before the footing. Column titles appear on every page. In HTML reports, blank space is added instead of a new page.

WHEN expression

Specifies a conditional subfoot in the printing of a report, as determined by a Boolean expression. Used with SUBFOOT, WHEN must be placed on the line following the text you enclose in double quotation marks.

Reference: Usage Notes for Creating Subfoots

  • When a SUBFOOT follows a RECAP, the default display of the RECAP values is suppressed, as it is assumed that the SUBFOOT is being used to display the RECAP.
  • A SUBFOOT can also be used as a complete report request without any display command if data is embedded in the text, because fields in the text become implicit display fields. The default display command is SUM. For more information, see Using Data in Headings and Footings.
  • If the report request contains the command SUM and the display field is specified in a subfoot, the value is summed. Use direct operators with fields specified in subfootings.
  • SUBFOOT WITHIN is useful where a prefixed field within a sort break would result in a single value (for example, AVE., MIN., MAX). Use of PCT. or APCT. displays only the last value from the sort group.
  • SUBFOOT WITHIN "<prefix.fieldname "does not result in the same value as SUBTOTAL prefix. The SUBFOOT WITHIN creates a display field that operates on the original input records. SUBTOTAL with a prefix operates on the internal matrix (so AVE. is the average of the SUMS or, if a display field had the prefix AVE., the average of the averages). SUBFOOT WITHIN "<AVE.field " generates an overall average.
  • Prefix operators are not supported on alphanumeric fields in a WITHIN phrase.
  • ST. is not supported in a SUBFOOT WITHIN phrase.

Example: Using Subfoots

This example creates a subfooting whenever the DEPARTMENT value changes:

TABLE FILE EMPLOYEE
SUM DED_AMT AND GROSS
BY DEPARTMENT BY HIGHEST PAY_DATE
ON DEPARTMENT RECAP
DEPAR_NET/D8.2=GROSS-DED_AMT;
ON DEPARTMENT SUBFOOT
"DEPARTMENT NET = <DEPAR_NET"
END

The output is:

DEPARTMENT  PAY_DATE          DED_AMT            GROSS
----------  --------          -------            -----
MIS         82/08/31        $4,575.72        $9,000.00
            82/07/30        $4,117.03        $7,460.00
            82/06/30        $4,117.03        $7,460.00
            82/05/28        $3,954.35        $6,649.50
            82/04/30        $3,386.73        $5,890.84
            82/03/31        $1,740.89        $3,247.75
            82/02/26        $1,740.89        $3,247.75
            82/01/29        $1,740.89        $3,247.75
            81/12/31        $1,406.79        $2,147.75
            81/11/30        $1,406.79        $2,147.75
DEPARTMENT NET = 22,311.98                            
PRODUCTION  82/08/31        $4,911.12        $9,523.84
            82/07/30        $3,483.88        $7,048.84
            82/06/30        $3,483.88        $7,048.84
            82/05/28        $3,483.88        $7,048.84
            82/04/30        $2,061.69        $4,959.84
            82/03/31        $2,061.69        $4,959.84
            82/02/26        $2,061.69        $4,959.84
            82/01/29        $1,560.09        $3,705.84
            81/12/31          $141.66          $833.33
            81/11/30          $141.66          $833.33
DEPARTMENT NET = 27,531.14                            

Example: Generating a Subfoot Within a Sort Group

The following request displays the average and minimum salary values first within department, then within department and job class, and last within department, job class and employee ID. Subfootings are generated on the department and jobcode sort fields. The DEFINE FILE command created two additional fields with the SALARY value, one for each sort break:

DEFINE FILE EMPDATA                            
SALDEPT/D6  WITH SALARY = SALARY;              
SALDEPTJOB/D6  WITH SALARY = SALARY;           
DEPT/A4 WITH SALARY = EDIT(DEPT, '9999');
JOB/A8 WITH SALARY = JOBCLASS;                 
END                                            
TABLE FILE EMPDATA                             
SUM AVE.SALDEPT    AS 'DEPT,AVE'               
     MIN.SALDEPT   AS 'DEPT,MIN'               
  BY DEPT                                      
SUM AVE.SALDEPTJOB  AS 'DEPT/JOB,  AVE' IN 32  
     MIN.SALDEPTJOB AS 'DEPT/JOB,  MIN' IN 42  
BY DEPT                                        
BY JOB                                         
PRINT AVE.SALARY/D6  AS 'AVE' IN 52            
      MIN.SALARY/D6  AS 'MIN' IN 61            
BY DEPT                                        
BY JOB                                         
BY PIN    NOPRINT                              
ON DEPT SUBFOOT                                
"******************DEPARTMENT <DEPT SUBFOOT**************************"   
"NOT WITHIN: AVE=<AVE.SALARY  MIN=<MIN.SALARY "                          
ON DEPT SUBFOOT WITHIN                                                   
"    WITHIN: AVE=<AVE.SALARY  MIN=<MIN.SALARY "                          
"*******************************************************************"    
ON JOB SUBFOOT                                                           
"</1 ***************DEPARTMENT <DEPT / JOB <JOB  SUBFOOT***************" 
"NOT WITHIN: AVE=<AVE.SALARY  MIN=<MIN.SALARY "                          
ON JOB SUBFOOT WITHIN                                                    
"    WITHIN: AVE=<AVE.SALARY  MIN=<MIN.SALARY "                          
"******************************************************************* </1"
  WHERE DEPT EQ 'MARK'                                                   
  WHERE  JOBCLASS EQ '257PSB' OR '257PTB'                                
END                                                                      

The report output shows that each SUBFOOT without the WITHIN phrase uses the report line above the subfooting in the calculations. The SUBFOOT within both department and jobcode uses the calculations that were specified in the second SUM command (by department by jobcode), and the SUBFOOT within department only uses the calculations that were specified in the first SUM command (by department):

         DEPT     DEPT         DEPT/JOB  DEPT/JOB                  
DEPT     AVE      MIN   JOB      AVE       MIN         AVE      MIN
----     ----     ----  ---    --------  --------      ---      ---
MARK   56,757   50,500  257PSB   55,860    50,500   55,500   55,500
                                                    62,500   62,500
                                                    50,500   50,500
                                                    52,000   52,000
                                                    58,800   58,800
                                                                   
***************DEPARTMENT MARK / JOB 257PSB  SUBFOOT***************
NOT WITHIN: AVE=     $58,800.00  MIN=     $58,800.00               
    WITHIN: AVE=     $55,860.00  MIN=     $50,500.00               
*******************************************************************
                                                                   
                        257PTB   59,000    55,500   62,500   62,500
                                                    55,500   55,500
                                                                   
***************DEPARTMENT MARK / JOB 257PTB  SUBFOOT***************
NOT WITHIN: AVE=     $55,500.00  MIN=     $55,500.00               
    WITHIN: AVE=     $59,000.00  MIN=     $55,500.00               
*******************************************************************
******************DEPARTMENT MARK SUBFOOT**************************
NOT WITHIN: AVE=     $55,500.00  MIN=     $55,500.00               
    WITHIN: AVE=     $56,757.14  MIN=     $50,500.00               
*******************************************************************

Example: Creating a Cover Page for Each Sort Group in a Report

The following request prints the subheading "SUM OF PRICES AND QUANTITIES FOR THE region REGION" and then starts a new page containing the data for that region. The PAGE-BREAK command starts a new page after printing this data, prior to the subheading for the subsequent region:

TABLE FILE CENTORD
SUM LINEPRICE AS ''
QUANTITY AS ''
BY REGION NOPRINT PAGE-BREAK
BY STATE AS ''
ON REGION SUBHEAD NEWPAGE
"SUM OF PRICES AND QUANTITIES FOR THE <REGION REGION"
END

The first few pages of output follow:

PAGE     1
 
 
SUM OF PRICES AND QUANTITIES FOR THE EAST REGION
 
PAGE     2
 
 
CT   $16,238,158.37      65,979
DC   $70,928,546.26     274,714
DE    $2,500,849.39      10,226
MA   $34,010,314.29     131,956
MD   $24,978,362.10      94,827
NH    $4,985,236.56      20,752
NJ   $38,906,712.15     154,974
NY   $41,667,939.52     171,742
PA   $27,830,850.54     104,456
RI      $821,994.05       3,250
VT    $2,751,969.47      10,631
 
PAGE     3
 
 
SUM OF PRICES AND QUANTITIES FOR THE NORTH REGION
 
PAGE     4
 
 
IA    $2,469,227.24      10,068
IL   $34,444,984.60     134,351
IN   $12,477,236.78      50,124
KS    $2,136,103.34       7,870
MI   $47,979,137.95     191,671
MN   $28,162,612.99     114,687
NA    $1,027,220.04       3,040
OH   $25,681,832.51     102,089
ON   $12,699,111.42      49,142
WI   $11,283,071.47      44,157

Note that without the PAGE-BREAK command, the subheading for each new region prints at the bottom of the page for the prior region's data.

Using Data in Headings and Footings

How to:

Reference:

You can embed the values of fields in headings, subheads, subfoots, and footings.

Syntax: How to Insert Data in Headings and Footings

To put a value in one of these titles, use the following syntax:

<fieldname 
<fieldname>

where:

<fieldname

Places the data value in the heading or footing, and suppresses trailing blanks.

<fieldname>

Places the data value in the heading or footing, and retains trailing blanks.

Reference: Usage Notes for Data in Headings and Footings

  • Trailing blanks in alphanumeric fields may be omitted by using only the opening < character for data in headings. For example, if AREA is a 16-character alphanumeric field, the line is expanded by 16 characters at the point of substitution of the retrieved value. If only the opening character is used, only the non-blank characters of the particular value are substituted. For example, if <AREA retrieves the value of EAST, only four characters plus one leading blank are inserted in the line, rather than a full 16 characters which the data value could contain.
  • The DST., MDE,, and MDN. prefix operators are not supported in headings or footings in requests that have an ACROSS phrase or multiple display commands.
  • A SUBFOOT can be used as a complete report request without any display command if data is embedded in the text, because fields in the text become implicit display fields.
  • You can place page numbers in headings and footings using TABPAGENO (see Inserting Page Numbers: TABPAGENO).
  • Fields in headings and footings are evaluated as if they were objects of the first verb. Fields in subheads and subfoots are evaluated as part of the first verb in which they are referenced. If a field is not referenced, it is evaluated as part of the last verb.
  • Text fields (FORMAT=TXnn) can be embedded in a heading or footing.
    • Text field values may display on multiple lines. The output is aligned vertically so that the position of the field on the initial line is maintained on the following lines.
    • The number of characters in the TX format specification determines the number of spaces per line for the field in the heading or footing.
    • HEADING and FOOTING lines can contain multiple TX fields. SUBHEAD and SUBFOOT lines can contain at most one.
    • You cannot embed TX fields in FML free-text lines.

Example: Using Data in a Heading and Footing

This request displays the DEPARTMENT field in the heading and footing:

TABLE FILE EMPLOYEE
"<DEPARTMENT>: BANK, EMPLOYEES AND SALARIES </1"
PRINT CURR_SAL
BY DEPARTMENT NOPRINT BY BANK_ACCT
BY LAST_NAME BY FIRST_NAME
ON DEPARTMENT PAGE-BREAK
FOOTING
"<DEPARTMENT EMPLOYEES WITH ELECTRONIC TRANSFER ACCOUNTS"
END

The output is:

PAGE     1                                             
                                                       
MIS        : BANK, EMPLOYEES AND SALARIES              
                                                       
BANK_ACCT  LAST_NAME        FIRST_NAME         CURR_SAL
---------  ---------        ----------         --------
           GREENSPAN        MARY              $9,000.00
           MCCOY            JOHN             $18,480.00
           SMITH            MARY             $13,200.00
 40950036  JONES            DIANE            $18,480.00
122850108  BLACKWOOD        ROSEMARIE        $21,780.00
163800144  CROSS            BARBARA          $27,062.00
                                                       
MIS EMPLOYEES WITH ELECTRONIC TRANSFER ACCOUNTS        
PAGE     2                                             
                                                       
PRODUCTION : BANK, EMPLOYEES AND SALARIES              
                                                       
BANK_ACCT  LAST_NAME        FIRST_NAME         CURR_SAL
---------  ---------        ----------         --------
           ROMANS           ANTHONY          $21,120.00
           SMITH            RICHARD           $9,500.00
           STEVENS          ALFRED           $11,000.00
   160633  BANNING          JOHN             $29,700.00
136500120  MCKNIGHT         ROGER            $16,100.00
819000702  IRVING           JOAN             $26,862.00
                                                       
PRODUCTION EMPLOYEES WITH ELECTRONIC TRANSFER ACCOUNTS 

Positioning Text

The positioning of text and data in headings, footings, subheads, and subfoots can be controlled by a spot marker, which identifies the column where the text should begin. A spot marker consists of a left caret (<) followed by a number indicating the absolute or relative column position. The right caret (>) is optional, and can make the spot marker clearer to a reader.

The various ways spot markers can be used are illustrated in the chart below:

Marker

Example

Usage

<n or <n> 
<50 

The next character starts in column 50.

<+n or <+n> 
<+4 

The next character starts four columns from the last non-blank character.

<-n or <-n> 
<-1 

The next character starts one column to the left of the last character and suppresses or writes over all or part of a field.

</n or </n> 
</2 

Skip two lines.

<0X or <0X>
<0X

Positions the next character immediately to the right of the last character (skip zero columns). This is used when you have more than two lines between the double quotation marks in a stored procedure that make up a single line of heading, subhead, footing, or subfoot display. No spaces are inserted between the spot marker and the start of a continuation line.

Note: If you place a skip line spot marker on a line by itself, it skips one line more than you asked for. To avoid this, put the skip line marker on the same line with additional text from the report. In addition, each field needs one space for field attributes; if a field placed with a spot marker overlaps an existing field, unpredictable results may occur.

Example: Positioning Text

  • To place a character in a specific column:
    "<50 SUMMARY REPORT"

    The letter S in SUMMARY starts in Position 50 of the line.

  • To place a substituted value in a specific column:
    "<15 COST OF VEHICLE IS <40 <RCOST>"
    "<10 <DIVISION <30 <AREA <50 <DATE"
  • To add spaces to the right of the last non-blank character:
    "DAILY REPORT <DATE <+5 <LOCATION <+5 <PRODUCT"
  • To move to the left of the last non-blank character:
    "<60 CONFIDENTIAL <-40 <FIRST_NAME"

    Skipping backward may cover other text on a line. This may be useful in some cases, but in general should be avoided.

  • To show four lines of heading text between double quotation marks:
    "THIS HEADING <0X
    SHOULD APPEAR <0X
    ON ONE <0X
    LINE"

    The above produces the line:

    THIS HEADING SHOULD APPEAR ON ONE LINE
  • To position a long line:
    "<20 DETAIL REPORT WITH LOTS OF TEXT ON ONE LINE
    <100 EVEN THOUGH IT IS ON TWO LINES IN THE REQUEST"
  • To skip multiple lines:
    "</4 THIS IS ON THE FIFTH LINE DOWN"

Extending Heading and Footing Code to Multiple Lines

How to:

A single line heading or footing code, between double quotation marks, can be a maximum of 32K characters. However, in some editors the maximum length of a line of code in a procedure is 80 characters. In cases like this, you can use the <0X spot marker to continue your heading onto the next line. The heading or footing content and spacing appears exactly as if typed on a single line.

Even if you do not need to extend your code beyond the 80-character line limit, this technique is convenient, since shorter lines may be easier to read on screen and to print on printers.

Procedure: How to Extend Heading and Footing Code to Multiple Lines

To extend the length of a single-line heading or footing beyond 80 characters:

  1. Begin the heading or footing with double quotation marks.
  2. Split the heading or footing content into multiple lines of up to 76 characters each, using the <0X spot marker at any point up to the 76th character to continue your heading onto the next line. (The four remaining spaces are required for the spot marker itself, and a blank space preceding it.)
  3. Place the closing double quotation marks at the end of the final line of heading or footing code.

Example: Extending Heading and Footing Code to Multiple Lines

This request creates a sort heading coded on two lines. The <0X spot marker positions the first character on the continuation line immediately to the right of the last character on the previous line. No spaces are inserted between the spot marker and the start of a continuation line.

SET PAGE-NUM = OFF
JOIN STORE_CODE IN CENTCOMP TO STORE_CODE IN CENTORD
TABLE FILE CENTCOMP
HEADING
"Century Corporation Orders Report"
PRINT PROD_NUM QUANTITY LINEPRICE
BY STORE_CODE NOPRINT
BY ORDER_NUM
ON STORE_CODE SUBHEAD
"Century Corporation orders for store <STORENAME <0X
(store # <STORE_CODE|) <0X in <STATE|."
END

The partial output is:

 Century Corporation Orders Report                                         
 Order    Product                         Line                             
 Number:  Number#:   Quantity:            Total                            
 -------  --------   ---------            -----                            
 Century Corporation orders for store Audio Expert (store # 1003CA)  in CA.
 48108    1006              90       $29,310.78                            
          1008              90       $13,368.96                            
          1020              90       $25,033.89                            
          1032             290       $20,481.38                            
          1034             290      $114,618.37                            
 Century Corporation orders for store Audio Expert (store # 1003CO)  in CO.
 54095    1006              12        $3,645.42                            
          1008              12        $1,926.35                            
          1020              12        $3,314.28                            
          1032             211       $15,983.61                            
          1034             211       $87,868.51                            

Tip: Although it is demonstrated here for a sort heading, you can use this technique with any heading or footing line.

The following example lists the employee's name, department, job description, and skill category in the heading:

TABLE FILE EMPLOYEE
"EMPLOYEE NAME            <FIRST_NAME <LAST_NAME"
"CURRENT DEPARTMENT       <DEPARTMENT"
"JOB TITLE                <JOB_DESC"
"**********************************"
"SKILL CATEGORY           <SKILLS"
"**********************************"
" "
WHERE EMP_ID IS '112847612'
END

The output is:

EMPLOYEE NAME            MARY SMITH  
CURRENT DEPARTMENT       MIS         
JOB TITLE                FILE QUALITY
**********************************   
SKILL CATEGORY           FIQU        
**********************************   

You can use any prefix operator in a heading or footing to perform specific operations. This example prints the maximum, minimum, average, and total units sold:

TABLE FILE SALES
"MOST UNITS SOLD WERE     <MAX.UNIT_SOLD"
"LEAST UNITS SOLD WERE    <MIN.UNIT_SOLD"
"AVERAGE UNITS SOLD WERE  <AVE.UNIT_SOLD"
"TOTAL UNITS SOLD WERE    <TOT.UNIT_SOLD"
END

The output is:

PAGE     1                    
                              
MOST UNITS SOLD WERE        80
LEAST UNITS SOLD WERE       12
AVERAGE UNITS SOLD WERE     35
TOTAL UNITS SOLD WERE      645

This request prints the COUNTRY field, count of models, and average retail cost in a subfoot each time the country changes:

TABLE FILE CAR
BY COUNTRY NOPRINT SUBFOOT
"NUMBER OF MODELS IN COUNTRY <COUNTRY = <CNT.MODEL <0X
WITH AVERAGE COST OF <AVE.RCOST "
END

The output is:

NUMBER OF MODELS IN COUNTRY ENGLAND =     4 WITH AVERAGE COST OF    11,330  
                                                                            
NUMBER OF MODELS IN COUNTRY FRANCE =     1 WITH AVERAGE COST OF     5,610   
                                                                            
NUMBER OF MODELS IN COUNTRY ITALY =     4 WITH AVERAGE COST OF    12,766    
                                                                            
NUMBER OF MODELS IN COUNTRY JAPAN =     2 WITH AVERAGE COST OF     3,239    
                                                                            
NUMBER OF MODELS IN COUNTRY W GERMANY =     7 WITH AVERAGE COST OF     9,247

This request prints the totals of units sold, returns, and actual sales:

DEFINE FILE SALES
ACTUAL_SALES/D8.2 = UNIT_SOLD-RETURNS;
%SALES/F5.1 = 100*ACTUAL_SALES/UNIT_SOLD;
END
  
TABLE FILE SALES
"SUMMARY OF ACTUAL SALES"
"UNITS SOLD               <TOT.UNIT_SOLD"
"RETURNS                   <TOT.RETURNS"
"                          =============="
"TOTAL SOLD              <TOT.ACTUAL_SALES"
" "
"BREAKDOWN BY PRODUCT"
PRINT UNIT_SOLD AND RETURNS AND ACTUAL_SALES
BY PROD_CODE
END

The following shows the beginning of the output:

SUMMARY OF ACTUAL SALES                    
UNITS SOLD                645              
RETURNS                    58              
                          ==============   
TOTAL SOLD                587.00           
                                           
BREAKDOWN BY PRODUCT                       
PROD_CODE  UNIT_SOLD  RETURNS  ACTUAL_SALES
---------  ---------  -------  ------------
B10               60       10         50.00
                  30        2         28.00
                  13        1         12.00
B12               40        3         37.00

The following special operators are specifically for use in subfootings:

ST.fieldname

Produces a subtotal value of the specified field at a sort break in the report.

CT.fieldname

Produces a cumulative total of the specified field.

Producing a Free-Form Report

Report requests do not have to produce a tabular display, but may consist of only the heading, as long as the heading has a data field referenced in it. If the request has no display command but there is a data field embedded in the heading, FOCUS assumes that this is a heading-only request and does not print the body of the report. Any data fields referenced in the heading are treated as if they were display fields. Their values at the time the heading is printed are what they would have been had they been mentioned as in a display command. Free-form reports are described in detail in Creating a Free-Form Report.


Information Builders