Reporting from a Dataset [ Getting Started With TRANSACT V ] MPE/iX 5.0 Documentation
Getting Started With TRANSACT V
Reporting from a Dataset
The first program we look at is a simple, three-line program to report
the contents of a dataset. Then we will expand this program and give it
many more capabilities as the section progresses. However, this should
not be viewed as implying that Transact is a report writer. Transact's
power lies in several areas: it provides a high-level interface for
database and file access, a high level interface with VPLUS for online
database updating, and an automatic error handling facility that makes
prototyping of a system possible in a very short time frame.
In addition, when Transact is interfaced with Report/V, it is possible to
write complex reports that no nonprocedural report writer can do. The
procedural power of Transact is used to retrieve and manipulate the data
and then Report is used to format the data and provide summarization as
necessary. We will see an example of that later on.
Getting a Complete Listing
One of the simplest tasks to perform with TRANSACT is to display the
contents of a data set. The three-line program shown in Figure 1-2 lists
the contents of a data set called customer.
_____________________________________
| |
| 1 system ex1,base=orders; |
| 2 list(auto) customer; |
| 3 output(serial) customer;|
_____________________________________
Figure 1-2. Program to display a dataset
1 The first statement in a Transact program is always a SYSTEM
statement, in which we give a name to the current program and
identify the database (and other files) to be used by the
program. In this example, the program is called EX1. This is
the name we will provide to Transact when we want to run the
program. We also tell Transact that our Image database is named
ORDERS.
2 The Image dataset that we want to list is called customer. We
don't need to tell Transact what data elements are in the
dataset. LIST(AUTO) instructs TRANCOMP to go to the dictionary
and extract the names of all the data elements for the named
dataset. Appendix G lists the data element or item content of
each dataset and file used throughout this manual, and also
displays a diagram that shows the relationship of the sets.
In this example, the LIST(AUTO) statement is equivalent to
individually listing each of the data elements as in:
list cust-no:
name:
street-addr:
city-state:
zipcode;
A statement is terminated with a semicolon. Within the
statement, item names are separated by colons.
3 The OUTPUT verb sets up a data retrieval and reporting loop; the
(SERIAL) option specifies that the customer set be read serially
and that each item of each record be retrieved and reported.
The output from this program might look like the report below.
______________________________________________________________________________
| |
| CUST-NO: NAME: STREET-ADDR: CITY-STATE: |
| ZIPCODE: |
| 1 Able-1 Answering 2775 Park Av San Jose, Ca |
| 95111 |
| 2 Grand Depression 27 E Main Santa Clara, Ca |
| 95122 |
| 3 Rummage Palace 410 N 10th South Bend, Ind. |
| 49146 |
| 4 Victorian Antiques 476 S 1st San Francisco, Ca.|
| 94123 |
| 5 Vinicator Corp 1092 Steward Drive San Jose, Ca |
| 95144 |
| 7 Frank Leary Racing 590 Laurelwood Mountain View, Ca.|
| 92123 |
| 8 Professor Muldoon's 123 Main Street Balloon City, Md |
| 12465 |
| 9 Bayliner Boats 1548 Maple San Jose, Ca. |
| 95144 |
| 20 Natkin & Co 807 Aldo Av Redwood City, Ca. |
| 93144 |
| |
| |
| CONTINUE(Y/N)> N |
______________________________________________________________________________
Figure 1-3. Report from a single dataset
Transact recognizes that our output is going to a terminal screen which
can hold 24 lines, each 80 characters long. Since the output is wider
then 80 characters, the last column of the report is on a second line.
If we had directed Transact to send our output to a 132 column printer,
then all the data would appear on a single line.
After a full screen of the report is displayed on the terminal, Transact
pauses, waiting for us to tell it to continue. If we direct output to a
printer, the report is generated without any pauses between pages. Also,
the report page length is adjusted to the length of a page on the
printer.
From the above example, we can see that Transact provides a simple format
by default. First, Transact reserves a column for each of the data
elements in our report. It makes the column either the width of the name
of the data element or the actual element length, whichever is longer.
It adds one blank space between the columns. It makes up column headings
by using the names of the data elements.
Later on we will see examples of how we can control the format ourselves.
MPE/iX 5.0 Documentation