4.1 Report Format
4.1.1 General Layout
In general, reports are designed by giving pictures for each aspect of the report. For example, a picture for each record to be printed, a picture for each subtotal, a picture for the page headings. Instructions to the report generator consists of a capital letter followed by a number, a picture, or some other information relevant to the instruction. There is also one special instruction which gives the file for the report generator to use. This is a standard filename declarations, eg. “:account”. Commands for the report generator are stored as text in files whose name ends in “.rep”.
: account
H
UNITE#List of Account Titles#[system date]
ACCT TITLE
->
>
R
[account][title]
>
F
->
#-[system,page]-
>
4.1.2 File Merging
Sometime you may wish to use more than one file in a report. This may be included in the main report format by putting a line “<file>” in the record picture, provided the “<file>” being included is known to the standard file.
Example of a Report Using Include File
: account
H
UNITE#List of Account Titles#[system date]
ACCT TITLE
->
>
R
[account][title]
<subaccount
>
R subaccount
[subaccount][title]
>
F
->
#-[system,page]-
>
4.2 Program Options
4.2.1 Debug Option
ubreport –d report-name
This gives a debug output. As ubreport reads the Data Dictionary and screen format each line is echoed to the screen. In this way the exact point at which the error occurs can be observed and correct.
To debug a stock report called “stock.rep”
ubreport –d stock
4.2.2 Non-Interactive
ubreport –i report-name
Indicates that ubreport is not interactive, ie it is in batch mode probably as part of a shell script or command file. In this mode the input screen (for the “I” section) is ignored (although it must be present) and report variables are read, one per line, from the standard input.
To get and set the next batch number in a shell script file that makes batches:
batch=’ubsetseq –m 00000 batch’
ubreport –i setbatch <<! 2>/dev/null
$batch
!
4.2.3 Screen Output
ubreport –s report-name
For screen output this option sets the page length (overriding the report page length to the number of lines on the screen) and then ubreport pauses at the end of each page until the user enters a RETURN or ENTER key to continue or “q” to quit.
To use screen output:
ubreport –s account
4.2.4 Match Values
ubreport –m value report-name
This restricts the report to those key values that are the same (match) as value. If a report is required of only a section of a large file this option can considerably reduce the report time. This option and the previous option may be used together.
To only report on those key values that have a transaction code on “INVS”
ubreport –m INVS trans
To only report on those transactions that have a transaction code of “INVS” and reference code of “99” (provided that these are part of the key):
ubreport –m “INVS99” trans
4.2.5 Standard Input File
ubreport –S report-name
ubreport reads records from standard input rather than the main file in the report format (report file). Records are assumed to be in the same format as the report file. NB The report file does not have to actually exist. Effectively this means ubreport can be used as a Unix filter. Input records will have any calculations and associations carried out as if a real UNIBASE file were being used.
To report on new stock, sort the data and report the sorted data:
ubreport newstock | sort | ubreport –S newlist
4.2.6 Field Separator
ubreport –f c report-name
Used in conjunction with the ‘S’ option this tells ubreport to use ‘c’ as the field separator for input records. Instead of fixed length input records, this allows for variable length records with each field separated by a field separator, which in the above example is the character ‘c’.
To use ubreport to read records where fields are separated by commas (,):
ubreport –f, newstock
4.2.7 Date Format
ubreport –D report-name
Thie option allows for the alternative date formate YYMMDD. Normally, all dated are expected to be in the formate DD.MM.YY or (DD/MM/YY). Using this option reads dates in the alternative format.
This is used in conjunction with the –S option.
To read and report on a text file with dates in the format YYMMDD:
ubreport –D orders
4.2.8 dBase Dump Format
ubreport –b report-name
This option allows ubreport to read “dbase Dump Formats” where each fixed length field is followed by a space.
This is an example of what a staff file would look like in dBase Dump Format:
00123 Mr John Smith SYDNEY (02)96978111 100000
03456 Mrs Eve Brown MELBOURNE (03)93411111 15000
98762 Emma Finch CASTLE HILL (02) 99470711 200000
Note the space after each fixed length field.
To read this data and report on it with ubreport (the file it uses would have to be define in the Data Dictionary, but does not need to be created):
ubreport –b staff
This could then be batched into a file called staff:
ubreport –b staff | ubbatch staff
4.3 Report Options
Except for the filename declaration, the report generator “ubreport” uses commands. Commands are lines starting with a capital letter. Theses commands are demonstrated in the following sections.
4.3.1 Page Breaks
B{P}field
Break to a new page whenever field changes. Filed must be part of the key being used. If P is also specified then the page numbering is restarted whenever a page break is forced.
To start a new page every time the field ‘category’ changes:
BP [category]
4.3.2 Conditions
C{file}
expression
>
A record is only printed if all expressions are true. If file is given then the expressions are applied to records of file when deciding whether to include a record in a join. There can be more than one set of conditions for a file. In that case a record is chosen it all the conditions in any group are satisfied.
To select only records in a given area with accounts >$1,000:
C
[area]=”SYD”
[account] > 1000
>
To select records in a given area with accounts > $1,000 or in a different area with accounts < $5,000:
C
[area]=”SYD”
[account] > 1000
>
C
[area]=”ACT”
[account] < 5000
>
4.3.3 Delete Records
D{file}
Delete the record from the file. Only records that would be printed are deleted.
To delete every record in a report:
D
4.3.4 Page Footer
F
picture
>
Format for page footer
To display the page number at the bottom of the page:
F
->
#-[system,page]-
>
4.3.5 Page Headings
H{1}
picture
>
Format for “Page Headers”. If H1 is given then the heading is used for page 1 only. Both H and H1 may be given in a report. H1 is printed any time the page number is 1. Therefore if you specify BP and H1 heading will be used every time a page break is forced.
To print a report title, date and column headings at the top of each page:
H
TRANSACTION REPORT –
[system,date]
Batch Tran Ref Date Description Credit Debit
->
>
To print the same header as above on the first page only and the number is each following page:
H
TRANSACTION REPORT –
[system,date]
Batch Tran Ref Date Description Credit Debit
->
>
H
#-[system,page]-
>
4.3.6 Operator Input
I
field def
. . .
>
input screen
>
Input requests for ‘?’ file. Fields defined in this section become the fields of the file ‘?’. All fields are automatically joined to the file ‘?’ and fields from this file may be used in the rest of the report by using the normal join notation:
[?field].
It is not necessary to put this section before the use of its fields as UNIBASE will resolve all references before executing.
input screen is a picture used to input the files defined above for ‘?’ file.
To input a field ‘area’ for a report (known as [?,area] in the report):
I
area, 3 PX
>
Area for Report: [area]
>
To input a field ‘area’ and be able to confirm it by displaying a description that is accessed from the file called ‘area’:
I
area, 3 PX
>
Area for Report: [area][area,description]
>
C
[area] = [?,area]
>
4.3.7 Key Definitions
K key def
Key to use for report. key def is a list of fields as used to define a key in the Data Dictionary. If a key definition is an environment variable, the value o the environment variable will be substituted. This can be useful when the same report format will be used with a different sort order.
To report by area (assuming there is a key that starts with area):
K area
To specify more of the key if more than one key starts with area:
K area,division,office
Or if the environment variable REPKEY = area, division, office then:
K $REPKEY
Will have the same effect.
4.3.8 Lines Printed Per Page
L(n)
Only use (n) lines per page. This does not set the page length only the number of lines that will be printed on a page.
To set the lines per page to 40:
L 40
4.3.9 Move Date to Another File
M file
Move as much information as possible from the current record to a new record in file.
This report will move records from an invoice file for archiving purposes when the invoice records are older than 3 months (this report will also delete the records after they have been moved). The archive file does not have to have exactly the same fields in exactly the same order as the invoice file.
*INVARCH – Archives invoice records older than 90 days
: invoice
R
[invoice no] [inv date][customer][deliv chrg][sales tax]\[inv amount]
>
M archive
D
C
[system,date] – [inv date]
>
4.3.10 New Section Heading
N{file}field
picture
>
Formate for heading whenever field changes. field must be part of the current key. This does not effect the page headings.
To get a new page heading every time a company name changes:
N [coy name]
[coy name]
>
To get a new heading from another file every time a stock category changes:
N stock[category]
Category Description
–
>
To get a new heading when part of a field changes (in this case the first character in the product number has been classified as the category code):
N[prod number:1-1]
[category][category,description]
>
4.3.11 Only Report Patterns
O list
Only match records. This option is the same as the ‘-m’ program option, except that the pattern can be built from a list of items following the O in the report file. list can be fields (usually from the ‘?’ and ‘system’ files) or text (letters, etc surrounded by “”). Any amount of spaces or tabs can be used to separate items in the list.
To print only records with the key N followed by today’s date, followed by a name input through an ‘I’ section:
O “N” [system,date][?,name]
To only print those invoices that haven’t been posted:
O “N”
4.3.12 Page Length
P(n)
Sets the page length to (n) linex.
To set the page length to 10 lines:
P 10
4.3.13 Reports Format
R{field}
picture
>
Report format per record. If file is given then it is the format for records from file. These records may be included in the main report format by putting in a line ‘file’ in the picture. All appropriate records from file will be printed.
A standard report format:
R
[name][company][tel no]
>
To include details from another file:
R
[name][company][tel no]
<notes
>
R notes
[notes]
>
4.3.14 Subtotals
S{F}{file} field
picture
>
Print a subtotal whenever field changes. field must be part of the current key. If ‘SF’ instead of ‘S’ is used then print the subtotal as a page footer.
To print a subtotal whenever a division number changes:
S [division]
–
[credit] [debit]
==== ====
>
To print a subtotal at the bottom of the page whenever a division number changes:
SF [division]
–
[credit] [debit]
==== ====
>
4.3.15 Totals
T{B}{file}
picture
>
Print grand total. If ‘B’ is specified then the grand total will be on anew page.
To print a total at the end of a report:
T
->
[credit] [debit]
==== ====
>
To print a total on a new page:
TB
->
[credit] [debit]
==== ====
>
4.3.16 Update
U{file}
Field<=+-*/>expression
>
Update value if field. If the field type is numeric then all the operators may be used. If it is not then only ‘=’ may be used. Field may be from another file.
To add quantity times amount to a sales field:
U
[sales] + [qty] * [amount]
>
To clear a filed to 0:
U
[sales this month] = 0
>
To set a flag to Y:
U
[sold]=”y”
>