In this section: |
You can position data within a report by selecting a justification (right, left or center) of a column or by specifying whether or not you wish to have data wrap within a cell. For information on positioning a column on the page, see Laying Out the Report Page.
How to: |
Reference: |
You can control the wrapping of report data in a report, thus preventing line breaks within report cells. When using HTML output, most web browsers will, by default, wrap alphanumeric report data that does not fit on a single line in a cell.
This bumps the contents of the cell onto a second line. A web browser wraps data based on its algorithmic settings. Use the WRAP attribute if you wish to suppress a web browser data wrapping.
By default, WRAP is set to ON for HTML output, allowing each individual browser to define the width of each column in the report. For PDF, PS, DHTML, PPT, and PPTX output, WRAP is set OFF by default. For these positioned output formats in which the location of each item in the report is explicitly defined, WRAP = ON is not a valid value, except when specified for ACROSSVALUE. For other elements of the report, such as headers, footers, titles, or data, define the width of wrapped lines by using a numerical value, as in WRAP = n.
In PDF and PostScript report output, you can control the line spacing in wrapped lines by using the WRAPGAP attribute.
Wrapping Data in PDF Reports That Use the OVER Phrase
OVER allows the presentation of a single data record across multiple lines within a report. By default, when OVER is defined within a request, the report shifts from a columnar presentation to a row level presentation. The field titles are displayed to the left of each value, rather than at the top of each column. This layout was not designed to be aligned in any specific fashion but to allow for the presentation of multiple elements of data within a small area. In many cases, reports that place columns over each other use blank AS names in order to align the columns properly. You can use the WRAP attribute to wrap data in PDF reports that use OVER and this technique works well with blank AS names.
Wrapping Data in PDF Reports That Use the ACROSS Phrase
In a request that uses ACROSS, the output displays each value of the ACROSS field above the set of data columns applicable to that ACROSS value.
If the ACROSS value is longer than the width of its columns, you can wrap the ACROSS value within the width of its underlying columns.
By default, the width of each ACROSS value group (the ACROSS value and the data columns within) is defined as the largest of either the sum of the width of the data columns or the largest ACROSS value for that group. With wrapping, the size of each ACROSS wrap will be defined by the width defined based on this rule including all data columns and any non-wrapped across fields.
The width of each ACROSS column for a given ACROSS group is defined as the length of the largest value for that ACROSS group. A single width is used for each group so in groups where the values are shorter than the longest value, you will see a larger right gap within the cell.
For reports containing multiple ACROSS fields, you can wrap individual ACROSS fields or all of them. Each designated value will wrap within the defined ACROSS group.
To control wrapping of text inside a report, use the following syntax within a StyleSheet.
TYPE=type, [subtype,] WRAP=value, $
where:
Is the report component you wish to affect, such as REPORT, HEADING, or TITLE.
Is any additional attribute, such as COLUMN, ACROSS, ITEM etc. that is needed to identify the report component that you are formatting. See Identifying a Report Component in a WebFOCUS StyleSheet for more information about how to specify different report components.
Is one of the following:
Note: This setting is not supported when using WRAP with OVER in PDF report output.
Note: WRAP=ON and WRAP=n are not supported with JUSTIFY.
The following example, with WRAP=ON, wraps report data based on the web browser functionality. Note that because this value is the default, there is no need to specify WRAP=ON in the report request syntax.
TABLE FILE GGPRODS PRINT SIZE UNIT_PRICE PACKAGE_TYPE VENDOR_CODE VENDOR_NAME BY PRODUCT_ID BY PRODUCT_DESCRIPTION ON TABLE SET STYLE * TYPE=REPORT, GRID=ON, $ ENDSTYLE END
Note: Wrap is determined by the size of your browser window, so you may need to shrink your window to see the example wrap the data as in the following image.
Notice that records in the Vendor Name column break to a second line.
The following report request, with WRAP=OFF, suppresses the web browser data wrapping:
TABLE FILE GGPRODS PRINT SIZE UNIT_PRICE PACKAGE_TYPE VENDOR_CODE VENDOR_NAME BY PRODUCT_ID BY PRODUCT_DESCRIPTION ON TABLE SET STYLE * TYPE=REPORT, WRAP=OFF, $ TYPE=REPORT, GRID=ON, $ ENDSTYLE END
The output is:
The following request against the GGPRODS data source places the column VENDOR_NAME on a new line with the OVER phrase. By default, wrap is turned off and must be defined explicitly within the StyleSheet:
TABLE FILE GGPRODS PRINT SIZE UNIT_PRICE PACKAGE_TYPE OVER VENDOR_NAME BY PRODUCT_ID BY PRODUCT_DESCRIPTION ON TABLE PCHOLD FORMAT PDF ON TABLE SET STYLE * TYPE=REPORT, SQUEEZE=ON, $ ENDSTYLE END
The partial output is shown in the following image.
The following version of the request turns wrapping on and sets a column width of 1.5 for the VENDOR_NAME column, which has been placed on a new line because of the OVER phrase:
TABLE FILE GGPRODS PRINT SIZE UNIT_PRICE PACKAGE_TYPE OVER VENDOR_NAME BY PRODUCT_ID BY PRODUCT_DESCRIPTION ON TABLE PCHOLD FORMAT PDF ON TABLE SET STYLE * TYPE=REPORT, COLUMN=VENDOR_NAME, WRAP=1.5,$ ENDSTYLE END
The partial output shows that the VENDOR_NAME column now wraps. Notice that turning WRAP ON causes the OVER value, not the OVER TITLE, to wrap:
Wrapping ACROSS Values is supported for HTML and PDF output formats.
TYPE=ACROSSVALUE, [ACROSS={fieldname|Nn|An}] WRAP={OFF|ON} ,$
where:
Note: WRAP=ON is not supported with JUSTIFY.
In the following request against the GGPRODS data source, VENDOR_NAME is an ACROSS field:
TABLE FILE GGPRODS HEADING " PRODUCT REPORT" " " PRINT PRODUCT_ID UNIT_PRICE/D5 ACROSS VENDOR_NAME BY SIZE WHERE VENDOR_NAME GT 'B' AND VENDOR_NAME LT 'F' ON TABLE PCHOLD FORMAT PDF ON TABLE SET STYLE * TYPE=REPORT, GRID=OFF, $ TYPE=REPORT, COLUMN=PRODUCT_ID, WIDTH=.25, $ TYPE=REPORT, COLUMN=UNIT_PRICE, WIDTH=.25, $ ENDSTYLE END
As shown in the following image, the output is too wide for one panel because some of the ACROSS field values (vendor names) are longer than the sum of the product code and unit price columns under them.
The following version of the request wraps the ACROSS values (TYPE=ACROSSVALUE, WRAP=ON ,$):
TABLE FILE GGPRODS HEADING " PRODUCT REPORT" " " PRINT PRODUCT_ID UNIT_PRICE/D5 ACROSS VENDOR_NAME BY SIZE WHERE VENDOR_NAME GT 'B' AND VENDOR_NAME LT 'F' ON TABLE PCHOLD FORMAT PDF ON TABLE SET STYLE * TYPE=REPORT, GRID=OFF, $ TYPE=REPORT, COLUMN=PRODUCT_ID, WIDTH=.25, $ TYPE=REPORT, COLUMN=UNIT_PRICE, WIDTH=.25, $ TYPE = ACROSSVALUE, WRAP=ON,$ ENDSTYLE END
The report now fits on one panel, as shown in the following image.
When OVER fields are defined with blank AS names (the value of the title of the column is set to empty ' '), they can be used to build a report with multiple data lines that present in an aligned grid fashion.
In this type of report, the column titles are usually indicated by adding multiple corresponding lines to the page headings rather than using the default titles that display to the left of the column field values. To present OVER fields with unique titles that take advantage of these new alignment features, you can place the column titles in independent fields and include them as fields within the given request.
The following example demonstrates using OVER with blank AS names and WRAP to build a multi-data line report:
TABLE FILE GGPRODS PRINT PACKAGE_TYPE AS '' SIZE AS '' OVER VENDOR_NAME AS '' BY PRODUCT_ID AS '' BY PRODUCT_DESCRIPTION AS '' ON TABLE SUBHEAD "Gotham Grinds" "Products Details" HEADING " Code <+0>Description<+0>Size <+0>Package" -*" <+0> <+0>Vendor" " <+0>Vendor" ON TABLE PCHOLD FORMAT PDF ON TABLE SET STYLE * TYPE=REPORT, FONT=ARIAL, SIZE=10, SQUEEZE=ON,$ TYPE=REPORT, COLUMN=PACKAGE_TYPE, SQUEEZE=.5 ,$ TYPE=REPORT, COLUMN=VENDOR_NAME, WRAP=1 ,$ TYPE=REPORT, BORDER=ON, $ TYPE=HEADING, LINE=1, ITEM=1, BORDER=ON, $ TYPE=HEADING, LINE=1, ITEM=2, BORDER=ON, POSITION=PRODUCT_DESCRIPTION,$ TYPE=HEADING, LINE=1, ITEM=3, BORDER=ON, POSITION=SIZE ,$ TYPE=HEADING, LINE=1, ITEM=4, BORDER=ON, POSITION=PACKAGE_TYPE, $ TYPE=HEADING, LINE=2, ITEM=1, BORDER=ON, $ TYPE=HEADING, LINE=2, ITEM=2, BORDER=ON, POSITION=PACKAGE_TYPE,$ ENDSTYLE END
On the report output, the Package Type and Size have been placed over the vendor name. The page heading has the corresponding titles. In the heading, the titles Package and Size have also been placed over the title Vendor Name. Note that the vendor name data wraps to maintain the alignment.
The width of both the column title and the column data for each OVER value is determined by the single SQUEEZE or WRAP value. The title will automatically size to the same width as the wrapped data column. If the column title is wider than the width defined for the column wrap, you can either define a smaller title or add your titles as OVER fields that can be sized independently.
The following examples demonstrate how to build a report with OVER and WRAP that has column titles longer than the designated WRAP size.
The following request defines two virtual fields to contain the column titles for the Product Name and Vendor Name fields. It then prints each virtual field next to its related data field and gives each a blank AS name. The first virtual field and data field are placed over the second virtual field and data field:
DEFINE FILE GGPRODS TITLE_PROD/A20 = 'Product Description'; TITLE_VEND/A20 = 'Vendor Name'; END TABLE FILE GGPRODS PRINT TITLE_PROD AS '' PRODUCT_DESCRIPTION AS '' OVER TITLE_VEND AS '' VENDOR_NAME AS '' BY PRODUCT_ID AS '' ON TABLE SUBHEAD "Gotham Grinds" "Products Details" ON TABLE PCHOLD FORMAT PDF ON TABLE SET STYLE * TYPE=REPORT, FONT=ARIAL, SIZE=10, SQUEEZE=ON,$ TYPE=REPORT, COLUMN=TITLE_PROD , SQUEEZE=1.25 ,$ TYPE=REPORT, COLUMN=TITLE_VEND , SQUEEZE=1.25 ,$ TYPE=REPORT, COLUMN=PRODUCT_DESCRIPTION, WRAP=.75 ,$ TYPE=REPORT, COLUMN=VENDOR_NAME, WRAP=.75 ,$ TYPE=REPORT, BORDER=ON, $ ENDSTYLE END
The output shows that the titles and data align properly.
You can use the WRAPGAP attribute in a StyleSheet to control spacing between wrapped lines in the data elements in PDF and PostScript report output.
TYPE=DATA, WRAPGAP={ON|OFF|n}
where:
Does not leave any space between wrapped lines. ON is equivalent to specifying 0.0 for n.
Places wrapped data on the next line. OFF is the default value.
Is a number greater than or equal to zero that specifies how much space to leave between wrapped lines (using the unit of measurement specified by the UNITS attribute). Setting n to zero does not leave any space between wrapped lines, and is equivalent to specifying WRAPGAP=ON.
In the following request, wrapping is turned on for the ADDRESS_LN3 column of the report:
TABLE FILE EMPLOYEE PRINT ADDRESS_LN3 BY LAST_NAME BY FIRST_NAME WHERE LAST_NAME LE 'CROSS' ON TABLE PCHOLD FORMAT PDF ON TABLE SET PAGE NOPAGE ON TABLE SET STYLE * type=report, grid=on, $ type=data, topgap=0.2, bottomgap=0.2, $ type=data, wrapgap=off, $ type=REPORT, column=ADDRESS_LN3, wrap=1.0 ,$ ENDSTYLE END
With WRAPGAP=OFF, each wrapped line is placed on the next report line:
With WRAPGAP=ON, the wrapped lines are placed directly under each other:
You can only specify WRAPGAP for columns that have wrapping enabled (WRAP attribute or parameter set to ON or a number). The TOPGAP and BOTTOMGAP attributes specify how much vertical space to leave above and below a report component. Increasing the values or these attributes makes a decrease in spacing between wrapped lines more noticeable.
How to: |
You can adjust text within a column by specifying whether report columns are left justified, right justified, or centered. By default, alphanumeric columns are left justified, numeric columns are right justified, and heading and footing elements are left justified. However, you can change the default using the JUSTIFY attribute. For information on justifying column titles using /R /L and /C, see Using Headings, Footings, Titles, and Labels.
To left justify, right justify, or center a column, use the following syntax within a StyleSheet.
TYPE=type, [subtype,] [COLUMN=column,] JUSTIFY=option, $
where:
Is the report component you wish to affect, such as REPORT, HEADING, or TITLE.
Is any additional attribute, such as COLUMN, ACROSS, ITEM etc. that is needed to identify the report component that you are formatting. For more information about how to specify different report components, see Identifying a Report Component in a WebFOCUS StyleSheet.
Is the column or group of columns you wish to justify. This attribute is only necessary if you wish to justify a specific column or set of columns. Omitting this attribute justifies the entire report.
Is the justification you wish to select:
Note: JUSTIFY is not supported with WRAP=ON or WRAP=n.
The following example displays the StyleSheet syntax used to center the data in the Vendor Name column. The header is also center justified.
TABLE FILE GGPRODS HEADING "PRODUCT REPORT" SUM UNITS BY PRODUCT_DESCRIPTION BY PRODUCT_ID BY VENDOR_NAME ON TABLE SET STYLE * TYPE=REPORT, COLUMN=VENDOR_NAME, JUSTIFY=CENTER, $ TYPE=HEADING, JUSTIFY=CENTER, $ TYPE=REPORT, GRID=OFF, $ ENDSTYLE END
The output is:
How to: |
Field-based reformatting allows you to apply different formats to each row in a single report column by using a field to identify the format that applies to each row. For example, you can use this technique to apply the appropriate decimal currency formats when each row represents a different country.
The field that contains the format specifications can be:
The field that contains the formats must be alphanumeric and be at least eight characters in length. Only the first eight characters are used for formatting.
The field-based format may specify a length longer than the length of the original field. However, if the new length is more than one-third larger than the original length, the report column width may not be large enough to hold the value (indicated by asterisks in the field).
You can apply a field-based format to any type of field. However, the new format must be compatible with the original format:
If the field-based format is invalid or specifies an impermissible type conversion, the field displays with plus signs (++++) on the report output. If the format field is blank or missing, the value is displayed without reformatting.
DEFINE FILE filename format_field/A8 = expression; END
DEFINE format_field/A8 = expression; $
COMPUTE format_field/A8 = expression;
where:
After the format field is defined, you can apply it in a report request:
TABLE FILE filename displayfieldname/format_field[/just] END
where:
DEFINE FILE CAR CFORMAT/A8 = DECODE COUNTRY('ENGLAND' 'D10.1' 'JAPAN' 'D10' ELSE 'D10.2'); END TABLE FILE CAR SUM SALES/CFORMAT/C DEALER_COST/CFORMAT BY COUNTRY END
The output is:
COUNTRY SALES DEALER_COST ------- --------- ----------- ENGLAND 12,000.0 37,853.0 FRANCE .00 4,631.00 ITALY 30,200.00 41,235.00 JAPAN 78,030 5,512 W GERMANY 88,190.00 54,563.00
How to: |
Using StyleSheet attributes, you can display An (character) and AnV (varchar) fields that contain line breaks on multiple lines in a PDF or PostScript report. Line breaks can be based on line-feeds, carriage-returns, or a combination of both. If you do not add these StyleSheet attributes, all line-feed and carriage-return formatting within these fields will be ignored, and all characters will be displayed on one line that wraps to fit the width of the report.
TYPE=REPORT,LINEBREAK='type',$
where:
LF inserts a line break after each line-feed character found in all An and AnV fields.
CR inserts a line break after each carriage-return character found in all An and AnV fields.
LFCR inserts a line break after each combination of a line-feed character followed by a carriage-return character found in all An and AnV fields.
CRLF inserts a line break after each combination of a carriage-return character followed by a line-feed character found in all An and AnV fields.
Note: This feature is supported in PDF, PPTX, or PS formats.
The following request defines an alphanumeric named ANLB field with a semicolon (in an EDCDIC environment) or a circumflex (in an ASCII environment) in the middle. The CTRAN function then replaces the semicolon or circumflex with a carriage return character and stores this string in a field named ANLBC. On the report output, this field displays on two lines:
DEFINE FILE EMPLOYEE ANLB/A40 ='THIS IS AN An FIELD;WITH A LINE BREAK.'; ANLBC/A40 = CTRAN(40, ANLB, 094, 013 , ANLBC); END TABLE FILE EMPLOYEE PRINT LAST_NAME ANLBC WHERE LAST_NAME EQ 'BLACKWOOD' ON TABLE HOLD FORMAT PDF ON TABLE SET STYLE * TYPE=REPORT,LINEBREAK='CR',$ ENDSTYLE END
The output is:
The following request defines an alphanumeric named ANLB field with a semicolon in the middle. The CTRAN function then replaces the semicolon (hex 094 in an EBCDIC environment, hex 059 in an ASCII environment) with a carriage return character and stores this string in a field named ANLBC. In the subfoot, this field displays on two lines.
The following report request is for an EBCDIC environment:
DEFINE FILE EMPLOYEE ANLB/A40 ='THIS IS AN An FIELD;WITH A LINE BREAK.'; ANLBC/A40 = CTRAN(40, ANLB, 094, 013 , ANLBC); END TABLE FILE EMPLOYEE PRINT FIRST_NAME BY LAST_NAME WHERE LAST_NAME EQ 'BLACKWOOD' ON LAST_NAME SUBFOOT " " " <ANLBC " ON TABLE HOLD FORMAT PDF ON TABLE SET STYLE * TYPE=REPORT,LINEBREAK='CR',$ ENDSTYLE END
The following report request is for an ASCII environment:
DEFINE FILE EMPLOYEE ANLB/A40 ='THIS IS AN An FIELD;WITH A LINE BREAK.'; ANLBC/A40 = CTRAN(40, ANLB, 059, 013 , ANLBC); END TABLE FILE EMPLOYEE PRINT FIRST_NAME BY LAST_NAME WHERE LAST_NAME EQ 'BLACKWOOD' ON LAST_NAME SUBFOOT " " " <ANLBC " ON TABLE HOLD FORMAT PDF ON TABLE SET STYLE * TYPE=REPORT,LINEBREAK='CR',$ ENDSTYLE END
The output is: