REPORTS

NAME

report – report definition file

DESCRIPTION

Files whose names end with `.rep’ are taken as report definition files, which are used by the report generator program ubreport. Report definitions are text files and can be created and maintained by any text editor such as vi, or edit.

A report definition file consists of a standard filename declaration and report command options.

The filename declaration is a line that starts with a `:’, a space and is followed by a table name. The report command options are lines starting with a capital letter followed by a picture or special instruction to the report generator.

Lines in report pictures can be any combination of text and fields.

A picture line can also be divided into three parts left, centre, and right by using `#’ as a separator. e.g. left#centre#right. Any section can be empty and only as many `#’ as are necessary need be given. Lines are left justified by default. To centre a string use `#string’; to right align a string use `##string’ etc.

Records from an associated table can be included in a report by starting a line with `<table’. In this case all the format options for table will be used. i.e. N table, R table, S table, T table, U table, D table, C table. Note that C table will be applied to all access to table, not just format sections.

REPORT COMMAND OPTIONS

{<table>} Means apply option to table instead of the master table.

{=} Means an optional condition may be given. See CONDITIONAL FORMATS below.

OPTION TITLE DESCRIPTION
A Attributes SYNTAX

A
{<field>} <attribute> {<condition>}
...
>

DESCRIPTION
Field attributes. This is used to set the display attributes of a field when it is printed.<attribute> is a single letter or symbol from the printer definition files (see printer (4)).

<condition> is an expression. If it is true (or missing) the <attribute> is applied to <field>.

If <field> is [record], <attribute> is applied to the entire record. If <field> is missing, <attribute> is applied to the entire picture. There may be several <attribute>/<condition> pairs for any <field>. The first true condition is used to select the attribute.

B Page Break SYNTAX

B{P}	<field>

DESCRIPTION
Break to a new page whenever field changes.”P” restarts page numbering from 1 after each break.

C Conditions SYNTAX

C	{<table>}
<expression>
...
>

DESCRIPTION
Print record or include calculations only if all expressions are true. If table is given the expressions are applied to table instead of to the main report table.

D Deletions SYNTAX

D	{<table>}

DESCRIPTION
Delete records as they are processed.Applies only to printed output not to records used in calculations.

If table is given and there is an “R <table>” section, the records will be deleted from the table as they are printed.

F Page Footer SYNTAX

F{L|T}	{=}
<picture>
>

DESCRIPTION
Page footer. FL is last page. FT is grand total (see TB) heading. If both FL and FT are given, FL will be used at the end of the last page before the grand total and FT on the grand total page.

H Page Header SYNTAX

H{1|T}{0} {=}
<picture>
>

DESCRIPTION
Page heading. H1 is page 1. HT is grand total (see TB) heading. Optional “0” means only print page heading if there are records to print.

I Variable Input SYNTAX

I	{<title>}
<field def>
...
>
<input screen>
>

DESCRIPTION
Input variables and screen.<field def> is a list of field definitions using the same format as the dictionary format (see dictionary (4)).

<input screen> is an input screen in the same format as a master file screen.

If <title> is given it is used as the window title and is centred on the top border of the window. The fields defined by field def are accessible in the table `?’.

EXAMPLE

I
date,	6	D
>
REPORT DATE [date]
>

C
[date entered] <=[?.date]
>
K Report Key/Index SYNTAX

K	<key>

DESCRIPTION
Key to use for report. Environment variables will be substituted. Key does not have to exist as a stored key. If it is not a stored key, ubreport will extract the records from the table and sort them by key. If the -m flag is used, only those keys matching the pattern will be sorted. Key may contain expressions.

L Lines Printed on Page SYNTAX

L	<n>

DESCRIPTION
Use only n lines on a page.

M Move Records SYNTAX

M	<table>

DESCRIPTION
Move all matching field names to a new record in <table>.

N New Section SYNTAX

N	{<table>}	<field>	{=}
<picture>
>

DESCRIPTION
Print a new section header whenever <field> changes.

O Match Index SYNTAX

O{L}	<list>

DESCRIPTION
Only print records whose primary key matches list. Environment variables will be substituted. list may be a mixture of fields, text and dates.If the optional “L” is given the list will end at the value. N.B. OL is only meaningful if O by itself is also specified.

EXAMPLE

O	"Y" [order no]
P Page Length SYNTAX

P	<n>

DESCRIPTION
Set page length to n linesIf n is 0, pagination is disabled.

R Report Format SYNTAX

R	{<table>}	{=}
<picture>
>

DESCRIPTION
Report format for each record. If table is given then the format is used for printing records from table.

If the picture has `<‘ in it, the rest of the line is taken as a table name and an optional index (if there is more than one possible association). The associated records in the specified table are printed at that position using the appropriate formats. C,D,N,R,S,T and V can all be used with the included formats.

Include files can also be specified as {<…<}. The table name and optional index replace … The advantage of this syntax is that it can be included inline with other parts of the picture.

N.B. ‘<‘ sections can be recursive if the table structure supports recursion. e.g. Bill of Materials reporting.

If the report has a `!’ in it the remainder of the line is the name of an execute (X) section. The output of the execute section is indented to the current the current position of the ‘!’.

Execute sections can also be specified as {!…!}. Again this has the advantage of being inline with other things in the report.

If a line in the format starts with “=”, the format up to the next “>” will only be printed if the condition following the “=” is true. IMPORTANT: To start a line with “=” (e.g. to put “=” across a page) put “\” in front of it. e.g.
\=>

Parts of a line can be conditionally included by using the following syntax:

{=<condition>{?<true format>{:<optional else format>=}

In line conditions can be nested.

EXAMPLE

R
...
= [margin] < 30%
*** WARNING: NOT ENOUGH MARGIN ***
>
SOME TEXT {=[value] > 0{?MORE THAN 0{:LESS THAN OR EQUAL TO 0=} AND SOME MORE TEXT
...
<table1 category,description
...
SOMETHING <table2
>

R table1
...
>

R table2
...
>
S Sub-Totals SYNTAX

S{<offset>}{F}	{<table>} <field> {=}
{<picture>}
>

DESCRIPTION
Print a subtotal using this format whenever field changes. F means print the subtotal as a page footer.When subtotals are part of an include table they are printed at the same indent level as the rest of the include table unless <offset> is specified. In this case the subtotal is printed offset from the left margin by the specified number of characters.

EXAMPLE

S	[supplier]
->
TOTALS FOR THIS SUPPLIER: [cost] [no of recs]
->
T Report Total SYNTAX

T{B}	{<table>} {=}
{<picture>}
>

DESCRIPTION
Grand total for file.TB prints on a new page. It may be used in conjunction with “HT”.

EXAMPLE

TB
\=>
REPORT TOTAL: [cost] [no of recs]
\=>
>
U Updates SYNTAX

U	{<table>} {=}
<field> <=+-*/> <expression>
...
>

DESCRIPTION
Update field with new value.The meaning of the operators is:

= Set field to expression
+ add expression to field
subtract expression from field
* multiply field by expression
/ divide field by expression

EXAMPLE

U
[price]		*1.1
[on hand]	-[qty]
[value]		-[qty]*[price]
[last sales]	=[system.date]
>
W Page Width SYNTAX

W	<n>

DESCRIPTION
Set page width to n characters. Most commonly used in conjunction with the `X’ option when the maximum line width cannot be determined before executing the command.

EXAMPLE

W	120
X Commands to Execute SYNTAX

X	<name>
<commands>
>

DESCRIPTION
Shell script to execute.
The script <name> is executed whenever “!<name>” is encountered while printing a report. This must be the last thing on the line. The output of the command is incorporated in the report at that point.
The script can also be incorporated into the report as in inline script by using this syntax “{!<name>!}”. Using this form the output of “name” will be included in the line and other text, fields etc can follow on the same line.
IMPORTANT: The command must be defined before it can be used.
USING ATTRIBUTES IN THE COMMAND
Attributes can be used inside the script in the normal way. The script is parsed for attributes and they are substituted.If the script is called from an include table and you want to use and attribute from that table it must be referred to as “[<table>,<attribute>]”.

EXAMPLE

X	files
1s - 1
> 

R
...
!files
...
>

CONDITIONAL FORMATS

Conditional Formats can be used to print records, subtotals, etc in different formats. An expression is evaluated and if it is true (non-zero) the format is used.

Example:

R
[partno] [description] [qty on hand] [reorder]
>

R = [qty on hand] < [reorder]
[part no] [description] [qty on hand] [reorder] BUY MORE
>

R = [qty on hand] = 0
[part no] [description] OUT OF STOCK
>

The syntax is = <expression> and may be used with any command option that has {=} in its syntax.

The format conditions are evaluated from the last to the first. The first true expression becomes the format to use for this record. This means the default format (i.e. no condition) comes first in the report program file.

Conditional formats can also occur inside a format. This happens when a format line starts with “=”. Up to the next terminating “>” the format will only be printed if the expression following the “=” is true.

These conditional formats can be nested.

The third method for conditional formats is embedded in the report line. The structure

{=<condition>{?<true format>{:<optional false format>=}

can occur anywhere within a format line. It cannot extend across multiple input lines.

You can nest an embedded condition inside the true and false formats for more complex requirements.

If the false format is not needed then the ‘{:’ operator is also left out.

Example:

R
[partno] [description] {=[qty on hand] > 0{?[qty on hand]{:{=[qty on hand] = 0{?OUT OF STOCK{:OVERSOLD=}=}\
 {=[qty on hand] <= 0 {?[reorder]=}
>

Leave a Reply