AA U051A TK_DATATRIEVE 11_Guide_To_Writing_Reports_Sep83 TK DATATRIEVE 11 Guide To Writing Reports Sep83

AA-U051A-TK_DATATRIEVE-11_Guide_To_Writing_Reports_Sep83 AA-U051A-TK_DATATRIEVE-11_Guide_To_Writing_Reports_Sep83

User Manual: AA-U051A-TK_DATATRIEVE-11_Guide_To_Writing_Reports_Sep83

Open the PDF directly: View PDF PDF.
Page Count: 80

DownloadAA-U051A-TK_DATATRIEVE-11_Guide_To_Writing_Reports_Sep83 AA-U051A-TK DATATRIEVE-11 Guide To Writing Reports Sep83
Open PDF In BrowserView PDF
)
DATATRIEVE-11
Guide to Writing Reports
Order No. AA-U051 A-TK

)

September 1983
This document describes the DATATRIEVE-ll Report Writer.

)

OPERATING SYSTEMS:

RSX-llM
RSX-llM-PLUS
RSTS/E

SOFTWARE VERSION:

DATATRIEVE-ll

V3.

digital equipment corporation, maynard, massachusetts

The information in this document is subject to change without notice and
should not be construed as a commitment by Digital Equipment Corporation.
Digital Equipment Corporation assumes no responsibility for any errors that
may appear in this document.
The software described in this document is furnished under a license and may
be used or copied only in accordance with the terms of such license.
No responsibility is assumed for the use or reliability of software on equipment that is not supplied by DIGITAL or its affiliated companies.

Copyright © 1983 by Digital Equipment Corporation. All Rights Reserved.

The postage-paid READER'S COMMENTS form on the last page of this document requests your critical evaluation to assist us in preparing future
documentation.

The following are trademarks of Digital Equipment Corporation:

~D~DDmD

™

DECmate
DECsystem-10
DECSYSTEM-20
DECUS
DECwriter

DIBOL
MASSBUS
PDP

P/OS
Professional
Rainbow
RSTS

RSX
UNIBUS
VAX
VAX
VMS
VT
Work Processor

DATATRIEVE-11 DOCUMENTATION MAP

)
Getting
Started

Learning
the Basics

Intermediate
Applications

Advanced
Applications

r - - - - - - Pocket
Guide

)

Summary
1 - - - - - Introduction 1-.......,.----Description

Installation
Guide/
Release Notes

Guide to
Writing
Reports

Call Interface
Manual

)

)

iii

DATATRIEVE-11 DOCUMENTATION DESCRIPTION
GETTING STARTED
Summary Description

Installation Guide / Release Notes

Provides an overview of DATATRIEVE.
Contains a documentation directory, a
glossary, and the master index.

1 - - -__- - - 1

Describes the installation procedure and
the installation verification procedure.
Release Notes contain the latest information about new features, restrictions, and
performance guidelines.

LEARNING THE BASICS
I
Introduction to
DATATRIEVE-11
Interactively guides users through the
basic tasks of managing information with
DATATRIEVE.

INTERMEDIATE APPLICATIONS

------..J

User's Guide

Guide to Writing Reports

Explains how to define, store, retrieve,
Explains how to produce reports based on
modify, and restructure data using ~ data managed by DATATRIEVE. DeDATATRIEVE. Elaborates on material
scribes the instructions that specify the
covered in the Introduction.
format and content of a report.

I
Pocket Guide

ADVANCED APPLICATIONS

Provides full descriptions of the comProvides a quick reference guide for exper-mands. statements. clauses. and other
rienced users to the syntax and elements
syntax elements that comprise the
of DATATRIEVE.
DATATRIEVE data management language.

iv

I

I
Reference Manual

Call Interface Manual

-

Explains how to call DATATRIEVE from
programs in languages such as
FORTRAN, COBOL. and BASIC.
Describes how to use DATATRIEVE
interactively on another node.

)

Contents
Page

How to Use This Manual

1

Getting Started
1".1
1.2

What the Report Writer Can Do.
Writing Reports. .. . . .
1.2.1
1.2.2
1.2.3

1.3

)

1.4

The PRINT Statement.
The SUM Statement.
The Report Writer.

Saving Report Statements.
1.3.1
1.3.2

2

vii

Using Procedures ..
U sing Command Files.

Printing Summary Statistics

· 1-2
· 1-3
· 1-3
· 1-3
· 1-4
· 1-6
· 1-6
· 1-7
· 1-8

Designing a Report
2.1
2.2

2.3

Identifying the Data and Invoking the Report Writer
Correcting Mistakes in the Report Writer . . . .

· 2-2
· 2-3

2.2.1
2.2.2
2.2.3

· 2-3
· 2-4
· 2-4

Formatting the Report Page. . . . . . .
2.3.1
2.3.2
2.3.3
2.3.4

2.4

Default Page Width and Length.
Option 1: Setting the Page Width
Option 2: Setting the Page Length.
Option 3: Limiting the Total Lines or Pages in a Report.

Setting Up the Report Heading . . .
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5

2.5

Returning to the DTR> Prompt. . . . . . .
Using a Text Editor to Correct Mistakes . . .
Using the DATATRIEVE Editor to Correct Mistakes

Default Format . . . . . . .
Option 1 : Naming the Report
Option 2: Assigning a Date .
Option 3: Suppressing a Date
Option 4: Suppressing the Page Number.

· 2-4
·
·
·
·

2-5
2-5
2-5
2-6

· 2-7
· 2-7
· 2-7
· 2-9

2-10
2-10

Printing Detail Lines and Column Headers

2-10

2.5.1

Content of the Detail Line. .

2-11

Field Values . . . .
Value Expressions.

2-11
2-12

2.5.1.1
2.5.1.2
2.5.2

Format of Fields in the Detail Lines.
2.5.2.1
2.5.2.2
2.5.2.3

Order of Print Items. . . .
Column Position of Print Items
Edit String Format of Print Items .

2-12
2-13
2-13
2-14

v

2.5.3

Column Headers for Print Items . . . . . . . . . .

2-15

Option 1: Suppressing a Column Header.
Option 2: Specifying a Column Header.

2-15
2-16

2.5.3.1
2.5.3.2
2.6

2.7

3

3.2

3.3
3.4

2.6.1
2.6.2

2-17
2-18

COUNT, AVERAGE, and TOTAL . . .
Maximum Value and Minimum Value.

Selecting the Output Device or File . . . .

2-19

2.7.1
2.7.2
2.7.3
2.7.4

2-20
2-20
2-20
2-20

Default: Output to Terminal. . . .
Option 1: Output to a Line Printer
Option 2: Output to a File.
Option 3: Prompt . . . . . . .

Dividing Data Records into Groups ..

· 3-2

3.1.1
3.1.2
3.1.3
3.1.4
3.1.5

·
·
·
·
·

Defining Key Fields to Optimize Speed of Processing
Developing Control Groups with a Sort Key. . . . .
Developing Levels of Control Groups Using Multiple Sort Keys
Using Control Breaks on Unsorted Records
Reporting Group Summaries Only . . . . .

3-2
3-2
3-4
3-8
3-8

Printing a Title Page and Other Special Headings.

3-10

3.2.1
3.2.2

Printing a Title Page . . . . . .
Printing Special Page Headings .

3-10
3-12

Performing Cross Tabulations.
Reporting Hierarchical Records . . . . .

3-13
3-15

Data Files Supplied With DATATRIEVE-11
A.l
A.2
A.3

Index

vi

2-17

Mastering Report Writing Techniques
3.1

A

Summarizing Data . . . . . . . . . . . . . .

YACHTS Domain Data . . .
FAMILIES Domain Data . .
PERSONNEL Domain Data.

· A-I
· A-3
.A-4

)

How to Use This Manual
)

Manual Objectives
This manual describes how to write reports with DATATRIEVE-ll. It illustrates the use of the DATATRIEVE-ll Report Writer.

Audience

)

)

You should use this manual if you want to produce reports using data managed
by DATATRIEVE-ll. The manual assumes that you have read or are familiar
wi th the material covered in the Introduction to DATATRIEVE-ll. For the
more advanced topics in this manual (especially in Chapter 3), you should be
familiar with the material in theDATATRIEVE-ll User's Guide about record
definitions, record selection expressions, variables, procedures, and command
files. In addition, you may need to refer to the section on the EDIT _STRING
clause in Chapter 5 oftheDATATRIEVE-ll Reference Manual.

Manual Structure
This manual has three chapters:
Chapter 1

Introduces the Report Writer and provides examples of simple
reports.

Chapter 2

Describes how to develop a report specification, the instructions
that control the content and format of a report. The chapter presents the Report Writer's default and optional settings.

Chapter 3

Discusses advanced techniques of report writing with
DATATRIEVE-ll. It covers such topics as reporting groups of
sorted records and reporting data from several domains.

Appendix A Contains the data files used in the examples in this book.

Vll

Conventions
The following list explains the special symbols used in this book:
lliill

The symbollliill tells you to press the RETURN key on the keyboard of
your terminal.

@ID

The symbol @ID tells you to press the TAB key on the keyboard of your
terminal.

(CTRUX)

The symbol (CTRUX) tells you to press the CTRL (control) key and a letter
key (usually Z or C) at the same time.

color

Text printed in red shows the lines you type while doing the examples.

Related Documents
You can find additional information in the following documents:

• DATATRIEVE-ll User's Guide
• DATATRIEVE-ll Call Interface Manual
• DATATRIEVE-ll Reference Manual

viii

)

)

)

Getting Started

1

DATATRIEVE-ll allows you to organize and maintain data conveniently. A
major reason for keeping this data is to make it available to the people who need
it. DATATRIEVE's Report Writer helps you present this information in attractive and comprehensive reports.
Managers, secretaries, and many other people often need information immediately on a specific subject. To produce simple query reports, they need reliable
techniques for presenting information. With a few simple statements and commands, you can quickly display and accurately summarize data managed by
DATATRIEVE.
In addition to query reports, most organizations require detailed summary
reports at regular intervals to compare current performance with past performance. These periodic reports are on subjects such as accounts receivable, inventory, and sales. The statistical functions within the Report Writer allow anyone
to summarize the information needed for periodic reports.
Those who want the same report formats repeatedly can define DATATRIEVE
procedures or use command files to save their report specifications. This manual
teaches you by example how to generate many types of reports ranging from simple queries to complex summary reports.
The examples in this book use the sample domains YACHTS, PERSONNEL, and
FAMILIES installed with your system. If the data in your files has changed since
installation, your results may differ from those in the book. To check your data
files with the ones these examples use, see Appendix A.
If your data file is different from that in Appendix A, you can either modify your
data or see your system manager to obtain the original file.

1-1

1.1

What the Report Writer Can Do
The Report Writer can:
1. Center a report name at the top of the page

2. Print the current date at the upper right
3. Print page numbers at the upper right
4. Set up column headings
5. Print a data line with information about individual records (a detail line) for
each record
6. Calculate and print a line of summary totals for:
a. A group of data (such as yachts by the same builder)
b. The entire report (such as yachts by several builders)
Each number corresponds to a feature listed in the following report produced
by the Report Wri ter:

~----------------------------~CD'
30-Ap r-83,.-----1@

YACHTS BY ALBERGt
ALBINt AND AMERICAN

MANUFACTURER
ALBERG

MDDEL

RIG

37 MK II

KETCH

LENGTH
Ot.IER
ALL
37

Page

GD

WEIGHT

BEAM

PRICE---(D

ZOtOOO

1Z

$36t951---QD

At.IERAGE PR I CE:

BOAT COUNT:

1

$36t951

****************************************
ALBIN
ALBIN
ALBIN

79
t.IEGA
BALLAD
BOAT COUNT:

SLOOP
SLOOP
SLOOP

Z6
Z7
30

atZOO
5t070
7tZ76

10
08
10

At.JERAGE PRICE:

3

$17t900
$18t600
$Z7t500
$Zl t 333 -----@

****************************************
AMERICAN
AMERICAN

SLOOP
MS

Z6
Z6-MS

BOAT COUNT:

Z

Z6
Z6

atOOO
5t500

08
08

At.JERAGE PR I CE:

$9t895
$18t895

$lat395

****************************************
TOTAL BOAT COUNT:

1-2

Getting Started

6

OVERALL AVERAGE PRICE:

$Zlt140--@

1.2

)

Writing Reports
With DATATRIEVE, you can produce reports both inside and outside of the
Report Writer:
• With the PRINT statement to display data from one group of records
• With the SUM statement to generate summary totals from groups of records
• With the Report Writer, providing the most flexibility for designing the format
and content of reports and providing the option of printing the report directly
on a line printer
The following sections illustrate these three methods of report writing in
DATATRIEVE . You can use the examples as models for creating similar reports
with your own data.

)

1.2.1

The PRINT Statement

When you display records with the PRINT statement outside of the Report
Writer, you create a simple report. To display the YACHTS built by ALBIN,
type the following, being sure to use all uppercase letters for ((ALBIN":

)

DTR> READY YACHTSru
DTR> PRINT YACHTS WITH BUILDER

=

MANUFACTURER

LENGTH
OI)ER
ALL
WEIGHT BEAM

ALBIN
ALBIN
ALBIN

MODEL
78

BALLAD
1.IEGA

RIG
SLOOP
SLOOP
SLOOP

"ALBIN"ru

26
30
27

at200
7t276

5.070

10
10
08

PRICE
$17t800
$27t500
$18.600

DTR>

1.2.2

The SUM Statement

You may want to summarize information about selected groups within your
report. The simplest way is with DATATRIEVE's SUM statement outside of the
Report Writer. For example, assume that you have a collection of seven records
from the YACHTS domain. Use the SUM statement to indicate the number of
yachts and the total price for each builder.
The SUM statement in the following example means ((Summarize the first seven
yachts, telling the total number and total price of yachts for each builder and the
total number and total price of all yachts in the collection."
The command SET NO PROMPT, which is included in many of the following
examples, stops DATATRIEVE's prompting for elements needed to complete

Getting Started

1-3

your current command or statement. If you omit SET NO PROMPT, prompts
such as ttLooking for next element in list" appear on your terminal. SET NO
PROMPT does not affect your report in any way.
DTR> SET NO PROMPT(@)
DTR> READY YACHTS; FIND FIRST 7 YACHTS(@)
[7 records found]

DTR> SUM 1 (II NUMBER 'II) US I NG 8 I(@)
CON> PRICE USING $$$$,$$$ BY BUILDER(@)
MANUFACTURER NUMBER
ALBERG
ALBIN
AMERICAN
BAYFIELD

1
3
2

PRICE

NUMBER

PRICE

$36,851

$64,000
$28,780
$32,875

7

$162,616

DTR>

The report separ"ates the seven records into four groups of builders. It summarizes data not only for each builder, but for all builders.
The SUM statement is the simplest way to create summary reports. See Chapter
3 for information on advanced summary reports.

1.2.3

The Report Writer

The PRINT and SUM statements give you some control over the display of your
data, but the Report Writer helps you format the page more than the PRINT
statement does. You can produce the simplest reports with only a few statements:
• A REPORT statement to invoke the Report Writer and to identify the data that
you wish to report.
• One or more SET statements to name the report and control the format. (SET
statements are optional. If you prefer, the Report Writer can do all the formatting for you.)
• A PRINT statement to indicate which fields from the records you want to
display.
- Note that the Report Writer PRINT statement is different from the regular
PRINT statement in DATATRIEVE. In the Report Writer, you list the fields
or value expressions that you want to display. You cannot say ttpRINT
CURRENT" or npRINT YACRTS", because ttCURRENT" and tty ACRTS"
are not field names or value expressions.
• An END_REPORT statement to tell DATATRIEVE to create and display the
report.

1-4

Getting Started

To find out the names of fields you can specify in the PRINT statement, use a
SHOW FIELDS command to display the field structure of the record:

)

DTR> SHOW FIELDS(@)
YACHTS
BOAT
TYPE [Indexed field]
MANUFACTURER (BUILDER)
[Character string, indexed Key]
MODEL
[Character string, indexed Key]
SPECIFICATIONS (SPECS)
RIG [Character string]
LENGTH_OVER_ALL (LOA)
[Character string]
DISPLACEMENT (DISP) [NuMber]
BEAM
[NuMber]
PRICE
[NuMber]
DTR>

BOAT is the top-level field for the records in the YACHTS domain. BOAT
includes all of the fields in YACHTS. If you want to report all the data on each·
yacht, specify BOAT in the PRINT statement.

)

Example: Report on all the yachts manufactured by Albin. ~ame the report
~~YACHTS BY ALBIN", and include a date and page number.
To produce the report, follow these steps:
1. Report each record in YACHTS for the builder ALBIN. The REPORT statement identifies the data and invokes the Report Writer. The RW> prompt
shows that DATATRIEVE is ready to accept your Report Writer statements.

2. Name the report.
3. Print the top-level field BOAT for each record. By doing so, you display all
the data on each yacht.
4. End with an END_REPORT statement.
The following DATATRIEVE session illustrates these steps. The number after
each statement corresponds to one in the list above:
DTR>
RW>
RW>
RW>

REPORT YACHTS WITH BUILDER = "ALBIN"(@)-------------G)
SET REPORT_NAME = "YACHTS BY ALBIN"(@)
PRINT BOAT(@)
®
END_REPORTOOl
0

®

20-Aug-83
Page 1

YACHTS BY ALBIN

MANUFACTURER
ALBIN
ALBIN
ALBIN

MODEL
78
BALLAD
1.IEGA

RIG
SLOOP
SLOOP
SLOOP

LENGTH
OI.IER
ALL
28
30
27

WEIGHT
a,200
7,278
5,070

BEAM

PRICE

10
10
08

$17,800
$27,500
$18,800

DTR>

Getting Started

1-5

Note the way the Report Writer sets up the page format. The page has the date
and page number in the upper right corner. In this example, the Report Writer
automatically sets the page width at 80 columns per page, spacing the fields of
each record for you.

1.3

Saving Report Statements
When you need to produce the same report periodically, you can save the Report
Writer specification by putting the statements in a DATATRIEVE procedure or a
command file.

1.3.1

Using Procedures

You define a procedure by:
1. Typing DEFINE PROCEDURE procedure-name at the DTR> prompt

2. Typing the report statements exactly as you would enter them outside a
procedure
3. Typing END_PROCEDURE
By using one or more prompting value expressions within your procedure, you
can let other people tailor the report. The prompting value expression consists of
an asterisk (*) and a period, followed by an expression enclosed in quotation
marks.
For example, you can include this statement:
REPORT YACHTS

WITH BUILDER

=

*.lIthe builder

ll

When you invoke the procedure, the terminal displays the following prompt:
Enter the builder:

DATATRIEVE does not process the report until you enter the name of the
builder.

Example: Define a procedure YACHT _PER_LB to produce a report with columns for these fields:
• MANUFACTURER
• MODEL
• DISP C~WEIGHT")
• PRICE
In addition, create a new column showing the price per pound of each yacht. The
Report Writer calculates the price per pound by dividing the number in the
PRICE field by the number in the DISP field.

1-6

Getting Started

Follow these steps:

)

1. Define a procedure YACHT _PER_LB.

2. Ready the domain YACHTS.
3. Identify the data you wish to report within the REPORT statement. Include
a prompt so the user can select the builder's name.
4. Specify the items in each detail line with a PRINT statement. These items
become the columns for the report. Create a column for price per pound by
including PRICE/DISP as one of the items. The ((/" indicates division. Use the
edit string clause $$.99 to print the price per pound as a monetary value.
(Chapter 2 discusses computed value expressions and edit strings in more
detail.)
5. End the report specification with an END_REPORT statement.
6. End the procedure with an END_PROCEDURE statement.

)

7. Invoke the procedure by typing: YACHT _PER_LB.
The following DATATRIEVE statements produce the report. The number after
each statement corresponds to one in the preceding list:
DTR:> DEF I NE PROCEDURE YACHT _PER_LB(@) ------------~CD
DFN> READY YACHTS(@)
®
DFN> REPORT YACHTS WITH BUILDER = *."the builder"(@)
DFN> SET REPORT_NAME = "YACHT PRICES BY WEIGHT"(@)
DFN> PRINT TYPE t DISP t PRICE t(@)
8)
DFN> PRICE/DISP ("PRICE/LB") USING $$.98(@)
DFN> END_RE PORT(@) - - - - - - - - - - - - - - - - - - - - - - 0
DFN> END_PROCEDURE(@)
@
DTR> :YACHT_PER_LB(@)
0
Ente r the bui Ide r: AMERICAN(@)

®

)

YACHT PRICES BY WEIGHT

MANUFACTURER
AMERICAN
AMERICAN

MODEL
28
28-MS

WEIGHT
atOOO
5t500

PRICE
$8t895
$18t885

17-Apr-83
Page 1

PRICE/LB
$2.a7
$3.a3

DTR>

1.3.2

Using Command Files

You can also place report specifications in command files outside DATATRIEVE
using a text editor.

Getting Started

1-7

For example, invoke a text editor, name the command file YACTWT.CMD, and
enter the statements to create your report, just as you would enter them within
DATATRIEVE:
READY YACHTS(BDJ
REPORT YACHTS WITH BUILDER = *."the builder"(BDJ
SET REPORT_NAME = "YACHT PRICES BY WEIGHT"(BDJ
PRINT TYPE, DISP, PRICE,(BDJ
PRICE/DISP ("PRICE/LB") USING $$.99(BDJ
END_REPORT(BDJ

Exit from the text editor. Invoke DATATRIEVE and execute the command file,
by typing the @ symbol and the command file name. The following statements
produce the report:
DTR> @YACTWT.CMD(BDJ
READY YACHTS
REPORT YACHTS WITH BUILDER = *."the builder"
SET REPORT_NAME = "YACHT PRICES BY WEIGHT"
PRINT TYPE, DISP, PRICE,
PRICE/DISP ("PRICE/LB") USING $$.99
END_REPORT
Ente r the bui 1 de r: AMERICAN(BDJ
YACHT PRICES BY WEIGHT

MANUFACTURER
AMERICAN
AMERICAN

MODEL
26
26-MS

WEIGHT
4,000
5,500

17-Apr-83
Page 1

PRICE

PRICE/LB

$9,895
$18,895

$2.47
$3.43

DTR>

For each report you can decide whether to create the report specification interactively, to put it into a procedure, or to put it into a command file. In any case, the
sequence of report statements and their syntax remain the same. For more information on procedures and command files, see theDATATRIEVE-ll User's
Guide.

1.4

Printing Summary Statistics
If you want summary information on the data records in the report, use the
Report Writer's statistical functions to compute values for a summary line. The
functions are:
• COUNT
• AVERAGE
• TOTAL
• MAX (maximum value)
o

1-8

MIN (minimum value)

Getting Started

)

Example: Report on yachts built by Albin. At the bottom of the report, indicate
the total number of yachts and the average price of a yacht. Limit the page width
to 70 columns. Follow these steps:
1. Identify the data you wish to report within the REPORT statement.

2. Name the report.
3. Set the page width.
4. Print the top-level field BOAT in each detail line.
5. Summarize the report with an AT BOTTOM OF REPORT statement. Use
COUNT for the total number of boats. To suppress the header cCCOUNT",
include a hyphen in parentheses after COUNT. Then apply AVERAGE to
the field PRICE for the average price.
6. End with an END_REPORT statement.

)

The following group of statements produces the desired summary report:
DTR>
DTR>
RW>
RW>
RW>
RW>
RW>
RW>
RW>

SET NO PROMPT([IT)
REPORT YACHTS WITH BUILDER = "ALBIN"([IT) -----------10
SET REPORT_NAME = "YACHTS BY ALBIN"m
®
SET COLUMNS_PAGE = 70([IT)
®
PRINT BOAT(Bm
0
AT BOTTOM' OF REPORT PRINT SKIP, COL 10 t(BDl
"BOAT COUNT:", SPACE, COUNT (-) USING Z9,@
COL as, "AI,IERAGE PR I CE: ", AI,IERAGE PR I CE (Bill ------~®
END_REPORT(Bill
®
YACHTS BY ALBIN

MANUFACTURER
ALBIN
ALBIN
ALBIN

MODEL
79
BALLAD
1,lEGA

BOAT COUNT:

3

RIG
SLOOP
SLOOP
SLOOP

10-Jan-83
Page 1

LENGTH
OI,IER
ALL
26
30
27

WEIGHT

BEAM

PRICE

a,200
7,276
5,070

10
10
08

$17,900
$27,500
$18,600

AI,IERAGE PRICE:

$21 ,333

DTR>

Note that the Report Writer has lined up the value for the average price in the
PRICE column.
These sample reports demonstrate only a few applications ofDATATRIEVE's
Report Writer. The next two chapters discuss and illustrate other features to control the format and content of reports.

Getting Started

1-9

)

Designing a Report

2

)
You may be content to allow the Report Writer to supply the date, page number,
page width, and other characteristics for your report. If you are, you need only
concern yourself with what you want to put into the report, not how to design the
report itself.

)

At times, though, you may want to supply your own formats. You are likely, for
instance, to want to supply a name for your report. Unless you specify a name,
the Report Writer generates a report without one.
Once you begin to specify titles, you may want to change page widths or provide
your own column headers. This chapter tells what the Report Writer does for you
and how to do those things for yourself if you wish.
You create a DATATRIEVE report with a series of Report Writer statements,
called a report specification. A report specification controls the format and determines the content of a report. Some statements are required for a valid report
specification, while others are optional.
These are required statements:
• A REPORT statement
• One PRINT statement or at least one AT statement
• An END_REPORT statement
These are optional statements:
• Statements to specify particular data you want for the report from all the
available data
• Statements to specify the file or device to which DATATRIEVE writes the
report

2-1

• A SET REPORT _NAME statement
• SET statements to control page format and assign headings
• AT statements if you wish to summarize data or print special headings
Each major section of this chapter discusses a part of the report specification.
Each section discusses first the format built into the Report Writer (the default
format) and then your options to change the default format.
You can incorporate one or more of the options into your report specification. If
you are satisfied with the default format, skip the option section that immediately follows ..
For example, the Report Writer automatically sets your page width at 80 columns per page. If you want to use that page width, you need not change it. But
you can include an optional statement (SET 'COLUMNS_PAGE) to specify a different page width.
To start a report design, take a piece of paper to make a rough sketch of a report
that you would like to produce. Indicate the information you would like the
report to contain, and the basic format for each page. Then read each section of
this chapter to develop a report specification that produces such a report, using
the instructions and examples provided as aids.

2.1

Identifying the Data and Invoking the Report Writer
Reports usually highlight only a portion of the available information. To report
specific data, you must identify it to DATATRIEVE and invoke the Report
Writer. Follow these steps:
1. Ready the domain(s) containing the data you wish to report:
DTR> READY YACHTSOO
DTR>

2. Identify the data that you want to report within the domain, so you can limit
the number of records in the report and sort the records if you desire. You can
identify the data in one of two ways: in a FIND statement that precedes the
report statement or with the REPORT statement itself.
This example shows a FIND statement that forms a sorted collection from
the YACRTS domain:
DTR> FIND YACHTS WITH LOA > ao SORTED BY BEAMOO
[8 records found]

DTR>

3. Enter the REPORT statement to invoke the Report Writer. The format of the
REPORT statement is:
REPORT [rse]

2-2

Designing a Report

file-spec }]
{ *.prompt

The following are valid REPORT statements:
• REPORT - When you omit the RSE (record selection expression) from the
REPORT statement, the Report Writer reports on the records in the
CURRENT collection:

)

DTR> REPORTOO)
RW>

• REPORT ON file-spec - When you specify the output file and no RSE, the
Report Writer reports on the CURRENT collection and writes the report to
a file. For example, this statement writes the report to the file
BIGYAT.LST:
DTR> REPORT ON BIGYATOO)
RW>

If your REPORT statement includes an ON clause, the Report Writer
advances the page after printing the report. That is, it places a trailing
form feed on the report. If you do not include an ON clause, it does not add
a form feed to the end of the report.

)

• REPORT rse - If you did not form a collection with a FIND statement, you
must identify a record stream with the REPORT statement. For example:
DTR> REPORT YACHTS WITH DISP :> 25000(0)
RW>

2.2

Correcting Mistakes in the Report Writer
You can correct mistakes in a Report Writer specification by retyping the
specification or by editing the procedure or command file that contains the report
statements.

2.2.1

Returning to the OTR> Prompt

You invoke the Report Writer with a REPORT statement, and you exit with
END_REPORT. However, if you make a mistake, you may want to exit before
completing your report specification.
To force an exit from the Report Writer and return to DATATRIEVE command
level, you can enter CTRL/Z as a response to an RW> prompt or in the middle of
an input line:
DTR> READY YACHTSOO)
DTR:> REPORT YACHTSOO)
RW> (CTRU Z )
DTR>

When you see the DTR> prompt, you can retype your Report Writer
specification.

Designing a Report

2-3

2.2.2

Using a Text Editor to Correct Mistakes

If you enter your report specification statements in a DATATRIEVE procedure or
in a command file outside DATATRIEVE, you can correct errors easily and
quickly.
To correct Report Writer statements contained in a DATATRIEVE procedure,
follow these steps:
1. Use the EXTRACT command to copy the procedure to a file, using the
statement:
EXTRACT ON file-spec procedure-name
2. EXIT from DATATRIEVE.
3. Use a text editor to make corrections in the procedure.
4. Return to DATATRIEVE.
5. Invoke the command file just created.
Notice the file begins with the commands DELETE procedure-name and
DEFINE procedure-name. DATATRIEVE inserts these commands into the
command file when you use the EXTRACT command. When you invoke the
file, DATATRIEVE deletes the incorrect procedure and creates the corrected
one.
6. Execute the procedure.
You also use the text editor to correct Report Writer statements in a command
file created outside DATATRIEVE. When you execute a file containing errors in
the report specification, DATATRIEVE sends you a message and returns you to
the DTR> prompt. To correct the errors, exit from DATATRIEVE and edit the
command file. Invoke DATATRIEVE again and execute the corrected command
file by typing the @ symbol and the command file name.
2.2.3

Using the DATATRIEVE Editor to Correct Mistakes

You can use the DATATRIEVE Editor to correct report statements contained in
a procedure. Type the command:
EDIT procedure-naMe

For a detailed explanation of the DATATRIEVE Editor, procedures and
command files, see the DATATRIEVE-ll User's Guide.

2.3

Formatting the Report Page
One of the main advantages of the Report Writer is its ease of formatting. You
can use the Report Writer's default format, or you can include SET statements to
specify the number of columns and lines per page, and the maximum number of
lines or pages in a report.

2-4

Designing a Report

2.3.1

)

Default Page Width and Length

The default format is the setting the Report Writer uses unless you specify otherwise. For page width and length, these are the defaults:
• Page width
• Page length
2.3.2

=

80 columns

=

60 lines

Option 1 : Setting the Page Width

If you do not want to use the default format of 80 columns per page, you can
specify the number of columns by putting a SET COLUMNS_PAGE statement
in your report specification. The statement has this form:

{~.prompt }

SET COLUMNS_PAGE =

)

The value n is the number of columns per page. The maximum value for n is 255.
You can use this command at DTR command level or in the Report Writer to set
the page width for reports. If you use the command in the Report Writer, it does
not affect the page width when you return to the DTR> prompt.

)

If you make the width too small, the Report Writer breaks each detail line and
moves the fields that do not fit to the next line of the display. In considering the
setting for page width, take into account the number of columns used to display
the same fields outside the Report Writer with the regular PRINT statement. If
you request totals and other special value expressions on the detail line, you
must add in the additional columns required for these print objects.
To set the page width at 60 columns, enter:
RW>

)

SET COLUMNS_PAGE

=

GOOO

If you use the prompt option, you can choose the page width when you process the
report.
2.3.3

Option 2: Setti ng the Page Length

If you do not want to use the default format 0[60 lines per page, you can include a
SET LINES_PAGE statement within your report specification. The statement
has the following form, where n is an integer representing the number of lines
per page:
SET LINES_PAGE =

fn

~ * .prompt

l,

To set the page length at 55 lines, enter:
RW>

SET LINES_PAGE = 5500

Designing a Report

2-5

If you use the prompt option, you can choose the page length at the time you process the report.
If your report contains a list, each item in the list counts as a separate detail line.
If you want a report without any page breaks, give n a value larger than the
number of lines in the report.
To be sure that you have set up your page the way you would like it, you may
have to experiment with two or three versions of the lines-per-page value.
2.3.4

Option 3: Limiting the Total Lines or Pages in a Report

The Report Writer limits the number of lines in a report to 32,767. It limits the
number of pages to 32,767 also. Because the automatic limit is so large, you may
want to use the SET MAX_LINES or SET MAX_PAGES statement to prevent a
loop that would tie up your system's resources. These statements specify the
maximum number of lines or pages your report can contain. For the statement
SET MAX_LINES, DATATRIEVE counts header lines, blank lines, detail lines,
and summary lines. The two formats are similar:
SET MAX_LINES =

SET MAX_PAGES =

{

~,prompt }
{

~,prompt }

The Report Writer counts all the lines or pages of the report. When it reaches the
limit you have specified, it stops producing the report and prints one of the following error messages:
MaxiMUM nUMber of lines exceeded--report aborted
Execution failed
MaxiMUM nUMber of pages exceeded--report aborted
Execution failed

If you use the prompt option, you can select the maximum number of pages or
lines at the time you process the report. For example:
DTR> READY YACHTSm
DTR> REPORT YACHTSm
RW>
PRINT BOATm
RW> SET MA}<_PAGES = *."the fTlaxifTlufTl nUfTlber of pages"m
RW> END_REPORTm
Enter the fTlaxifTlufTl nUfTlber of pages: 1m

2-6

Designing a Report

8-Mar-83
Page 1
!

J

MANUFACTURER
ALBERG
ALBIN
ALBIN
ALBIN
AMERICAN

MODEL
37 MK I I
78
BALLAD
I.,JEGA
26

RIG
KETCH
SLOOP
SLOOP
SLOOP
SLOOP

LENGTH
OI.JER
ALL
37
26
30
27
26

GRAMPIAN
KETCH
33
MaxiMUM nUMber of pages exceeded--report aborted
Execution failed
DTR>

2.4

WEIGHT

BEAM

PRICE

20tOOO
at200
5t070
atOOO

12
10
10
08
08

$17t800
$27t500
$18t600

12tOOO

10

$28t675

7t276

$36t851

$8t885

Setting Up the Report Heading
The report heading consists of the report name, date, and page number. You can
let the Report Writer use the default format or you can specify a report heading
with SET statements.

2.4.1

Default Format

The default format for the report heading is:
• Report Name - The Report Writer prints no title, unless you include a SET
REPORT_NAME statement.
• Date - The Report Writer prints the current system date in the upper right corner of the page. It uses the format DD-Mmm-YY (for example, 21-Jan-83).
• Page number - The Report Writer prints the page number of the report
directly under the date. Regardless of the lengths of the date string and the
page number, the Report Writer aligns the first character of the page number
identification under the first character of the date. It uses the format Page n.
For example:
21-Jan-83
Page 2

2.4.2

Option 1: Naming the Report

Use the SET REPORT _NAME statement to name your report. Be sure to enclose
the name in quotation marks. The Report Writer centers this name on the first
printed line at the top of the page. For example:
DTR>
DTR>
RW>
RW>
RW>

SET NO PROMPTffiD)
REPORT YACHTSffiD)
SET REPORT_NAME =ffiD)
"ACCOUNTS PAYABLE FOR BOCK'S YACHTS"ffiD)
END-REPO"'TffiD)

Designing a Report

2-7

This statement produces the following title:
ACCOUNTS PAYABLE FOR BOCK'S YACHTS

21-Jan-83
Page 1

The SET REPORT _NAME statement has the following syntax:
For naming the report:
SET

REPORT_NAME =

"string"[/ ... ] }
{ *.prompt

For specifying a date or string at the upper right of each page:
SET

DATE = "string"

For controlling the printing of a date or page number:
SET

NO DATE
NUMBER
NO NUMBER

I

I

[, ... ]

For specifying page width or length, or overall report length:
COLUMNS_PAGE =
LINES_PAGE =
MAX-LINES =
MAX-PAGES =

SET

{

~.prompt }

[, ... ]

You are not limited to report names of one line. To produce a report name of two
or more lines, enclose each segment of the report name in quotation marks and
separate each segment from the next with a slash (I):
DTR>
RW>
RW>
RW>

REPORT YACHTSCBill
SET REPORT-:NAME =CBill
IIACCOUNTS PAYABLElljllFOR BOCK'S YACHTSIICBill
END-REPORTCBill

This statement produces the following report heading:
ACCOUNTS PAYABLE
FOR BOCK'S YACHTS

18-Apr-83
Page 1

You can also have the Report Writer prompt you for a name each time it processes a report. In response to the prompt, enclose each segment in quotation
marks, and separate each segment from the next with a slash. For example:
DTR> READY PERSONNELCBill
DTR> REPORT FIRST 2 PERSONNELCBill
RW> SET REPORT_NAME = _*."report nafrle"CBill
RW> PRINT PERSONCBill
RW> END_REPORTCBill
Enter report nafrle: IIEMPLOYEE STATUSllj"FOR FIRST QUARTER"CBill

2-8

Designing a Report

This statement produces the following report:
EMPLOYEE STATUS
FOR FIRST QUARTER

)
10

00012
00891

STATUS

FIRST
NAME

E}-{ PER I ENCED
EXPERIENCED

CHARLOTTE
FRED

LAST
NAME
SPII.JA
HOWL

17-Jan-83
Pa!:le 1

START
DATE

DEPT
TOP
Fll

SUP
SALARY

12-Sep-72
9-Apr-76

$75,892
$59,594

10

00012
00012

DTR>

If you include a one-line name for the report, the name prints on the same line as
the page number.
To produce a report with no name, do not use the SET REPORT _NAME statement at all. There is no default report name.

)

2.4.3

Option 2: Assigning a Date

With the SET DATE statement, you can replace the default date in the top right
corner of the page with another date or any other character string:
DTR> REPORT YACHTSoo
RW> SET D?HE = "22 MAR 1983 "00
RW> END-REPORToo

)

This statement produces:
22 MAR 1983
Pa!:le 1

You can use a variety of date formats. For example:
DTR> REPORT YACHTSoo
RW> SET DATE = "TUESDAY, MARCH 14TH"(BIT)
RW> END-REPORToo

This statement produces:
TUESDAY, MARCH 14TH"
Pa!:le 1

You can specify wording that has no connection at all with dates. For example:
DTR> REPORT YACHTSOO
RW> SET DATE = "COMPANY CONFIDENTIAL"m
RW> END-REPORTm

This statement produces:
COMPANY CONFIDENTIAL
Pa!:le 1

Designing a Report

2-9

2.4.4

Option 3: Suppressing a Date

If you do not want a date on your report, include the SET NO DATE statement as
part of your report specification.
DTR>
RW>
RW>
RW>
RW>

REPORT FIRST 3 YACHTSt'@)
SET NO DATEt'@)
SET REPORT_NAME = IIFIRST BOATS"t'@)
PRINT BOATt'@)
END_REPORTt'@)
FIRST BOATS

MANUFACTURER
ALBERG
ALBIN
ALBIN

MODEL

RIG

37 MK I I
78
BALLAD

KETCH
SLOOP
SLOOP

LENGTH
OI.IER
ALL
37
26
30

Pase 1

WEIGHT

BEAM

PRICE

20,000
a,200
7,276

12
10
10

$36,951
$17,900
$27,500

DTR>

2.4.5

Option 4: Suppressing the Page Number

If you do not want any page numbers on your report, include the SET NO
NUMBER statement as part of your report specification.
DTR>
RW>
RW>
RW>

REPORT FIRST 1 YACHTSt'@)
SET NO NUMBEROO)
PRINT BOATOO)
END_REPORTOO)
13-Sep-82

MANUFACTURER
ALBERG

MODEL
37 MK II

RIG
KETCH

LENGTH
OI.lER
ALL
37

WEIGHT

BEAM

PRICE

20,000

12

$36,951

DTR>

Unless you suppress the page number, the Report Writer automatically prints
the page number in the upper right corner of the page .

. 2.5

Printing Detail Lines and Column Headers
Detail lines contain information about individual records from a domain. The
Report Writer arranges the information in columns, and the column headers
from the DATATRIEVE domain tell what the information in each column
represents.

2-10

Designing a Report

)

The Report Writer PRINT statement produces a detail line in the report for every
record in the CURRENT collection or in the specified record stream. A detail line
can cover several lines on the report page, depending on the content and format
you specify.
With the Report Writer PRINT statement, you can specify three characteristics
of the detail lines:
• The content of the detail lines:
Values of fields from records identified either by a FIND or by a REPORT
statement
Value Expressions
• The format of the print items in the detail lines:
Order of each print item
Column position of each print item
Edit string format for each print item
o

Column headings for each print item

For further discussion of the Report Writer PRINT statement, see the
DATATRIEVE-l1 Reference Manual.

2.5.1

Content of the Detail Line

A detail line can have two kinds of print items. The first is the value of a field
from the record. One example is the value of the PRICE field from YACHTS. The
second is a value expression. You n1ay derive value expressions from field values,
as in PRICE/DISP (price per pound) or PRICE* 1.1 (10% markup on price). Value
expressions may also be literals, variables, or prompt options.
2.5.1.1 Field Values - You determine the content of the detail line by indicating which fields from the record the Report Writer should print. You can specify
either elementary fields or group fields. In the case of a group field, each of its elementary fields appears in a separate column.

Example: Print the TYPE and PRICE fields of the YACHTS domain in the
default format. The report displays the group field TYPE as two columns, one
for each elementary field (MANUFACTURER and MODEL) TYPE contains:
DTR> REPORT FIRST 2 YACHTS(@')
RW> PRINT TYPE, PRICE(@,)
RW> SET COLUMNS_PAGE = GO(@')
RW> END_REPORT(@)

Designing a Report

2-11

27-Aug-83
Page 1

ALBERG
ALBIN

PRICE

MODEL

MANUFACTURER

$3Gt951
$17t900

37 MK II
79

DTR>

2.5.1.2 Value Expressions - You can create additional detail line items
computed from other field values with DATATRIEVE's arithmetic or statistical
operators. In addition, you can include other value expressions such as literals,
variables, or prompting value expressions.

Example: Display the model, current price, and a new price 10 percent higher
than the current price for the first five records in the YACRTS domain.
DTR>
DTR>
RW>
RW>
RW>
RW>

SET NO PROMPTOO)
REPORT FIRST 5 YACHTSOO
SET COLUMNS_PAGE = GOOO)
SET REPORT_NAME = "BOCK'S YACHTS"j"PRICE LIST"OO)
PRINT TYPEt PRICEt PRICE * 1.1 USING $$$t$$$OO)
END_REPORTOO)

BOCK'S YACHTS
PRICE LIST

MANUFACTURER
ALBERG
ALBIN
ALBIN
ALBIN
AMERICAN

8-Mar-83
Page 1

PRICE

MODEL
37 MK I I
79
BALLAD
I.JEGA
2G

$3Gt951
$17t900
$27t500
$18tGOO
$9t895

$llOtGllG
$19tG90
$30t250
$20tllGO
$10t8811

DTR>

The edit string clause, USING $$$,$$$, specifies the output format for the PRICE
*1.1 field. You need to use one more dollar sign than the maximum number of
digits for the value expression. See Section 2.5.2.3 for more information on edit
strings.

2.5.2

Format of Fields in the Detail Lines

The Report Writer determines a default format for each print item based on edit
string or picture clauses in the record definition or variable declaration. You can,
at your option, control the format within the PRINT statement.

2-12

Designing a Report

Order of Print Items - The order of the field names in the PRINT
statement determines the left to right printing order of the detail line items.
The following example shows how you can control the order of field names for
YACHTS:
2.5.2.1

DTR>
RW>
RW>
RW>

REPORT YACHTS WITH BUILDER = "GRAMPIAN"OO
PRINT ~10DEL t PRICE t MANUFACTURER t LOAOO
SET REPORT_NAME = "REPORT SHOWING PRINT ORDER"OO
END_REPORTOO
13-Sep-82
Page 1

REPORT SHOWING PRINT ORDER

MODEL
2-34
26
28
30
34

PRICE
$2Bt675
$11 t4B5
$14t475
$17t775

$2Bt675

MANUFACTURER
GRAMPIAN
GRAMPIAN
GRAMPIAN
GRAMPIAN
GRAMPIAN

LENGTH
OI.IER
ALL
34
26
28
30
33

DTR>

Column Position of Print Items - The Report Writer automatically
sets up the column spacing based on field, header, and page widths. If you want to
change the default spacing, you can specify the print position of any or all of the
print items.
2.5.2.2

If you do not leave enough room for the column headers and data items, the
Report Writer in some cases ((wraps" the detail line. That is, it prints some items
on a second line, including column headers. However, if a column header from
the first line is so long that it wraps into the next header's space in the second
line, the Report Writer suppresses the next header altogether. If you let the
Report Writer wrap the headers, make certain that all your headers appear in
the final copy.
If you choose to specify print' positions, you can:
• Specify the column number where the Report Writer begins to print each item
• Require spacing between columns by including a SPACE [n] element in the
PRINT statement
Here is an example of the first option:

Example: Display the same fields from YACRTS, but begin each field at 20
space intervals:
DTR>
DTR>
RW>
RW>
RW>
RW>

SET NO PROMPTOO
REPORT FIRST 2 YACHTSOO
SET REPORT_NAME = "REPORT SHOWING PRINT POSITIONS"OO
PRINT COL 1 t MODEL t COL 21 t PRICE tOO
COL 41 t BU I LDER t COL 61 t LOAOO
END_REPORTOO

Designing a Report

2-13

REPORT SHOWING PRINT POSITIONS

17-Jan-83

Page 1

37 MK

MANUFACTURER

PRICE

MODEL
II

ALBERG
ALBIN

$36t951
$17t900

79

LENGTH
OI,'ER
ALL
37
26

DTR>

Here is an example of spacing with the SPACE En] element:·

Example: Display the same fields, allowing five spaces between columns:
DTR>
DTR>
RW>
RW>
RW>
RW>

SET NO PROMPT(@)
REPORT FIRST 2 YACHTS(@)
SET REPORT_NAME = "REPORT USING THE SPACE ELEMENT"(@)
PRINT MODELt SPACE 5t PRICEt SPACE 5tOO
BUILDERt SPACE St LOAOO
END_REPORTOO
REPORT USING THE SPACE ELEMENT

ll-Oct-83

Page 1

MODEL
37 MK II

79

PRICE
$36t951
$17t900

MANUFACTURER
ALBERG
ALBIN

LENGTH
OI,'ER
ALL
37
26

DTR>

2.5.2.3 Edit String Format of Print Items - If you declare an edit string for a
field in the record definition, the Report Writer uses that edit string to format the
print item. If you are setting up print items derived from field values, the Report
Writer supplies an edit string. You can replace either edit string for a print item
by specifying an edit string in the PRINT statement.

The full range of edit strings for record definitions is available to you in Report
Writer PRINT statements. With a USING clause, you can require that the
Report Writer display the value of an alphabetic, numeric, or date field. The
USING clause can contain commas, hyphens, percent signs, dollar signs, or decimal points.

Example: You want a numeric field to represent money. All values for the field
are'less than $10,000. You could choose the following edit string:
RW>

2-14

PRINT PRICE/DISP USING $$t$$$.9900)

Designing a Report

Some values formatted with this edit string are:

)

• $9,016.97
• $995.38
• $.99
If a field contains a large amount of text, specify a T edit string. The format of a T
edit string is T(n), where n is the column width. The T edit string instructs the
Report Writer to print the text over several lines, with a maximum ofn characters pe! line.
The Report Writer does not divide any words across lines.
If you put the T format value expression at the end ofa line, the other print items
all appear on the same line as the first line of text.
For full information on the edit strings available within DATATRIEVE, consult
theDATATRIEVE-ll Reference Manual.

2.5.3

Column Headers for Print Items

DATATRIEVE displays column headers at the top of the report and at the top of
each page. The Report Writer uses the field name or the query header from the
record definition as the default.
Option 1: Suppressing a Column Header - If you do not want a column header for an individual field, follow the print list item with a hyphen in
parentheses: (-). For example:
2.5.3.1

OTR>
RW>
RW>
RW>

REPORT FIRST 1 YACHTS@
SET COLUMNS_PAGE = 80@
PRINT MANUFACTURER t MOOEL (-) t LOA tRIG t PRICE (-)@
ENO_REPORT@

9-Apr-83
Page

LENGTH
OI.IER
ALL

MANUFACTURER
ALBERG

37 MK

II

37

1

RIG
KETCH

$38t951

OTR>

Designing a Report

2-15

2.5.3.2

Option 2: Specifying a Column Header - You can choose the column

header by following a print list item with the column header enclosed in parentheses and quotation marks. For example, you could change the name of the first
column header in the last example from ~~MANUFACTURER" to ~~VENDOR" by
using this PRINT statement:
DTR> REPORT FIRST 1 YACHTSOO
RW>
PRINT MANUFACTURER ( 11.JENDOR") t MODEL
RW>
END_REPORT(@)

(-) t LOA tRIG t PRICE

(-)(@)

The report specification with this revised print statement produces the following
report:
5-MAY-83

Page 1

LENGTH
OI.JER
ALL

1.'ENDOR

37 MK I I

ALBERG

37

RIG
KETCH

$3Gt951

DTR>

To include a column header of two or more lines, use the slash (I) between quoted
strings. For example:
DTR> REPORT FIRST 1 YACHTSOO
RW>
PR I NT MANUFACTURER (" BOAT"
RW>
END_REPORT(@)

j"

BU I LDER" )

t

MODEL

(-)

t

LOA(@)

The report specification with this revised print statement produces:
17-Jan-83
Page 1

LENGTH
OI.'ER
ALL

BOAT
BU I'LDER
ALBERG

37 MK I I

37

DTR>

For fields with one or two character values, you can compress the headers. The
following PRINT statement specifies a three-line header for the LOA field:
RW>

2-16

PRINT MANUFACTURERt LOA

Designing a Report

(ILljIOlj"A")

t

RIGt PRICE(@)

Here is a sample report using this print statement:
DTR>
RW>
RW>
RW>

)

REPORT FIRST 1 YACHTS(BTI)
SET COLU~1NS_ PAGE = 60(BTI)
PRINT MANUFACTURERt LOA ("L"j"O"j"A") t RIGt PRICE(BTI)
END_REPORT(BTI)
17-Jan-83
Page 1
L

o
MANUFACTURER
ALBERG

RIG

PRICE

KETCH

$36t851

A

37

DTR>

2.6

Summarizing Data
You can instruct the Report Writer to calculate summary statistics for the report.
Use the AT BOTTOM OF PAGE or the AT BOTTOM OF REPORT statements.
(An AT BOTTOM OF field-name statement can generate summaries on groups
within the report. See the next chapter for a discussion of dividing data records
into groups.)
As a general rule, it is best not to use the AT TOP OF REPORT or AT TOP OF
PAGE statements for summarizing data. Use these statements for printing special headings in the report.

2.6.1

COUNT, AVERAGE, and TOTAL

With the statistical operators COUNT, AVERAGE, and TOTAL you can display
the number of records in the report, the average value of the value expressions in
the record stream, and the total value of those expressions. You use these statistical operators within PRINT or AT TOP or AT BOTTOM statements.
Example: Bock's Yachts has a PERSONNEL domain that stores data about the
members of its sales force. Report the ID, last name, department, and salary for
each salesperson. At the bottom of the report, show the number of salespersons
(COUNT), the total salary (TOTAL SALARY), and the average salary
(AVERAGE SALARY).

Use a command file (.CMD) to create the report. The file AV.CMD and the report
it generates follow:
DTR> @AI.J. CMD (BTI)
READY PERSONNEL
REPORT PERSONNEL
SET COLUMNS_PAGE = 60
SET REPORT_NAME = "BOCK'S YACHTS"j"SALARY REPORT"
PRINT IDt LAST_NAMEt DEPTt SALARY
AT BOTTOM OF REPORT PRINT SKIP 2t
COL 10 t "WORK FORCE:" t SPACE t COUNT (-) USING 28 t
COL 37 t "TOTAL:" t TOTAL SALARY US I NG $$$$ t $$$.88 t
COL 37 t "AI.JERAGE:" t AI.JERAGE SALARY US I NG $$$ t $$$.88
END_REPORT

Designing a Report

2-17

BOCK'S YACHTS
SALARY REPORT

Page 1

ID

LAST
NAME

DEPT

SALARY

00012
00B81
02843
12843
32432
34458
38482
38485
38485
48475
48573
48001
48843
78823
83784
84375
87288
87485
87701
88001
80342
81023
88028

S P !I.'A
HOWL
TERRY
TASHKENT
SCHWEIK
MORRISON
SWAY
FREIBURG
TERRICK
CASSIDY
KELLER
ROBERTS
HAMMER
HARRISON
MEADER
NALEl.'O
DEPALMA
IACOBONE
CHONTZ
LITELLA
DONCH I K0 1.'
WITTGEN
PODERESIAN

TOP
F 11
D8B
C82
F 11
T32
T32
E48
D88
E48
T32
C82
D88
Fll
T32
D88
G20
C82
F 11
G20
C82
G20
C82

$75,882
$58,584
$28,808
$32,818
$28,723
$30,000
$54,000
$23,808
$55,828
$55,407
$31,548
$41 ,385
$28,382
$40,747
$41 ,028
$58,847
$57,588
$58,482
$24,502
$34,833
$35,852
$25,023
$33,738

WORK FORCE: 23

2.6.2

28-Feb-83

TOTAL: $852,343.00
AVERAGE: $41,a08.21

Maximum Value and Minimum Value

To show the maximum and minimum values of specific fields, use the operators
MAX and MIN on the field names. These operators cause the Report Writer to
display the maximum or minimum value of all value expressions in the record
stream or current collection.

Example: Expand the salary report to indicate the maximum salary and the
minimum salary.
Use a command file (.CMD) to contain the statements to create the report.
Here is the file SALSTA.CMD, followed by the report that it generates:
DTR> @SALSTA (BTI)
READY PERSONNEL
REPORT PERSONNEL
SET REPORT_NAME = "BOCK'S YACHTS"j"DETAILED SALES REPORT"
SET COLUMNS_PAGE = 80
PRINT ID, LAST_NAME, DEPT, SALARY
AT BOTTOM OF REPORT PRINT SKIP 2,
COL 10, "WORK FORCE:", SPACE, COUNT (-) USING Z8,
COL 37, "TOTAL:", TOTAL SALARY US I NG $$, ,$$$ ,$$$.88 ,
COL 37, "Al.'ERAGE:", Al.'ERAGE SALARY US I NG $$$, $$$.88 ,
COL 37, "MA}n MUM: ", MA}-{ SALARY US I NG $$$, $$$.88 ,
COL 37, "MINIMUM:", MIN SALARY USING $$$,$$$.88
END_REPORT

2-18

Designing a Report

BOCK'S YACHTS
DETAILED SALES REPORT

8-Mar-83
Page 1

)

)

ID

LAST
NAME

00012
00881
02843
12643
32432
34456
38462
38465
38485
48475
48573
48001
48843
78823
83764
84375
87288
87465
87701
88001
80342
81023
88028

S PI I)A
HOWL
TERRY
TASHKENT
SCHWEIK
MORRISON
SWAY
FREIBURG
TERRICK
CASSIDY
KELLER
ROBERTS
HAMMER
HARRISON
MEADER
NALEI)O
DEPALMA
IACOBONE
CHONTZ
LITELLA
DONCH I K0 1)
WITTGEN
PODERESIAN

WORK FORCE: 23

DEPT

SALARY

TOP
F11
D88
C82
F11
T32
T32
E46
D88
E46
T32
C82
D88
F11
T32
D88
G20
C82
F11
G20
C82
G20
C82

$75,882
$58,584
$28,808
$32,818
$26,723
$30,000
$54,000
$23,808
$55,828
$55,407
$31 1546
$41 1385
$26,382
$40,747
$41 1028
$56,847
$57,588
$58,462
$24,502
$34,833
$35,852
$25,023
$33,738

TOTAL:
$852,343.00
AVERAGE:
$41 1406.21
MAXIMUM:
$75,882.00
MINIMUM:
$23,808.00

One other way to produce the report is to define a procedure within
Invoke the procedure at DATATRIEVE command level (indicated by the DTR> prompt) by typing a colon and the procedure name.
DATATRI~VE.

The last two examples use AT BOTTOM statements to produce overall page and
report summaries. You can also use AT BOTTOM statements to divide your data
records into groups. You can then compile statistics about groups of records, as
well as about all the records.

2.7

Selecting the Output Device or File
With the REPORT statement you can select the device or file that is to receive
the report. If you use the prompt option, you can choose the output device immediately before you produce the report.

Designing a Report

2-19

2.7.1

Default: Output to Terminal

If you begin your report specification with a statement of the form ((REPORT
[rse]", the Report Writer displays the report on your terminal. Such a statement
is equivalent to an explicit declaration of the form ((REPORT [rse] ON TI:" except
that the Report Writer does not start a new page after the report as it does when
you use the ON clause.

2.7.2

Option 1: Output to a Line Printer

To get a copy of your report from a line printer, type the device name of the line
printer at the end of the REPORT statement:
DTR> REPORT ON LP:@]

If the REPORT command contains an RSE, put the output specification after the
RSE:
DTR> REPORT YACHTS WITH BUILDER

2.7.3

PEARSON ON LP:@]

Option 2: Output to a File

If you want to store your report in a file, end the REPORT statement with ON followed by a file specification. This example creates a file called REPORT. TXT in
your default directory:
DTR> REPORT BIG_ONES ON REPORT. T}·(T@]

If you send your report to a file, you can use your operating system's commands to
print a hard copy at your convenience.
For RSTS/E systems, if you specify an output file that already exists, the system
sends you an error message and does not create the file.

2.7.4

Option 3: Prompt

If you want to choose the output medium at the time you process the report, use
the prompt option. Then DATATRIEVE prompts you for the output medium
when it processes the report:
DTR> READY PERSONNEL(@]
DTR> REPORT FIRST a PERSONNEL ON *."OUTPUT DEVICE OR FILE"@]
RW> SET REPORT_NAME = *."THE NAME FOR THE REPORT"@]
RW> PRINT IDt NAMEt SALARY@]
RW> END_REPORTCBTI)
Enter THE NAME FOR THE REPORT: "TOP ACHIEI,IERS"CBTI)
Enter OUTPUT DEI,IICE OR FILE: TICBTI)

2-20

Designing a Report

TOP ACHIE1.JERS

22-Apr-83
Page 1

)
IO

FIRST
NAME

00012
00891
02943
12843

CHARLOTTE
FRED
CASS
JEFF

LAST
NAME
S P !I.' A
HOWL
TERRY
TASHKENT

SALARY
$75t892
$59t594

$29t908
$32t918

In this case, the Report Writer displays the report on the terminal. You can
specify only one output device in a REPORT command.
When you specify your output medium with an ON clause, the Report Writer
advances to a new page after the report. If you do not use an ON statement, it
does not advance to a new page after the report.

)

Designing a Report

2-21

)

Mastering Report Writing Techniques

3

)
The Report Writer allows you to use a number of special techniques, such as
these:
• Reporting on Groups of Records
To report on groups of records, define your data file so your records are sorted
automatically. Use an indexed file.
If you want to sort the records differently for different reports, use the
SORTED BY clause to tell the Report Writer how to sort the records.
• Reporting a Summary Only
To produce a report made up of summary lines only, use the AT BOTTOM OF
field-name statement.
• Printing a Title Page
To print a complete title page before the body of the report, use the AT TOP OF
REPORT statement.
• Printing Special Headings
To produce special headings for successive pages of a'report, use the AT TOP
OF PAGE statement.
• Finding Totals within a Detail Line (Cross Tabulation)
To add fields within a detail line, specify an additional print item that computes the total you want.
• Reporting List Fields
To report list fields, form a collection with the FIND statement, and use an
inner print list as an item in the PRINT statement.

3-1

This chapter describes these techniques and illustrates them with sample
reports.

3.1

Dividing Data Records into Groups
You may often need to report on the groups of records within a body of data
as well as on all the data. For example, you could report on employees sorted
by department, with summary totals for each department as well as for all
employees.
Groups of sorted records are control groups. A control group is a series of sorted
data records that have the same value in one or more fields. The common field or
fields ~~control" the forming of the group.
3.1.1

Defining Key Fields to Optimize Speed of Processing

Instead of requiring the Report Writer to sort the records (with the SORTED BY
phrase), you can define your data file so the field you sort by most frequently is
the primary key field. To define a data file for PERSONNEL with ID as the primary key, use this command:
DTR> DEFINE FILE FDR PERSONNELt KEY = ID(@')

Defining such primary key fields is an effective optimization technique. The
examples in the next section show how to use the SORTED BY phrase for cases
where you have not defined a key field or want to sort by a field other than the
key field.
3.1.2

Developing Control Groups with a Sort Key

When you sort a group of records, you choose at least one field as the basis for the
sort. That field is called the sort key. Sometimes every record in a record stream
has a unique value for the sort key. For example, every employee's badge number
is unique. When you sort employee records by the badge number, you create no
control groups with two or more records because no two records have the same
value in that field.
In other cases, the number of unique values for a sort key may be small compared
to the number of sorted records. For example, a company of 500 employees may
have only 10 departments. That is, there are only 10 unique values for DEPT in
the collectiqn of 500 employee records. When you sort the employee records by
the department code (DEPT), you create 10 control groups. DEPT would be a
meaningful sort key for the grouping ~~employee records."
The following report statement establishes DEPT as the sort key for the records
in the domain PERSONNEL:
DTR> REPORT PERSONNEL SORTED 5'1' DEPT(@,)
RW>

3-2

Mastering Report Writing Techniques

When you have completed the report specification, DATATRIEVE sorts the
records according to the department code and processes the report:

)

DTR>
RW>
RW>
RW>

REPORT PERSONNEL SORTED BY DEPTm
SET COLUMNS_PAGE = 70(@)
-PR I NT PERSON(@)
END_REPORT(@)
2-Mar-83
Page 1

ID
12643
48001
87465
80342
88028
02843
38485
48843
84375
38465
48475
00881
32432
78823
87701
87288
88001
81023
34456
38462
48573
83764
00012

STATUS
TRAINEE
E>~ PER I ENCED
E)-( PER I ENCED
E)-( PER I ENCED
E)·~ PER I ENCEO
E)-( PER I ENCED
E>~ PER I ENCED
TRAINEE
E>~PERIENCED

E)-( PER I ENCED
E)-( PER I ENCED
E>~ PER I ENCED
TRAINEE
E)-( PER I ENCED
TRAINEE
E)-{ PER I ENCED
E)-( PER I ENCED
TRAINEE
TRAINEE
D-(PER I ENCED
TRAINEE
EHPERIENCED
E)-{ PER I ENCED

FIRST
NAME

LAST
NAME

JEFF
DAN
ANTHONY
BRUNO
RANDY
CASS
DEE
BART
MARY
JOANNE
GAIL
FRED
THOMAS
LYDIA
NATHANIEL
LOUISE
DAt.JID
STAN
HANK
BILL
SY
JIM
CHARLOTTE

TASHKENT
ROBERTS
IACOBONE
DONCH I KOt)
PODERESIAN
TERRY
TERRICK
HAMMER
NALEt.JO
FREIBURG
CASSIDY
HOWL
SCHWEIK
HARRISON
CHONTZ
DEPALMA
LITELLA
WITTGEN
MORRISON
SWAY
KELLER
MEADER
S P !l.JA

DEPT
C82
C82
C82
C82
C82
D88
D88
D88
D88
E46
E46
F11
F11
F 11
F11
G20
G20
G20
T32
T32
T32
T32
TOP

START
DATE
4-Apr-81
7-Jul-78
2-Jan-73
8-Aug-78
24-Ma}'-78
2-Jan-80
2-Ma}'-77
4-Aug-81
3-Jan-76
20-Feb-80
2-Ma}'-78
8-Apr-76
7-Nol.l-81
18-Jun-78
28-Jan-82
28-Feb-78
11-Nol.l-80
23-Dec-81
1-Mar-82
5-Ma}'-80
2-Aug-81
4-Apr-80
12-Sep-72

SUP
ID

SALARY
$32t818
$41 t385
$58t462
$35t852
$33t738
$28t808
$55t828
$26t382
$56t847
$23t808
$55t407
$58t584
$26t723
$40t747
$24t502
$57t588
$34t833
$25t023
$30tOOO
$54tOOO
$31 t 546
$41 t028
$75t882

87465
87465
00012
87465
87465
38485
00012
38485
38485
48475
00012
00012
00881
00881
00881
00012
87288
87288
87288
00012
87288
87288
00012

DTR>

Once you have sorted the records, you can use an AT TOP OF field-name or an
AT BOTTOM OF field-name statement to emphasize the relationships among
the sorted records. In the next example, an AT BOTTOM OF DEPT statement
groups records according to department. Within the AT BOTTOM statement, you
can use one or more statistical operators to summarize data about the employees
in each control group.
Example: Bock's Yachts keeps salary records for employees in various departments using the PERSONNEL domain. Report on all employees for selected
departments within the company. Display the total salary for each department.
Follow these steps:
1. Sort the records according to the sort key DEPT to produce a group of
employees for each department.

2. Use an AT TOP OF DEPT statement to print the value for DEPT at the
beginning of each DEPT control group.

Mastering Report Writing Techniques

3-3

3. Specify the values to be printed in each detail line. Use the concatenation
expression ( II ~~ "1) to put exactly one space between the values for the first
and last names. The double vertical line ( II ) suppresses the trailing spaces
after the entry for FIRST _NAME. The space in quotation marks puts one
space after FIRST _NA~E. The single vertical line ( I ) causes LAST _NAME
to print immediately after the one space. Specify a header CNAME").
4. Summarize salary information for each department with an AT BOTTOM
OF DEPT statement. TOTAL SALARY gives the total salary for a
department.
The following command file, SALRP1.CMD, incorporates these basic steps.
DTR> @SALRP1m
READY PERSONNEL
REPORT PERSONNEL WITH DEPT = ID98", IE48", IT32" SORTED BY DEPT
SET REPORT_NAME = "SALARY REPORT"
SET COLUMNS_PAGE = 80
AT TOP OF DEPT PRINT DEPT
(
PRINT ID , FIRST_NAME::
LAST_NAME ("NAME"), SALARY - - - - - - _ .03
AT BOTTOM OF DEPT PRINT SKIP,
COL 34, DEPT::
"TOTAL: ",
TOTAL SALARY USING $$$$,$$$ --------------------------~(
END_REPORT
II

II

:

II

":

SALARY REPORT

DEPT

ID

NAME

9-Mar-83
Pa!:le 1

SALARY

D98
02943
39485
49843
84375

CASS TERRY
DEE TERRICK
BART HAMMER
MARY NALEI.IO
D98 TOTAL:

$29,908
$55,829
$28,392
$58,847
$188,978

E48
38485
48475

JOANNE FREIBURG
GAIL CASSIDY
E48 TOTAL:

$23,908
$55,407
$79,315

T32
34458
38482
48573
83784

HANK MORRISON
BILL SWAY
SY KELLER
JIM MEADER
T32 TOTAL:

$30,000
$54,000
$31 ,548
$41 ,029
$158,575

DTR>

3.1.3

Developing Levels of Control Groups Using Multiple Sort Keys

The last example used one sort key to establish control groups, with each member of the group having the same value for the key field. There may also be times
when you wish to identify groups within these control groups. One control group
can contain other control groups.
3-4

Mastering Report Writing Techniques

For example, you could sort a personnel file by department and type of employee.

)

Example: Two categories of employees work at Bock's Yachts, experienced
workers and trainees. The STATUS field takes one of two values: ((Experienced"
or ((Trainee". Report salaries for each department, and for each type of employee
within a given department.
Follow these steps:
1. Sort the records according to two sort keys, DEPT and STATUS.

2. Use AT TOP OF DEPT and AT TOP OF STATUS statements to set up special headings for the control groups.
3. Print the field values of the detail line. Use a concatenation expression
(FIRST _NAME II (( "1 LAST _NAME) to allow exactly one space between
FIRST _NAME and LAST _NAME. Specify a header for the full name
CNAME").
4. Use AT BOTTOM OF DEPT and AT BOTTOM OF STATUS statements to
print summary lines for each control group.
5. Summarize the entire report with an AT BOTTOM OF REPORT statement.
The report specification follows these basic steps to produce a double-controlbreak report, that is, a report with two sort keys. It forms a new sort order each
time there is a change for ((DEPT" (the first control break), and for ((STATUS"
(the second). For brevity, this report shows only employees in departments D98
and T32.
The procedure SALARY _REPORT2 contains the following report specification:
DTR> SHOW SALARY_REPORT200l
PROCEDURE SALARY_REPDRT2
READY PERSONNEL
REPORT PERSONNEL WITH DEPT = "D98" t "T32" SORTED BY DEPT t STATUS-0
SET REPORT_NAME = "DETAILED SALARY REPORT"
SET COLUMNS_PAGE = 70
AT TOP OF DEPT PRINT DEPT
AT TOP OF STATUS PRINT STATUS ~I----------------------------------QD
PR I NT I D t FIRST_NAME::" " : LAST_NAME (" NAME" ) t SALARY
®
AT BOTTOM OF STATUS PRINT SKIPt COL 38t----------~
STATUS::" ":"TOTAL:"t TOTAL SALARY USING
$t$$$t$$$t SKIP
~--------~4
AT BOTTOM OF DEPT PRINT COL 3Gt
"DEPARTMENT ": DEPT: :" TOTAL:" t
TOTAL SALARY USING $t$$$t$$$t
COL 30 t " _______________________ " t SK I P
AT BOTTOM OF REPORT PRINT COL 15t --------------------~

"****************************************"

t

SK I P 2 t COL 38 t "GRAND TOTAL SALARY:" t
TOTAL SALARY USING $ t$$$ t$-$$ - - - - - - - - - - - - - - '
END_REPORT
END_PROCEDURE
DTR) :SALARY_REPORT2(illj

Mastering Report Writing Techniques

5

3-5

DETAILED SALARY REPORT

DEPT

STATUS

ID

NAME

25-Jan-83
Page 1

SALARY

D98
E}-(PER I ENCED
029a3
39a85
8a375

CASS TERRY
DEE TERRICK
MARY NALEI.IO

$29t908
$55t829
$56t8a7

EXPERIENCED TOTAL:
TRAINEE
BART HAMMER
TRAINEE TOTAL:
DEPARTMENT D98 TOTAL:

$26t392
$26t392
$168t976

T32
E>~PER

I ENCED
38a62
8376a

BILL SWAY
JIM MEADER
EXPERIENCED TOTAL:

$54tOOO
$a 1 t029
$95t029

TRAINEE
3aa56
a8573

HANK MORRISON
SY KELLER
TRAINEE TOTAL:
DEPARTMENT T32 TOTAL:

$30tOOO
$31 t5a6
$61 t5a6

$156t575

****************************************
GRAND TOTAL SALARY:
DTR>

3-6

Mastering Report Writing Techniques

$325t551

)

The report looks like this if you change the order of the sort keys, putting
STATUS before DEPT in your statement, but with the rest of the specification
unchanged:
DETAILED SALARY REPORT

17-Jan-B3
Page

STATUS
E>~

DEPT

1

ID

NAME

SALARY

029L13
39L185
BLl375

CASS TERRY
DEE TERRICK
MARY NALEI.IO
DEPARTMENT D98 TOTAL:

$29t908
$55t829
$56tBLl7
$1L12t58L1

3BLl62
B376L1

BILL SWAY
JIM MEADER
DEPARTMENT T32 TOTAL:

$5L1tOOO
$Ll1 t029
$95t029

PER I ENCED
D98

T32

EXPERIENCED TOTAL:

$237t613

TRAINEE
D98
Ll9BLl3

BART HAMMER
DEPARTMENT D98 TOTAL:

$26t392
$26t392

3L1L156
LlB573

HANK MORRISON
SY KELLER
DEPARTMENT T32 TOTAL:

$30tOOO
$31 t5L16
$61t5L16

T32

TRAINEE

TOTAL:

$87t938

****************************************
GRAND TOTAL SALARY:

$325t551

DTR>

Mastering Report Writing Techniques

3-7

The Report Writer sorts first by the sort key that you list first. Within each of the
control groups formed by that key, it sorts by a second sort key, and so on. It creates a control break whenever there is a change in field value for the sort key.
If you are reporting on sorted records and do not call for explicit control breaks
in the AT TOP or AT BOTTOM statements, the Report Writer does not supply
breaks. If you want a field break when a value changes, you must include an
explicit AT TOP OF field or AT BOTTOM OF field statement.
When it is printing the values for a given control group, the Report Writer continues printing until it reaches the end of the group, even ifit must run over to a
second page to do so.

3.1.4

Using Control Breaks on Unsorted Records

You may decide to use AT TOP and AT BOTTOM statements on records you have
not sorted with DATATRIEVE. If you are reporting on:
• An indexed file, the Report Writer processes the records according to the
ascending order of the primary key value
• A sequential file, the Report Writer processes records in the order they were
stored
When you use AT statements with records you have not sorted using
DATATRIEVE, the Report Writer produces the report, but it sends the
following message:
Proceeding to report unsorted records

If you are using more than one AT TOP statement or AT BOTTOM statement,
you should specify the control breaks in this order:
RW>
RW>
RW>
RW>

3.1.5

AT
AT
AT
AT

TOP OF
TOP OF
BOTTOM
BOTTOM

field-l
field-2
OF field-2
OF field-l

Reporting Group Summaries Only

Control groups allow you to separate groups of detail lines and to print group
summaries. Sometimes you may want only the summary information for the
groups. It is possible to produce a report with summary lines and no detail lines,
using the Report Writer or the SUM statement.
You can produce a report consisting of only summary lines for control groups
with the AT BOTTOM OF field-name statement.

Example: Report salary information for each department in Bock's Yachts.
Include the number of employees in each department, the total salary, and the
average salary. Finally, for the entire company, show the total number of
employees, total salary, and average salary.

3-8

Mastering Report Writing Techniques

Follow these steps:

)

1. Specify a sort key for the REPORT statement.

2. Use AT BOTTOM OF DEPT to print each line of the body of the report. Each
line summarizes a different department. Do not use the PRINT statement,
because you are reporting on group totals, not on the individual members of
the group. Use COUNT as a print item for the number of employees.
3. Use AT BOTTOM OF REPORT for the aggregate summaries. COUNT provides the total of all employees, because it represents the total of all records
processed.
The report specification that follows is contained in the command file
TOTALS.CMD:
DTR> @TOTALS(@)
READY PERSONNEL
REPORT PERSONNEL SORTED .BY DEPT -------------------10
SET COLUMNS_PAGE = *."the Colufrlns per page"
AT BOTTOM OF DEPT PRINT COL 10, DEPT,
COL 20, COUNT (" NUMBER j EMPLOYEES
COL 35, TOTAL SALARY (ITOTALljISALARY") USING $,$$$,$$$,
COL 50, At.IERAGE SALARY (IAI.IERAGEljISALARY") USING $$$ ,$$$
AT BOTTOM OF REPORT PRINT SKIP, COL 10,
II

II

II )

,

"**********************************************" ,
SK I P 2, COL 10, COR PORATE: ", COL 22, COUNT,
COL 34, TOTAL SALARY USING $$,$$$,$$$,
COL 48, AI.IERAGE SALARY USING $ ,$$$ ,$$$ _ _ _ _ _
END_REPORT
Enter the Colufrlns per page: 60(@)
II

t-------i3

....l

8-Mar-83
Page 1

DEPT
C82
088
E46
Fll
G20
T32
TOP

NUMBER
EMPLOYEES
5
4
2

4
3
4
1

TOTAL
SALARY

AI)ERAGE
SALARY

$202,465
$168,876
$78,315
$151 ,566
$117,554
$158,575
$75,882

$40,483
$42,244
$38,657
$37,881
$38,184
$38,143
$75,882

**********************************************
CORPORATE:

23

$852,343

$41 ,406

DTR>

Mastering Report Writing Techniques

3-9

3.2

Printing a Title Page and Other Special Headings
By using AT TOP OF REPORT and AT TOP OF PAGE statements, you can
enhance your reports with title pages and headings.

3.2.1

Printing a Title Page

The AT TOP OF REPORT statement allows you to produce a title page before
you produce any detail lines. When you use this statement, you suppress the
default report heading on the first page of the report. You can then design the
first page as a special title page without detail lines. The next page is ((Page I"
and includes the report and column headers.

Example: Report the salaries of employees at Bock's Yachts. Produce a title page
for the report. Include the company name, the warning ((CONFIDENTIAL: FOR
OFFICIAL EYES ONLY", and the company motto. Do not print the date or page
number until the next page of the report. Separate each item in the print list
with a comma. Include NEW _PAGE as the last item of your print list to ensure
that the first detail lines do not appear until the next page.
The command file and title page look like this:
DTR> @TPCffi)
READY PERSONNEL
REPORT P[RSONNEL WITH DEPT = IID88 11 t IIEa6 11 t IIT32 11
AT TOP OF REPORT PRINT SKIP 15t COL 20t
11* * * * * * * * * * * * * * * * * * *lItSKIPt
COL 20 t
* t COL 56 t *lItSKIPt
*lItSKIPt
COL 20 t * t COL 56t
COL 20 t
* t COL 32t SALARY REPORT II t COL 56t 11*11 t
COL 20 t
* t COL 56 t *11 t SKIPt
COL 20 t
* t COL 30 t FOR BOCK'S YACHTS II t COL 56 t 11*11 t
COL 20 t * t COL 56 t *11 t SKIPt
COL 20 t
* t COL 56t *11 t SKIPt COL 20t
11* * * * * * * * * * * * * * * * * * *11 t SKIP 5t
COL 32t IICONFIDENTIAL: II t SKIPt
COL 32t IIFOR OFFICIALlit SKIPt
COL 33 t II EYES ONLY II t SK I P 5 t
COL 20t 11 _______________________________________ 11 tSKIP 3t
COL 22 t II OUR MOTTO:
A YACHT FOR EIJERY WORKER II t SK I P 3 t
COL 20 t 11---------------------------------------11 t NEW_PAGE
SET COLUMNS_PAGE = 70
PRINT I"D t STATUS t FIRST_NAME:: II II : LAST_NAME (IINAMEII) t
DEPTt SALARY
END_REPORT

3-10

Mastering Report Writing Techniques

Here is the title page. The body of the report is on the next page:

)

* * * * * * * * * * * * * * * * * *
*
*
SALARY REPORT
*
*
FOR BOCK'S YACHTS
*
*
*
* * * * * * * * * * * * * * * * * *

*
*
*
*
*
*
*
*
*

CONFIDENTIAL:
FOR OFFICIAL
EYES ONLY

OUR MOTTO:

A YACHT FOR EVERY WORKER

Mastering Report Writing Techniques

3-11

18-Jan-83
Page 2
ID

STATUS

02943
34456
38462
38465
39485
48475
48573
49843
83764
84375

E){PER I ENCED
TRAINEE
E)-~ PER I ENCED
E)-~ PER I ENCED
E)-~ PER I ENCED
E)-{ PER I ENCED
TRAINEE
TRAINEE
E){ PER I ENCED
E)-~ PER I ENCED

NAME
CASS TERRY
HANK MORRISON
BILL SWAY
JOANNE FREIBURG
DEE TERRICK
GAIL CASSIDY
SY KELLER
BART HAMMER
JIM MEADER
MARY NALEI.IO

DEPT

SALARY

D98
T32
T32
E46
D98
E46
T32
D98
T32
D98

$29,908
$30,000
$54,000
$23,908
$55,829
$55,407
$31 ,546
$26,392 $41 ,029
$56,847

DTR>

3.2.2

Printing Special Page Headings

With the AT TOP OF PAGE statement you can print special headings for your
report. When you use the AT TOP OF PAGE statement, you suppress the default
report and column headings on every page. If you want either of these headings
on the page, you must include REPORT _HEADER or COLUMN _HEADER as
part of the print list for the AT TOP OF PAGE statement.

Example: Produce the salary report for Bock's yachts without a title page, but
with the report heading: ((SALARY REPORT FOR BOCK'S YACHTS", surrounded by asterisks. Include the date and page number, as well as the appropriate column headings:
DTR> @PGHEAD(@)
READY PERSONNEL
RE PORT PERSONNEL WITH DE PT = II D98 II, II E46 II, II T32 II
SET COLUMNS_PAGE = 70
AT TOP OF PAGE PRINT REPORT_HEADER, SKIP 2,
COL 20, * * * * * *. * * * * * * * * * * * * * II ,SK I P ,
COL 20, * , COL 56, II * II, SK I P ,
COL 20, * , COL 56, II * II, SK I P ,
COL 20, * , COL 32, IISALARY REPORT", COL 56, "*",
COL 20, * , COL 56, "* II, SK I P ,
COL 20, * , COL 30, IIFOR BOCK'S YACHTS" ,COL 56, "*",
COL 20, * , COL 56, "*", SK I P ,
COL 20, * , COL 56, "* II, SK I p, COL 20,

"* * * * * * * * * * * * * * * * * * *",

SKIP 3, COLUMN_HEADER
PRINT ID, STATUS, FIRST_NAME::" ":LAST_NAME ("NAME"),
DEPT, SALARY
END_REPORT

3-12

Mastering Report Writing Techniques

29-Jul-83
Pa!:te

1

)
* * * * * * * * * * * * * * * * * * *
*
*
*
*
SALARY REPORT
*
*
*
*
FOR BOCK'S YACHTS
*
*
*
*
*
*

* * * * * * * * * * * * * * * * * * *
ID
029a3
3aa56
38a62
38a65
39a85
a8a75
a8573
a98a3
8376a
8a375

STATUS
E>~ PER I ENCED
TRAINEE
E}'~ PER I ENCED
E>~PER I ENCED
E>~PER I ENCED
E>~ PER I ENCED
TRAINEE
TRAINEE
E>~ PER I ENCED
E}-{ PER I ENCED

NAME
CASS TERRY
HANK MORRISON
BILL SWAY
JOANNE FREIBURG
DEE TERRICK
GAIL CASSIDY
SY KELLER
BART HAMMER
JIM MEADER
MARY NALEl.IO

DEPT

SALARY

D98
T32
T32
Ea6
D98
Ea6
T32
D98
T32
D98

$29t908
$30tOOO
$5atOOO
$23t908
$55t829
$55ta07
$31 t5a6

$26t392
$a 1 t029
$56t8a7

DTR>

Note that the REPORT_HEADER print item produces both the date and page
number. Then, after skipping three lines, the Report Writer prints the special
heading as specified in the AT TOP OF PAGE statement. If the report had several pages, each successive page would have the special heading.
U sing REPORT _HEADER along with the AT TOP OF PAGE statement, you
could design a special billing form with the company heading, with labels for
charges and charge descriptions. If the data for each bill was in a single record,
you could include NEW _PAGE as the last print item in the PRINT statement.
Then each page would contain one customer's bill.
You could also apply this technique to duplicate an existing standard form.
Specify the appropriate character strings, column numbers, and 1ield values as
print list items. Finally, include NEW _PAGE as the last print list item.

3.3

Performing Cross Tabulations
Reports sometimes require totals of the fields within a detail line. For example,
for the domain YACHTS, the field DISPLACEMENT is related to the field
PRICE. You might want to design a report to print a detail line for each boat
showing builder, model, and price. Perhaps a buyer wants to know the individual

Mastering Report Writing Techniques

3-13

prices for a number of boats, the combined price for all the boats, and the price for
the boats after the next increase. To compute the scheduled new price, you need
to apply a price increase formula to each detail line.
Specify an additional print item for the detail line by indicating the formula for
the scheduled price increase. The Report Writer then produces a column of totals
for each row.
The following example uses the domain YACRTS.

Example: Bock's Yachts maintains pricing records for its semiannual increases.
Report on each boat's price, indicating the scheduled new price. Then, for the first
fifteen boats, calculate the total price and the total new price. Use the equation
(DISP/IO) + PRICE to find the new price. Compute the totals of the field values
with an AT BOTTOM OF REPORT statement.
Enter the steps for the report in a command file called PR.CMD. When you
execute the command file, you get this report:
DTR> @PR(ffi)
READY YACHTS
FIND FIRST 15 YACHTS WITH PRICE NE 0
[15 records found]
REPORT CURRENT
SET REPORT_NAME = "BOCK'S FAMOUS YACHTS"/
"SEMIANNUAL PRICE CATALOGUE"
SET COLUMNS_PAGE = 70
PRINT BUILDERt MODELt PRICEt COL 57t
(DISP/l0) + PRICE ("NEW PRICE") USING $$$t$$$
AT BOTTOM OF REPORT PR I NT SK I P 2 t COL 1 t "TOTAL:" t
TOTAL PRICE USING $$$t$$$t$$$t COL 5at
TOTAL «OISP/l0) + PRICE) USING $$$t$$$t$$$
END_REPORT
BOCK'S FAMOUS YACHTS
SEMIANNUAL PRICE CATALOGUE

MODEL

MANUFACTURER
ALBERG
ALBIN
ALBIN
ALBIN
AMERICAN
AMERICAN
BAYFIELD
BOMBAY
CAPE DORY
CAPE DORY
CAPE DORY
CARIBBEAN
CHALLENGER
CHALLENGER
CHALLENGER

TOTAL:
DTR>

3-14

Mastering Report Writing Techniques

37 MK I I
79
BALLAD
1.IEGA
2G
2G-MS
30/32
CLIPPER
25
28
TYPHOON
35
32
35
al

PRICE
$3Gt951
$17t900
$27t500
$18tGOO
$9t895
$18t895
$32t875
$28t950
$8t995
$21t990

18-Jan-8
Page 1

NEW PRICE
$38t951
$18 t320 '
$28t227
$19 tl07
$10t295
$19taa5

$33t825
$2at890

$9t395
$22t890

$at295

$ata85

$37t850
$31t835
$39t215
$51t228

$39tG50
$33tl15

$381 t97a

$397 t 188

$aOtG95

$53t898

An alternate solution is to edit the record definition and add a new COMPUTED
BY field, NEW _PRICE. Then include NEW _PRICE as one of the print items in
the PRINT statement. The following is a sample field definition:

)

10 NEW_PRICE COMPUTED BY
(DISP/10) + PRICE
EDIT_STRING IS

$$$t$$$.

Using a COMPUTED BY field saves typing if you need the value for the new
price in several different reports. Then if the formula changes, you have to
change it only in the record definition.

3.4

Reporting Hierarchical Records
A hierarchical record is a record that contains a list. The list field uses an
OCCURS clause to specify the number of items in the list. Each list item is subordinate to the list field, on a lower logical level than the other fields of the record.
Figure 3-1 illustrates the structure of the hierarchical record FAMILY _REC.
01 FAMILY
03 PARENTS
06 FATHER

03 NUMBER_KIDS

I

06 MOTHER

03 KIDS
OCCURS 0 TO 10 TIMES
DEPENDING ON NUMBER_KIDS
06 EACH_KID
09 KID_NAME

I

09AGE

I

09 AGE

I

09 AGE

06 EACH_KID
09 KID_NAME

06 EACH_KID
09 KID_NAME

Figure 3-1: Field Structure of FAMILY _REC

The OCCURS clause of a hierarchical record designates either a fixed-length or a
variable-length list. For variable-length lists, the list field's definition includes
an OCCURS DEPENDING clause stating that the number of items in the list
depends on the value of another field. For example, the length of the KIDS list in
FAMIL Y _REC depends on the value stored in EACH_KID.

Mastering Report Writing Techniques

3-15

Here is the record definition for F AMIL Y _REC:
RECORD FAMILY_REC
USING
01 FAMILY.
03 PARENTS.
06 FATHER PIC X(10).
06 MOTHER PIC X(10).
03 NUMBER_KIDS PIC 99 EDIT_STRING IS Z9.
03 KIDS OCCURS 0 TO 10 TIMES DEPENDING ON NUMBER_KIDS.
06 EACH_KID.
09 KID_NAME PIC X(10) QUERY_NAME IS KID.
09 AGE PIC 99 EDIT_STRING IS Z9.

If you have a domain with hierarchical records, you may want access to individual items from the list to compare their values or to find associated values on a
table.
To provide DATATRIEVE with the proper context for each list item, you can use
nested FOR statements outside of the Report Writer.
To print the names of the children from FAMILIES, for instance, you cannot simply say PRINT KID_NAME. You must provide a context. In the following example the first FOR statement, FOR FIRST 3 FAMILIES, instructs DATATRIEVE
to process the first 3 records from FAMILIES one record at a time. The second
FOR statement, FOR KIDS, tells it to process the KIDS list for each family
record.
DTR>
DTR>
DTR>
CON>
CON>

READY FAMILIES(@)
SET NO PROMPT(@)
FOR FIRST 3 FAMILIES(@)
FOR KIDS(@)
PRINT KID_NAME(@)

KID
NAME
URSULA
RALPH
ANNE
JIM
ELLEN
DAl.,1I D
ROBERT
ANN
JEAN
DTR>

For more information on context in DATATRIEVE, see theDATATRIEVE-ll
User's Guide.

3~16

Mastering Report Writing Techniques

To list items from within the Report Writer, first form a collection of the records
you will use. In the PRINT statement, precede items from the list with ALL and
follow them with OF and an RSE specifying the source of the items:

)

DTR> READY FAMILIESOO)
DTR> FIND FAMILIESOO)
[14 records found]

DTR>
RW>
RW>
RW>

REPORTOO)
PRINT MOTHER, FATHER, ALL KID_NAME OF KIDSOO)
SET REPORT_NAME = IIANNUAL PICNIC ROSTERIlOO)
END_REPORTOO)
ANNUAL PICNIC ROSTER

MOTHER

FATHER

ANN

JIM

LOUISE

JIM

JULIE

JOHN

ELLEN
ANNE

JOHN
ARNIE

SARAH
ANNE

SHEARMAN
TOM

MERIDETH

BASIL

0101
RUTH

ROB
JEROME

BETTY

TOM

LOIS

GEORGE

SARAH

HAROLD

TRINITA

EDWIN

8-Mar-83
Pa!:te 1

KID
NAME
URSULA
RALPH
ANNE
JIM
ELLEN
DAI.lID
ROBERT
ANN
JEAN
CHRISTOPHR
SCOTT
BRIAN
DAI.I! 0
PATRICK
SUZIE
BEAU
BROOKS
ROBIN
JAY
WREN
JILL
ERIC
CISSY
NANCY
MICHAEL
MARTHA
TOM
JEFF
FRED
LAURA
CHARLIE
HAROLD
SARAH
ERIC
SCOTT

DTR>

Mastering Report Writing Techniques

3-17

If you were planning the games for the picnic, you might want a report of just the
kids between five and twenty years old. You could specify the report like this:
DTR> READY FAMILIESOO
DTR> FIND FAMILIES WITH ANY KIDS WITH AGE BT 5 AND 20(0)
[6 records found]

DTR>
RW>
RW>
RW>

REPORT CURRENTOO
PRINT ALL KID_NAME, AGE OF KIDS WITH AGE BT 5 AND 20(0)
SET REPORT_NAME = "SACK RACE CANDIDATES"OO)
END_REPORTOO)
SACK RACE CANDIDATES

5-Ma}'-83

Page 1

KID
NAME
URSULA
ROBERT
SUZIE
WREN
JILL
MICHAEL
ERIC
SCOTT

AGE
7
16
6
17

20
20
16
11

DTR>

Dividing data into groups, printing title pages, performing cross tabulations,
and reporting hierarchical records are some of the advanced Report Writer techniques you may want to use. If you wish to develop additional techniques of your
own, refer to theDATATRIEVE-ll Reference Manual for a summary of the syntax for Report Writer statements.

3-18

Mastering Report Writing Techniques

)

Data Files Supplied with DATATRIEVE-11

A

This appendix contains copies of the original data for the YAeRTS,
FAMILIES, and PERSONNEL domains. If the files you have in your directory
do not match these in any way, you may get different results from those
shown in the examples in this book. To display the data you have in your
files, just ready the domain and use the PRINT statement:
DTR> READY YACHTS
DTR> PRINT YACHTS

A.1

00)
00)

YACHTS Domain Data

MODEL

MANUFACTURER
ALBERG
ALBIN
ALBIN
ALBIN
AMERICAN
AMERICAN
BAYFIELD
BLOCK I •
BOMBAY
BUCCANEER
BUCCANEER
C&:C
CABOT
CAL
CAL
CAL
CAL
CAL
CAPE DORY
CAPE DORY
CAPE DORY
CAPITAL

37 MK I I
79
BALLAD
VEGA
2G
2G-MS
30/32

ao
CLIPPER
270
320
CORI.JETTE
3G
2-27
2-3a

29
3-30
35
25

28
TYPHOON
NEWPORT

RIG
KETCH
SLOOP
SLOOP
SLOOP
SLOOP
MS
SLOOP
SLOOP
SLOOP
SLOOP
SLOOP
SLOOP
SLOOP
SLOOP
SLOOP
SLOOP
SLOOP
SLOOP
SLOOP
SLOOP
SLOOP
SLOOP

LENGTH
OI.lER
ALL
37
2G
30
27
2G
2G
32
39
31
27
32
31
3G
27
33
29
30
35
25
28
19
28

WEIGHT

BEAM

PRICE

20tOOO
at200
7t27G
5t070
atOOO
5t500
9t500
18t500
9taOO
5tOOO
12t500
8tG50
15tOOO
Gt700
9t500
8tOOO
10t500
15tOOO
atOOO
9tOOO
1 t900
7tOOO

12
10
10
08
08
08
10
12
11
08
10
09
12
09
10
09
10
11
07
09
OG
09

$3Gt951
$17t900
$27t500
$18tGOO
$9t895
$18t895
$32t875
$23t950

$8t995
$21 t990
$at295

A-1

MANUFACTURER
CARIBBEAN
CHALLENGER
CHALLENGER
CHALLENGER
CHRIS-CRAF
COLUMBIA
COLUMBIA
COLUMBIA
DOUGLAS
DOWN EAST
DOWN EAST
DUFOUR
EASTWARD
ENCHILADA
ENDEAI.IOUR
ERICSON
ERICSON
FISHER
FISHER
FJORD
GRAMPIAN
GRAMPIAN
GRAMPIAN
GRAMPIAN
GRAMPIAN
GULFS TAR
HUNTER
HUNTER
I • TRADER
IRWIN
IRWIN
IRWIN
IRWIN
ISLANDER
ISLANDER
ISLANDER
ISLANDER
ISLANDER
LINDSEY
MARIEHOLD
METALMAST
MOODY
NAUTOR
NEWPORT
NEWPORT
NEWPORT
NICHOLSON
NORTHERN
NORTHERN
O'DAY
O'DAY
OLYMPIC
ONTARIO
ONTARIO
PACESHIP
PEARSON
PEARSON
PEARSON
PEARSON
PEARSON
PEARSON

A-2

MODEL
35
32
35
41
CARIBBEAN
35
41
PAYNE 8.6
32
32
38
25
HO
20
32,
23/ SPECIA
CRUISING/3
30
37
MS 33
2-34
26
28
30
311
41
27
30
37
25
30
37 MARK I I
HALF TON
28
30
36
BAHAMA
FREEPORT
38
32
GALA~~PERIENCED

E}-( PER I ENCED
E}-( PER I ENCED
TRAINEE
TRAINEE
TRAINEE
E>~ PER I ENCED
E>~ PER I ENCED
E}-( PER I ENCED
E>~ PER I ENCEo
TRAINEE
E}-( PER I ENCED
TRAINEE
E}-( PER I ENCED
E}-( PER I ENCED
E>~ PER I ENCED
E>~ PER I ENCED
E}-( PER I ENCED
TRAINEE
E>~ PER I ENCED
E}-( PER I ENCED
TRAINEE
EXPERIENCED

FIRST
NAME

LAST
NAME

DEPT

CHARLOTTE
FRED
CASS
JEFF
THOMAS
HANK
BILL
JOANNE
DEE
GAIL
SY
DAN
BART
LYDIA
JIM
MARY
LOUISE
ANTHONY
NATHANIEL
DAI,l!D
BRUNO
STAN
RANDY

SPIVA
HOWL
TERRY
TASHKENT
SCHWEIK
MORRISON
SWAY
FREIBURG
TERRICK
CASSIDY
KELLER
ROBERTS
HAMMER
HARRISON
MEADER
NALEI,'o
DEPALMA
IACoBoNE
CHoNTZ
LITELLA
DoNCH I K0 1,'
WITTGEN
PoDERESIAN

TOP
F11
088
[:82
F11
T32
T32
E46
088
E46
T32
C82
088
Fii
T32
088
G20
C82
F11
G20
C82
G20
C82

Data Files Supplied with DATATRIEVE-11

START
DATE
12-Sep-72
8-Apr-76
2-Jan-80
4-Apr-81
7-Nol.l-81
1-Mar-82
5-Ma}'-80
20-Feb-80
2-Ma}'-77
2-Ma}'-78
2-Aus'-81
7-Jul-78
4-Aus'-81
18-Jun-78
4-Apr-80
3-Jan-76
28-Feb-78
2-Jan-73
28-Jan-82
i1-Nol.l-80
8-Aus'-78
23-Dec-81
24-Ma}'-78

SALARY
$75,882
$58,584

$28,808
$32,818
$26,723

$30,000
$54,000
$23,808
$55,828

$55,407
$31 1546
$41 1385
$26,382

$40,747
$41 1028
$56,847
$57,588
$58,462

$24,502
$34,833
$35,852

$25,023
$33,738

SUP
10
00012
00012
38485
87465
00881
87288
00012
48475
00012
00012
87288
87465
38485
00881
87288
38485
00012
00012
00881
87288
87465
87288
87465

Index

A

D

AT BOTTOM statement (Report Writer)
OF field-name, 2-17, 3-3, 3-8 to 3-9
OF PAGE, 2-17
OF REPORT, 2-17, 2-18, 3-14
AT TOP statement (Report Writer)
OF field-name, 3-3
OF PAGE, 2-17, 3-10 to 3-13
OF REPORT, 2-17
AVERAGE statistical function, 1-9,2-17
to 2-18

Dates
suppressing, 2-10
DEFINE PROCEDURE command, 1-6
Detail lines, 2-10 to 2-17
content, 2-11 to 2-12
format, 2-12 to 2-15
Displaying reports, 1-4

c
Column headers, 2-10, 2-15 to 2-17
specifying, 2-16 to 2-1 7
suppressing, 2-15
wrapping, 2-13
COLUMN_HEADER, 3-12
Command files, 2-18 to 2-19
Concatenated expressions, 3-4
Control groups, 3-2 to 3-9
levels of, 3-4 to 3-8
sort keys, 3-2 to 3-8
without sort keys, 3-8
COUNT statistical function, 1-9, 2-17 to
2-18
Cross tabulations, 3-13 to 3-14

E
Edit strings, 2-14 to 2-15
text edit strings, 2-15
Elementary fields, 2-11
END_REPORT statement (Report
Writer), 1-4, 1-5, 1-7

F
Field values
in detail lines, 2-11 to 2-12
FIND statement, 2-2
FINISH command, 1-7
FOR statement, 3-16
Form feed
trailing, 2-3
Formatting output
default, 2-2, 2-4
report header, 2-7
reports, 1-4

Index-1

G
Group fields, 2-11

H
Hierarchical records, 3-15 to 3-18
Hyphen (-), 2-15, 2-16

Prompting value expressions, 1-6 to 1-7,
2-12
as print item, 2-11
for page width, 2-5
for report length, 2-6
Prompts
RW>, 1-5

R
Invoking
procedures, 1-7

L
Lists
printing, 3-17 to 3-18
Literals, 2-12
in detail lines, 2-11

M
MAX statistical function, 2-18 to 2-19
MIN statistical function, 2-18 to 2-19

N
Naming reports, 1-4
NEW_PAGE, 3-10, 3-13

o
OCCURS clause, 3-15

p
Page format, 2-4 to 2-7
length, 2-6
width, 1-6, 2-2, 2-5
Page numbers, 2-7
suppressing, 2-10
Print items
column position of, 2-13 to 2-14
cross tabulations, 3-14
edit string format, 2-14 to 2-15
order of, 2-13
PRINT statement (Report Writer), 1-3,
1-3, 1-4, 2-1
detail lines, 2-11
order of print items, 2-13
Procedures
for reports, 2-19

Index-2

READY command, 2-2
Report header, 2-7 to 2-10
REPORT statement, 1-4, 1-5, 2-1, 2-2
to 2-3
identifying data, 2-2
selecting output medium, 2-19 to 2-21
default, 2-20
file, 2-20
printer, 2-20
prompt option, 2-20
terminal, 2-20
Report Writer
invoking, 1-5, 2-2 to 2-3
REPORT_HEADER, 3-12, 3-13
Reports
cross tabulations, 3-13 to 3-14
dating, 2-7, 2-9
designing, 2-1 to 2-21
hierarchical records, 3-15 to 3-16
naming, 2-1, 2-7
page numbers, 2-7
periodic, 1-1
query, 1-1
sample, 1-2
special page headings, 3-12 to 3-13
specification, 1-4 to 1-5, 2-1 to 2-2
title page, 3-10 to 3-12

s
Sample report, 1-2
Saving reports
using command files, 1.;.-7 to 1-8
using procedures, 1-6 to 1-7
SET NO PROMPT command, 1-3
SET statement (Report Writer), 1-4
COLUMNS_PAGE, 2-2, 2-5
DATE, 2-9
LINES_PAGE, 2-5 to 2-6
MAX_LINES, 2-6 to 2-7
MAX_PAGES, 2-6 to 2-7
NO DATE, 2-10
NO NUMBER, 2-10
REPORT_NAME, 2-2, 2-7, 2-7 to 2-9

SHOW FIELDS command, 1-5
Slash (/), 2-8, 2-16
Sort keys, 3-2 to 3-8
multiple, 3-4
SORTED BY clause, 3-2 to 3-8
SPACE, 2-13,2-14
Special page headings, 3-12 to 3-13
Statistical functions, 1-8 to 1-9, 2-12,
2-17 to 2-19
AVERAGE, 1-8, 2-17
COUNT, 1-8, 2-17
MAX, 1-8, 2-18
MIN, 1-8, 2-18
TOTAL, 1-8,2-17
SUM statement, 1-3, 1-3 to 1-4
Summaries
group, 3-8 to 3-9
Summarizing data, 2-17 to 2-19
Summary lines, 1-8 to 1-9, 2-17 to 2-19
Summary statistics, 1-8 to 1-9

T
T (text)
edit string character, 2-15
TI
for output to terminal, 2-20
Title page, 3-10
TOTAL statistical function, 2-17 to 2-18

u
USING clause, 2-12, 2-14 to 2-15

v
Val ue expressions
in detail lines, 2-11, 2-12
prompting, 1-6 to 1-7
Variables, 2-12
in detail lines, 2-11

Index-3

HOW TO ORDER ADDITIONAL DOCUMENTATION
DIRECT TELEPHONE ORDERS
In Continental USA
and Puerto Rico
call 800-258-171 0

In Canada
call 800-267-6146

In New Hampshire,
Alaska or Hawaii
call 603-884-6660

DIRECT MAIL ORDERS (U.S. and Puerto Rico*)
DIGITAL EQUIPMENT CORPORATION
P.O. Box CS2008
Nashua, New Hampshire 03061

DIRECT MAIL ORDERS (Canada)
DIGITAL EQUIPMENT OF CANADA LTD.
940 Belfast Road
Ottawa, Ontario, Canada K1 G 4C2
Attn: A&SG Business Manager

INTERNATIONAL
DIGITAL EQUIPMENT CORPORATION
A&SG Business Manager
c/o Digital's local subsidiary
or approved distributor

Internal orders should be placed through the Software Distribution Center (SOC), Digital
Equipment Corporation, Northboro, Massachusetts 01532
*Any prepaid order from Puerto Rico must be placed
with the Local Digital Subsidiary:

809-754-7575

)
Reader's Comments

DATATRIEVE-11
Guide to Writing Reports
AA-U051A-TK

Note: This form is for document COITlments only. DIGITAL will use comments submitted on this

form at the company's discretion. If you require a written reply and are eligible to receive
one under Software Performance Report (SPR) service, submit your comments on an SPR
form.
Did you find this manual understandable, usable, and well-organized? Please make suggestions
furimprovement. _______________________________________________________________

Did you find errors in this manual? If so, specify the error and the page number. _______

Please indicate the type of user/reader that you most nearly represent.

o
o

o
o
o
o
Name

Assembly language programmer
Higher-level language programmer
Occasional programmer (experienced)
User with little programming experience
Student programmer
Other (please specify) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __
Date ________________________________

Organization ________________________________________________________________
Street _______________________________________________________________________
City __________________________________ State _________ ZiporCode
Country

------Do Not Tear· Fold Here and T a p e ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ,

111111

No Postage
Necessary
if Mailed in the
United States

BUSINESS REPLY MAIL
FIRST CLASS PERMIT NO.33 MAYNARD MASS.
POSTAGE WILL BE PAID BY ADDRESSEE

ATTN: DISG Documentation ZK02-2/N53
DIGITAL EQUIPMENT CORPORATION
110 SPIT BROOK ROAD
NASHUA, N.H. 03062

-------Do Not Tear· Fold Here and Tape - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Update Notice #1
November 1987

DATATRIEVE-11
Guide to Writing Reports
AO-U051A-T1

)

Copyright © 1987 by Digital Equipment Corporation.
All Rights Reserved.

New and Changed Information

This update contains changes and additions made to the
DATATRIEVE-ll Guide to Writing Reports for Version 3.2.

)

Instructions

Place the enclosed pages in the DATATRIEVE·ll Guide to Writing
Reports Version 3 as replacements for or additions to cu~rent pages.
Change bars on replacement pages indicate changed text. For new
pages and pages where most of the text has been substantially
revised, no change bars are used. Instead, only the Version 3.2
release date is shown on the botton1 corner of the page.

;'

Old Page

New Page

Title Page/Copyright
How to Order
Reader's Comments/Mailer

Title Page/Copyright
How to Order
Reader's Comments/Mailers

DATATRIEVE-11
Guide to Writing Reports
Order No. AA-UOS1 A-TK

Including AD-UOS1A-T1

November 1987
This manual describes the DATATRIEVE-ll Report Writer.

OPERATING SYSTEMS:

RSX-IIM
RSXIIM-PLUS
RSTS/E
Micro/RSX
Micro/RSTS
VMS with RSX-ll

SOFTWARE VERSION:

DATATRIEVE-ll V3.2

digital equipment corporation, maynard, massachusetts

The information in this document is subject to change without notice and should
not be construed as a commitment by Digital Equipment Corporation. Digital
Equipment Corporation assumes no responsibility for any errors that may
appear in this document.
The software described in this document is furnished under a license and may be
used or copied only in accordance with the terms of such license.
No responsibility is assumed for the use or reliability of software on equipment
that is not supplied by DIGITAL or its affiliated companies.

Copyright © 1983, 1987 by Digital Equipment Corporation. All Rights Reserved.

The postage-paid Reader's Comments forms at the end of this document request
your critical evaluation to assist us in preparing future documentation.

The following are trademarks of Digital Equipment Corporation:

~D~DD~D

TM

ACMS
CDD
DATATRIEVE
DEC
DEC net
DECUS
Micro/RSTS
Micro/RSX

MicroVAX
MicroVMS
PDP
RALLY
Rdb/ELN
Rdb/VMS
ReGIS
RSTS
RSX
TDMS

TEAMDATA
UNIBUS
VAX
VAXcluster
VAXinfo
VAX Information Architecture
VAXNMS
VMS
VT

How to Order Additional Documentation

/

If you live in:

Call:

or Write:

New Hampshire,
Alaska

603-884-6660

Digital Equipment Corp.
P.O. Box CS2008
Nashua, NH 03061-2698

Continental USA,
Puerto Rico, Hawaii

1-800-258-1710

Same as above.

Canada
(Ottawa-Hull)

613-234-7726

Digital Equipment Corp.
940 Belfast Road
Ottawa, Ontario K1G 4C2
Attn: P&SG Business
Manager or approved
distributor

Canada
(British Columbia)

1-800-267-6146

Same as above.

Canada
(All other)

112-800-267 -6146

Same as above.

All other areas

Digital Equipment Corp.
Peripherals & Supplies
Centers
P&SG Business Manager
c/o DIGITAL's local
subsidiary

Note: Place prepaid orders from Puerto Rico with the local DIGITAL subsidiary (phone 809-754-7575).

Place internal orders with the Software Distribution Center, Digital Drive,
Westminster, MA 01473-0471.

)

Reader's Comments

DATATRIEVE-11

Guide to Writing Reports
AA-U051 A-TK
Including: AO-U051 A-T 1

Please use this postage-paid form to comment on this manual. If you require a written reply to a software
problem and are eligible to receive one under Software Performance Report (SPR) service, submit your
comments on an SPR form.
Thank you for your assistance.

I rate this manual's:

)

Accuracy (software works as manual says)
Completeness (enough information)
Clarity (easy to understand)
Organization (structure of subject matter)
Figures (useful)
Examples (useful)
Index (ability to find topic)
Page layout (easy to find information)

Excellent

Good

Fair

Poor

D
D
D
D
D
D
D
D

D
D
D
D
D
D
D
D

D
D
D
D
D
D
D
D

D
D
D
D
D
D
D
D

I would like to see more/less

What I like best about this manual is

"1

What I like least about this manual is

I

I found the following errors in this manual:
Page

Description

Additional comments or suggestions to improve this manual:

I am using Version _ _ _ of the software this manual describes.

Name/Title

Dept.
Date

Company

\

)

Mailing Address
Phone

Do Not Tear - Fold Here and Tape

----------------------lr-------;~;;~--if Mailed
in the
United States

BUSINESS REPLY MAIL
FIRST CLASS PERMIT NO. 33 MAYNARD MASS.
POSTAGE WILL BE PAID BY ADDRESSEE

DIGITAL EQUIPMENT CORPORATION
Corporate User Publications-Spit Brook
ZK01-3/J35
110 SPIT BROOK ROAD
NASHUA, NH 03062-9987

11111.1111. 1111 •• 1111 •• 1. 11.1111.111 1111. 111.1.11111
.- Do Not Tear - Fold Here

Reader's Comments

DATATRIEVE-11
Guide to Writing Reports
AA-U051 A-TK
Including: AO-U051 A-T1

Please use this postage-paid form to comment on this manual. If you require a written reply to a software
problem and are eligible to receive one under Software Performance Report (SPR) service, submit your
comments on an SPR form.
Thank you for your assistance.

I rate this manual's:

)

Accuracy (software works as manual says)
Completeness (enough information)
Clarity (easy to understand)
Organization (structure of subject matter)
Figures (useful)
Examples (useful)
Index (ability to find topic)
Page layout (easy to find information)

Excellent

Good

Fair

Poor

D
D
D
D
D
D
D
D

D
D
D
D
D
D
D
D

D
D
0
D
D
D
D
D

D
D
D
D
D
D
D
D

I would like to see more/less

What I like best about this manual is

\~

What I like least about this manual is

I

I found the following errors in this manual:
Page

Description

Additional comments or suggestions to improve this manual:

I am using Version _ _ _ of the software this manual describes.

Name/Title

Dept.

Company

Date

Mailing Address
Phone

Do Not Tear - Fold Here and Tape

-------------------n-llr-------~~;:;~---

II

BUSINESS REPLY MAIL
FIRST CLASS PERMIT NO. 33 MAYNARD MASS.
POSTAGE WILL BE PAID BY ADDRESSEE

DIGITAL EQUIPMENT CORPORATION
Corporate User Publications-Spit Brook
ZK01-3/J35
110 SPIT BROOK ROAD
NASHUA, NH 03062-9987

11111.1111. 1111 •• 1111 •• 1. 11.1 •• 1.1 •• 1•• 1. I••• 1.11 .. I
-- Do Not Tear - Fold Here

if Mailed
in the
United States



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.3
Linearized                      : No
XMP Toolkit                     : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:56:37
Create Date                     : 2011:10:21 14:14:30-08:00
Modify Date                     : 2011:10:21 15:02:13-07:00
Metadata Date                   : 2011:10:21 15:02:13-07:00
Producer                        : Adobe Acrobat 9.46 Paper Capture Plug-in
Format                          : application/pdf
Document ID                     : uuid:9d38439f-2cfe-48a0-9f5c-2b35a033ea01
Instance ID                     : uuid:548ad4f0-ba73-4cc1-a2ce-e52b28596358
Page Layout                     : SinglePage
Page Mode                       : UseNone
Page Count                      : 80
EXIF Metadata provided by EXIF.tools

Navigation menu