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.
{HEADING [CENTER]|FOOTING} "text_and_data1" . . . "text_and_datan" WHEN expression
where:
Is the text and data for each heading or footing line.
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.
TYPE = {HEADING|FOOTING}, CONDITION = n, ... ,$
where:
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.
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
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.
Information Builders |