Easytrieve Manual
Easytrieve Manual
Easytrieve Manual
Application Guide
6.3
R0J7E863AGE
Release 6.3, February 2001
This documentation and related computer software program (hereinafter referred to as the “Documentation”) is for
the end user’s informational purposes only and is subject to change or withdrawal by Computer Associates
International, Inc. (“CA”) at any time.
TO THE EXTENT PERMITTED BY APPLICABLE LAW, CA PROVIDES THIS DOCUMENTATION “AS IS”
WITHOUT WARRANTY OF ANY KIND, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. IN NO EVENT
WILL CA BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR DAMAGE, DIRECT OR
INDIRECT, FROM THE USE OF THIS DOCUMENTATION, INCLUDING WITHOUT LIMITATION, LOST
PROFITS, BUSINESS INTERRUPTION, GOODWILL OR LOST DATA, EVEN IF CA IS EXPRESSLY ADVISED OF
SUCH LOSS OR DAMAGE.
THE USE OF ANY PRODUCT REFERENCED IN THIS DOCUMENTATION AND THIS DOCUMENTATION IS
GOVERNED BY THE END USER’S APPLICABLE LICENSE AGREEMENT.
Provided with “Restricted Rights” as set forth in 48 C.F.R. Section 12.212, 48 C.F.R. Sections 52.227-19(c)(1) and (2) or
DFARS Section 252.227.7013(c)(1)(ii) or applicable successor provisions.
Ó 1996-2001 Computer Associates International, Inc., One Computer Associates Plaza, Islandia, New York 11749. All
rights reserved.
All trademarks, trade names, service marks, or logos referenced herein belong to their respective companies.
Contents
Chapter 2: Overview
Introduction .................................................................................. 2–1
Capabilities ............................................................................... 2–1
Application ............................................................................... 2–2
Structure ..................................................................................... 2–7
Environment Definition Section ............................................................. 2–8
Library Section ............................................................................ 2–8
Activity Definition Section ................................................................. 2–8
Rules of Syntax .............................................................................. 2–10
Statement Structure ...................................................................... 2–10
Words................................................................................... 2–11
Comments ............................................................................... 2–12
Continuations ............................................................................ 2–13
Environment Definition ................................................................... 2–13
PARM Statement ......................................................................... 2–13
SYNTAX Parameter ...................................................................... 2–14
COMPILE Parameter ..................................................................... 2–14
Contents iii
Chapter 3: Library
Introduction ................................................................................. 3–1
FILE Statement ............................................................................... 3–2
File-type Parameters ...................................................................... 3–4
Device-type Parameters ................................................................... 3–5
Record Format Parameters ................................................................. 3–6
DEFINE Statement............................................................................ 3–8
Field-name Parameter ..................................................................... 3–9
Location Parameter ....................................................................... 3–9
Attributes Parameter ..................................................................... 3–10
MASK Parameter ........................................................................ 3–12
VALUE Parameter ....................................................................... 3–14
Contents v
Coding Techniques ...................................................................... 8–17
Special-name Report Procedures .......................................................... 8–18
REPORT-INPUT ......................................................................... 8–20
BEFORE-LINE and AFTER-LINE .......................................................... 8–20
BEFORE-BREAK ........................................................................ 8–21
AFTER-BREAK .......................................................................... 8–22
ENDPAGE .............................................................................. 8–22
TERMINATION ......................................................................... 8–22
Contents vii
Chapter 14: Applications
Introduction ................................................................................ 14–1
Application Overview .................................................................... 14–1
Program Formatting Standards............................................................ 14–2
Program Output Standards ............................................................... 14–2
Inventory Sample File .................................................................... 14–3
Personnel Sample File .................................................................... 14–4
Contents ix
Appendix B: Cross-References
Cross-Reference of Statement .................................................................. B–1
Index
This guide covers a subset of CA-Easytrieve Plus statements. The statements are
described briefly, along with the associated parameters.
Organization
This guide is organized into four major divisions:
■ CA-Easytrieve Plus statements (grouped by functional requirements) and
report and file processing
■ Examples of report types which are common to many different businesses
■ CA-Easytrieve Plus statements covered in this guide in a condensed, tabular
form for easy reference
■ A cross-reference of CA-Easytrieve Plus statements by the examples
described in earlier chapters
Title Description
CA-Easytrieve Plus Reference Contains descriptions of all product features
Guide and functions and summaries of each
CA-Easytrieve Plus version.
CA-Easytrieve Plus Getting Describes the process of installing and tuning
Started the CA-Easytrieve Plus system.
CA-Easytrieve Plus User Guide Provides new users with the information they
need to become productive quickly. It includes
a six-lesson tutorial and a format designed to
make the material more interesting and easier
to comprehend.
CA-Easytrieve Plus Extended Describes support of extended reporting
Reporting Facility Guide capabilities for Impact Dot, Ink Jet, and Electro
Photographic printers.
CA-Easytrieve Plus Interface Short guides available for users of various
Option Guides system options. These consist of manuals for
IMS/DLI processing, CA-IDMS and IDD
processing, TOTAL processing, SQL
processing, CA-Datacom/DB processing,
SUPRA processing, and other CA-Easytrieve
Plus options.
CA-Easytrieve Plus Pocket A quick reference guide to all CA-Easytrieve
Reference Plus syntax.
Related Publications
The following publication, not produced by Computer Associates, is either
referenced in this publication or is recommended reading:
■ IBM IMS/DLI Applications Programming Manual
Documentation Conventions
The following conventions are used throughout this manual for illustrative
purposes.
Notation Meaning
{ braces } Mandatory choice of one of these entries.
[ brackets ] Optional entry or choice of one of these entries.
¦ (OR bar) Choice of one of these entries.
( parentheses ) Multiple parameters must be enclosed in parentheses.
... Ellipses indicate that you can code the immediately
preceding parameters multiple times.
CAPS All capital letters indicate a keyword, name, or field used in a
program example.
lowercase Lowercase letters represent variable information in statement
syntax. If the same variable types recur within a statement,
they are made unique by adding a numeric suffix, such as
literal-2.
Variable Parameters
Parameter Meaning
field-name Data field defined in your program.
file-name Unique file name defined in the library section of your
program.
index name Name of an INDEX data item.
integer Numeric literal (whole number greater than zero).
job-name Name a JOB activity.
letter Single alphabetic character, such as an edit mask identifier.
literal Text string enclosed in quotes or a numeric constant.
proc-name Name of a procedure.
program-name Name of a program written in a language other than CA-
Easytrieve Plus, such as COBOL or Assembler.
record-name Name of an IMS/DLI or CA-IDMS entity.
report-name Name of a REPORT.
Parameter Meaning
sort-name Name of a SORT activity.
Overview
2
Introduction
CA-Easytrieve Plus is an information retrieval and data management system
designed to simplify typical programming tasks. Almost any business-oriented
task can be accomplished using CA-Easytrieve Plus. It is simple enough for a
beginner to use without additional training, and sophisticated enough to enable a
data processing expert to perform complex tasks.
Capabilities
File Processing
■ Accepts any number of input files.
■ Processes SAM, ISAM, VSAM, or IMS/DLI files.
■ Allows fixed, variable, undefined, or spanned record formats.
■ Processes data in alphabetic, numeric, packed, packed-unsigned, or binary
format.
■ Searches files and performs logical data selection based on input or
calculation.
■ Edits and updates files.
■ Matches an unlimited number of files.
■ Creates subfiles containing selected records from a master file.
Overview 2–1
Introduction
Operations
■ Performs extensive computations through user logic; including percentages,
averages, and other calculations.
■ Sorts on any number of keys.
■ Calls your programs and subroutines written in other languages and
integrates them into the job.
Output
■ Outputs any number of files or reports on one pass of the input file(s).
■ Automatically formats output with all totals calculated internally.
■ Provides summary reports and output files with no limits on the number and
size of control break fields or total fields.
■ Makes it easy for you to define and print specially formatted output, such as
for W-2 forms, audit confirmations, labels, form letters, and preprinted
forms.
■ Permits you to vary page sizes within a report, and insert additional header
and footer information.
■ Enables you to write reports directly to microfiche.
Application
CA-Easytrieve Plus is designed to make it easy for you to manipulate files and
produce reports. It is suitable for beginners in data processing techniques
because it is easy to learn. The next exhibit presents a sample program which is
used throughout the following chapters of this guide to demonstrate the use of
CA-Easytrieve Plus statements. This sample program is contrived to exemplify a
large selection of CA-Easytrieve Plus statements.
Sample Program
1 PARM DEBUG(FLOW FLDCHK)
2 *
3 FILE PERSNL FB(150 1800)
4 NAME 17 16 A
5 LAST-NAME NAME 8 A
6 PAY-GROSS 94 4 P 2
7 DEPT 98 3 N
8 DATE-OF-HIRE 136 6 N
9 HIRE-MM DATE-OF-HIRE 2 N
10 HIRE-DD DATE-OF-HIRE +2 2 N
11 HIRE-YY DATE-OF-HIRE +4 2 N
12 SALARY W 4 P 2
13 BONUS W 4 P 2
14 RAISE W 4 P 2
15 SERVICE W 2 N
16 CURR-DATE S 6 N
17 CURR-MM CURR-DATE 2 N
18 CURR-DD CURR-DATE +2 2 N
19 CURR-YY CURR-DATE +4 2 N
20 *
21 FILE ERRPRINT PRINTER
22 *
23 JOB INPUT PERSNL
24 %GETDATE CURR-DATE
42 SALARY = PAY-GROSS * 52
43 PERFORM SERVICE-CALC
44 IF SERVICE LT 1
45 GO TO JOB
46 END-IF
47 PERFORM RAISE-CALC
48 BONUS = 0
49 IF SERVICE GT 14
50 PERFORM BONUS-CALC
51 END-IF
52 SALARY = SALARY + RAISE + BONUS
53 PRINT UPD-RPT
54 *
55 SERVICE-CALC. PROC
57 SERVICE = CURR-YY - HIRE-YY
58 IF CURR-MM < HIRE-MM
59 SERVICE = SERVICE - 1
60 END-IF
61 IF CURR-MM NE HIRE-MM
62 GOTO QUIT-SERV-CALC
63 END-IF
64 IF CURR-DD < HIRE-DD
65 SERVICE = SERVICE - 1
66 END-IF
67 QUIT-SERV-CALC
68 END-PROC
69 *
70 RAISE-CALC. PROC
72 IF DEPT LT 940
73 RAISE = SALARY * 0.1
74 ELSE
75 RAISE = SALARY * 0.15
76 END-IF
77 END-PROC
78 *
79 BONUS-CALC. PROC
81 IF SALARY GT 29999
82 DISPLAY ERRPRINT, LAST-NAME, +5, +
'INELIGIBLE FOR BONUS'
Overview 2–3
Introduction
83 GOTO QUIT-BONUS
84 END-IF
85 IF SERVICE GT 19
86 BONUS = 2000
87 ELSE
88 BONUS = 1000
89 END-IF
90 PRINT BONUSRPT
91 QUIT-BONUS
92 END-PROC
93 *
94 REPORT UPD-RPT PAGESIZE 51 LINESIZE 63 NODATE NOPAGE
95 SEQUENCE DEPT LAST-NAME
96 CONTROL DEPT
97 TITLE 1 'ANNUAL UPDATE REPORT - SALARIED EMPLOYEES'
98 HEADING LAST-NAME 'NAME'
99 HEADING SERVICE 'SERV'
100 LINE DEPT LAST-NAME SERVICE RAISE SALARY
101 *
102 REPORT BONUSRPT LINESIZE 60 NODATE NOPAGE
103 SEQUENCE DEPT LAST-NAME
105 TITLE 1 'ANNUAL BONUS REPORT - SENIOR EMPLOYEES'
106 LINE DEPT LAST-NAME SERVICE BONUS
107 *
The program illustrated in the above exhibit processes a Personnel Master File
named PERSNL that contains the department numbers, names, salaries, and
dates of hire of all employees in an imaginary company.
Six working storage fields contain the results of calculations used in the program
and printed on the resulting reports.
Finally, two reports are produced. The first presents a list of all salaried
employees, with the new values for length of service, amount of raise, and salary.
The second lists only those employees who received a bonus, their length of
service, and the amount of the bonus.
This type of file updating and reporting is a typical application for CA-Easytrieve
Plus. It illustrates many of the statements most commonly used. Portions of this
program are referenced throughout this Guide as the various statements and
operations are described in detail.
The two exhibits that follow illustrate the reports generated by the sample
program. The third exhibit illustrates the printout of the error file ERRPRINT.
Overview 2–5
Introduction
108,327.98 1080,388.14
Structure
A CA-Easytrieve Plus program can be composed of up to three sections: one is
optional, one is customary, and one is mandatory, as illustrated next.
Overview 2–7
Structure
This section is optional, and if used, must be the first section of your program. It
consists of the PARM statement which can be used to establish a customized
operating mode for the duration of your program.
Library Section
This section is also called the data definition section and is usually necessary for
file processing and report generation. It follows the PARM statement and
contains the FILE statement and field definitions. These statements describe the
data to be processed by your program and initialize the required working storage
(see the “Library” chapter). The library section of the sample program is
illustrated earlier in this chapter.
Your program can contain any number of JOB and SORT activities, in any order.
Within each of these activity types are statements, procedures, and subactivities
which specify the tasks your program intends to accomplish, as follows:
Procedures are discussed in the “Decision and Branching Logic” chapter. The
REPORT statement and associated declaratives and procedures are described in
the “Report Processing” chapter.
Overview 2–9
Rules of Syntax
Rules of Syntax
CA-Easytrieve Plus statements have a free-form, English-like structure and a
simple, consistent syntax which is easy to understand and remember.
Statement Structure
A statement area can contain more than one CA-Easytrieve Plus statement or, in
the case of continuations, a portion of a statement. In general, a CA-Easytrieve
Plus statement begins with a keyword and is terminated by a period or the end of
the statement area, whichever is first. This technique enables you to code more
than one statement in a statement area, or to continue a statement which is too
large for one statement area.
To enter multiple statements on one line, follow each statement with a period
and a space. The next statement is considered to begin in the next available
position after the space. For example:
A = 7. Y = 5. Z = X
Words
Statements are made up of one or more words. A word can be a keyword, a field
name (also called a data name), or a literal, described below. All words begin
with a nonblank character and are terminated either by the end of the statement
area or by one of the following word delimiters:
The basic word delimiter is the space. At least one space must follow all other
delimiters except the left parenthesis.
Keywords
Field Names
Overview 2–11
Rules of Syntax
A qualified field name consists of the qualifying word followed by a colon and
the field name. You can use any number of spaces, or no spaces, to separate the
colon from either the qualifying word or the field name.
For example:
PERSNL: SALARY
WORK:SALARY
FILEX : SALARY
Literals
Alphabetic literals can contain both letters and numbers, but the numbers are
treated the same as letters. For example:
'709 ENTERPRISE DR., OAK BROOK, ILL 60521'
The numbers 709 and 60521 are not numeric values on which an arithmetic
operation can be performed.
Comments
Continuations
The plus symbol indicates that the statement continues with the first nonblank
character in the next statement area (which could be in the first position); leading
blanks are ignored. For example, the LINE statement, which indicates the
contents of a report, is as follows:
LINE EMPLOYEE# NAME STREET CITY STATE ZIP TELEPHONE +
REGION DIVISION BRANCH GROSS NET DEDUCTIONS +
QUARTER YEAR-TO-DATE
Environment Definition
The environment under which your CA-Easytrieve Plus program runs can be
determined by one or more of three sources:
■ The options table established by your data center at installation. Normally,
the default setting of these options is used. The examples and instructions in
this guide assume that the defaults are in effect. If you get unexpected results
from your program, contact your data center to identify modified installation
options.
■ The optional PARM statement which overrides the options table. If used, it
must be the first statement in your program.
■ Parameters of the FILE, SORT, and REPORT statements which, when
specified, override the options table and the PARM statement.
PARM Statement
The parameters of the PARM statement provide a method for customizing the
operating environment for the duration of one program's compilation and
execution.
Overview 2–13
Rules of Syntax
SYNTAX Parameter
COMPILE Parameter
If you do not use the PARM statement, the default is syntax check, compile, and
execute.
Library
3
Introduction
The library section of your program describes the information that your program
processes. This description is in terms that CA-Easytrieve Plus can understand,
that is, files, records, and fields.
File
A file is a group of records whose attributes (such as the type of file, the type of
device on which it resides, and the format of its records) are provided in the FILE
statement parameters.
Record
Field
Library 3–1
FILE Statement
The next exhibit illustrates the library section of the Sample Program depicted in
the “Overview” chapter under the topic Application.
2 *
3 FILE PERSNL FB(150 1800)
4 NAME 17 16 A
5 LAST-NAME NAME 8 A
6 PAY-GROSS 94 4 P 2
7 DEPT 98 3 N
8 DATE-OF-HIRE 136 6 N
9 HIRE-MM DATE-OF-HIRE 2 N
10 HIRE-DD DATE-OF-HIRE +2 2 N
11 HIRE-YY DATE-OF-HIRE +4 2 N
12 SALARY W 4 P 2
13 BONUS W 4 P 2
14 RAISE W 4 P 2
15 SERVICE W 2 N
16 CURR-DATE S 6 N
17 CURR-MM CURR-DATE 2 N
18 CURR-DD CURR-DATE +2 2 N
19 CURR-YY CURR-DATE +4 2 N
20 *
21 FILE ERRPRINT PRINTER
22 *
FILE Statement
The FILE statement describes the files and/or the databases your program
references. This description is provided by parameters coded following the
keyword FILE. Not all parameters are used with any one file. The next exhibit
diagrams the most commonly used FILE parameters.
FILE file-name +
[SYSxxx] +
[ ]
[IS ]
File [VIRTUAL ]
Type ==> [DLI (dbdname [literal-1]) [ ] ] +
[VS ([ES] [PASSWORD 'literal-2'] [CREATE [RESET]]) ]
[ [UPDATE ] ]
[ [ ] ]
[ ]
[CARD ]
Device [PUNCH ]
Type ==> [PRINTER] +
[DISK ]
[TAPE ]
[ ]
[ ]
[F literal-3 ]
Record [V literal-3 ]
Format ==> [U literal-4 ]
[ { literal-4 } ] +
[FB (literal-3 { FULLTRK })]
[ { literal-4 } ]
[VB (literal-3 { })]
[ { FULLTRK } ]
[VBS (literal-3 { literal-4 })]
[ { FULLTRK })]
[ ]
[ [ ] ]
[TABLE [INSTREAM ] ]
[ [literal-5] ]
[ [ ] ]
File-name Parameter
FILE file-name
This is a name you give to each of your files. It is the only FILE statement
parameter which is mandatory under every circumstance. It must start with a
letter, can contain letters, numbers, and a few special characters and can be from
one- to eight-characters long (one to seven in VSE). Within your program, the
name of each file must be unique — no two files can have the same name.
In the FILE statement sample program (shown earlier), the input file-name is
PERSNL.
FILE PERSNL
This optional parameter establishes the logical unit assignments. Valid entries
are:
■ SYSLST
■ SYSPCH
■ SYSIPT
■ SYS000 through SYS240.
Check with your data processing department to learn if you must supply this
parameter.
Library 3–3
FILE Statement
File-type Parameters
[ ]
[IS ]
File- [VIRTUAL ]
type ==> [DLI (dbdname [literal-1]) [ ] ]
[ [CREATE [RESET]])]
[VS ([ES] [PASSWORD 'literal-2'] [ ] ]
[ [UPDATE ] ]
[ [ ] ]
This parameter specifies your file-type. If you do not supply it, CA-Easytrieve
Plus assumes that your file is sequentially ordered. If it is not, you must specify
this parameter to identify your file-type. This subject is covered in more detail in
the “File Processing” chapter. The file-types are:
File-Types Description
IS Indexed Sequential Access Method (ISAM)
VIRTUAL CA-Easytrieve Plus virtual file manager (VFM)
DL/I Designates an IMS/DLI database:
Dbd=name is alphabetic and names the Database Definition
(DBD) in the Program Specification Block (PSB) to be processed.
(See the “IMS/DLI Processing” chapter.)
Literal-1 is numeric and specifies the relative occurrence of the
desired DBD in the PSB.
VS Virtual Storage Access Method (VSAM):
ES - code this option to indicate that your file accesses as an
Entry Sequenced data set.
PASSWORD - literal-2 is an optional one- to eight-character
alphabetic or hexadecimal password for the VSAM file. Enclose
the literal in single quotes.
CREATE - code the CREATE option to load a VSAM file.
CREATE by itself implies a new file; include the RESET
subparameter to reload an existing file which has been defined
as reusable.
UPDATE - code the UPDATE option to update this file with the
PUT or WRITE statements.
Device-type Parameters
[ ]
[CARD ]
Device- [PUNCH ]
type =====> [PRINTER]
[DISK ]
[TAPE ]
[ ]
This optional parameter directs CA-Easytrieve Plus where to look for your file.
TAPE or DISK is for VSE only.
[CARD]
This option retrieves your file data from the system input stream (SYSIN for
OS/390, SYSIPT for VSE). If your operating mode is the default (syntax check,
compile, and execute), your file data must follow an END statement within your
program, as illustrated below.
Only one file in your program can use the CARD option; this file must contain
80-character unblocked records.
FILE PERSUPD CARD
JOB INPUT PERSUPD
...(Program) ...
REPORT NEW-RPT ...
...
END
... (Data Records) ...
[PUNCH]
The PUNCH option indicates punched card output. Files created with this option
are 80-character unblocked records.
[PRINTER]
The PRINTER option indicates print output files, referenced by the DISPLAY and
REPORT statements.
This option (required only for VSE) indicates the device on which your file
resides. Specify this option only if your file is on a device other than the default
established at installation.
Library 3–5
FILE Statement
This parameter is required for VSE programs, but not necessarily required for
OS/390 programs. CA-Easytrieve Plus obtains the record format from OS/390
when the file is opened. It can be useful in OS/390, however, for output files.
Record format codes are:
F = fixed unblocked
V = variable unblocked
U = undefined
FB = fixed blocked
VB = variable blocked
VBS = variable blocked spanned
The specified record length for a file with variable length records must include
four bytes for the Record Descriptor Word (RDW). If the file is blocked, the
specified block size must include an additional four bytes for the Block
Descriptor Word (BDW). This construction is illustrated next:
Note: A block size designation of FULLTRK specifies that the output block size
be set to the maximum track capacity of the disk or the next lower multiple of the
record size for FB files. For devices with track lengths greater than 32760,
FULLTRK indicates a block size of 32760.
TABLE
[ [INSTREAM ]]
[TABLE [ ]]
[ [literal-5]]
This option identifies a file that you are specifying as a table. The format of table
data must follow some strict rules, but its use is very efficient (see the “Table
Processing” chapter). The information in this file is accessed by the SEARCH
statement. The table data can reside within your program (INSTREAM), or you
can store it external to your program.
INSTREAM Tables
INSTREAM directs CA-Easytrieve Plus to look for the table data within your
program immediately following the associated FILE statement. This table is
created by coding the data at the same time you code your program; it is
established at the time your program is compiled. The size of an INSTREAM
table is limited only by the amount of available memory. Instream tables are very
useful for decoding information into a more usable format, such as printing
department names instead of department numbers on a report.
External Tables
If you specify the TABLE option with no subparameter, the file is an external
table whose maximum number of entries is limited by a value in the options table
established at installation. Check with your data center to determine this value.
If the number of entries in your external table is larger than the default value,
you can code literal-5 to specify the maximum number of entries. External tables
are established for use during initiation of the JOB activity that contains the
SEARCH statement which references them.
Library 3–7
DEFINE Statement
DEFINE Statement
The DEFINE statement (with or without the keyword DEFINE) describes data
fields within files or within working storage. Optionally, you can omit the
DEFINE keyword when the field definitions immediately follow the associated
FILE statement. The next exhibit illustrates the DEFINE statement.
There are three conditions which apply to data fields either in a file or within
working storage, as follows:
■ Any number of fields can be defined.
■ Field-names must be unique within a file or within working storage. There
can be no duplicates. The same field-name can be defined in multiple files.
■ A field must be DEFINEd before you can use it in your program.
{literal-1 }
Location ==> {field-name-2 [+nn]} +
{ }
{W }
{S }
{ {A} }
{ {N} }
Attributes ==> {literal-2 {P} [literal-3]} +
{ {B} }
{ {U} }
[VALUE literal-5]
Field-name Parameter
[DEFINE] field-name
This is the name you give to the field you are defining. It must start with a letter;
can contain letters, numbers, and special characters; and can be from 1 to 40
characters long.
Location Parameter
{literal-1 }
{field-name-2}
Location => { } [+nn]
{W }
{S }
This parameter identifies the location of the named field within a record or
identifies it as a working storage field. The codes to specify location are:
{literal-1}
Specifies the location of the file field's leftmost byte. It is the starting position of
this field relative to the first position of the record (position one (1)).
{field-name-2}
Specifies the location of the leftmost byte of a file field as the relative
displacement from the start of a previously defined field.
Library 3–9
DEFINE Statement
{W or S}
In the field definitions sample program (shown earlier), the first designation to
the right of the field-name is the location parameter. Four of the fields,
NAME, PAY-GROSS, DEPT, and DATE-OF-HIRE
are specified with a numeric value which indicates the starting position of each of
these fields relative to the beginning of the record.
Four fields,
LAST-NAME, HIRE-MM, HIRE-DD, and HIRE-YY
Six fields,
VAC-HRS, SALARY, BONUS, RAISE, SERVICE, and CURR-DATE
Attributes Parameter
{ {A} }
{ {N} }
Attributes ==> {literal-2 {P} [literal-3]}
{ {B} }
{ {U} }
This parameter is specified as three components: field length, data format and
number of decimal positions, if any. These values are interdependent in many
cases.
Specified by literal-2. This value is constrained by the associated data format. See
the Field Attribute Relationships table below.
Data Format
A - alphabetic. Use when none of the numeric data types apply to this field.
N - zoned decimal. The field contains digits 0 through 9 in external decimal form
(for example, 0 = X'FO').
P - packed decimal. The field contains numbers which meet IBM's definition of
internal packed decimal. For example, a two-byte packed field containing the
value 123 looks like X'123F'.
B - binary. The field contains binary data. Depending on their field length, binary
fields can contain values whose maximum is equivalent to the following number
of decimal digits:
U - unsigned packed decimal. It is the same as packed decimal, but with the sign
stripped off. A two-byte unsigned packed field containing the value 123 looks
like X'0123'. This lets you reference part of a packed field without allowing for its
sign position.
The following table delineates the relationship between field length, data format,
and the valid number of decimal positions for each field.
Library 3–11
DEFINE Statement
The field attribute specifications in the Sample Program Library Section, shown
earlier, can be read as illustrated in the following table.
Refer to the Sample Update Report in the “Overview” chapter, to see how the
data fits into these field attribute specifications.
MASK Parameter
MASK ([letter] [BWZ] [literal-4])
This optional parameter can specify a pattern (edit mask) for printing a numeric
field on a report. Alphabetic fields cannot be edited. The subparameters are:
[letter]
[BWZ]
BWZ (blank when zero) suppresses printing a numeric field when it contains all
zeros.
[literal-4]
Literal-4 is the print edit mask to use. It is an alphabetic literal created with a
combination of the following characters:
Character Description
9 Causes any digit to print.
Z Causes any digit except leading zeros to print.
* Causes an asterisk to replace leading zero digits.
- Causes a minus sign to print before the first or after the last digit
of a negative number.
$ Causes a currency symbol to print before the first nonzero digit.
X Permits any character to be printed with the edited data.
character
The system default masks for numeric fields with decimal positions are
illustrated next.
Number of
Decimals Mask
none ZZZZZZZZZZZZZZZZZZ *
0 ZZZ,ZZZ,ZZZ,ZZZ,ZZZ,ZZZ-
1 ZZ,ZZZ,ZZZ,ZZZ,ZZZ,ZZZ.9-
2 Z,ZZZ,ZZZ,ZZZ,ZZZ,ZZZ.99-
3 ZZZ,ZZZ,ZZZ,ZZZ,ZZZ.999-
4 ZZ,ZZZ,ZZZ,ZZZ,ZZZ.9999-
5 Z,ZZZ,ZZZ,ZZZ,ZZZ.99999-
6 ZZZ,ZZZ,ZZZ,ZZZ.999999-
7 ZZ,ZZZ,ZZZ,ZZZ.9999999-
8 Z,ZZZ,ZZZ,ZZZ.99999999-
9 ZZZ,ZZZ,ZZZ.999999999-
10 ZZ,ZZZ,ZZZ.9999999999-
11 Z,ZZZ,ZZZ.99999999999-
12 ZZZ,ZZZ.999999999999-
13 ZZ,ZZZ.9999999999999-
14 Z,ZZZ.99999999999999-
15 ZZZ.999999999999999-
16 ZZ.9999999999999999-
17 Z.99999999999999999-
18 .999999999999999999-
* For zoned decimal fields with no decimals, the default
mask is '999999999999999999'.
Library 3–13
DEFINE Statement
The next exhibit illustrates some print masks and their purposes.
Mask Use
VALUE Parameter
[VALUE literal-5]
For example, if you are defining an alphabetic field whose name is MONTH, and
you want to initialize it to the value JANUARY, your statement might read:
DEFINE MONTH W 10 A VALUE 'JANUARY'
where:
DEFINE is the keyword which identifies your statement
MONTH is the name of the field being defined
W is the location parameter = working storage
10 is the field length parameter = 10 bytes
A is the data format parameter = alphabetic
VALUE- specifies the initial contents of MONTH = JANUARY.
where:
DEFINE is the keyword
YEAR is your field-name
W locates your field in working storage
4 indicates a field length of 4 bytes
N specifies a zoned decimal data format
VALUE initializes field YEAR to 1999.
Activity Definition
4
Introduction
The activity definition section of your program contains the CA-Easytrieve Plus
statements that perform the tasks for which you created your program: reading
in, processing, and writing out data. These tasks are divided into two activity
types - JOB activities and SORT activities.
JOB Activities
JOB activities, identified by the JOB statement, read data from input files
described in the library section of your program. See the “Library” chapter.
Examine and manipulate this data as directed by CA-Easytrieve Plus statements,
and write data to output files and the appropriate report declaratives.
SORT Activities
SORT activities, initiated by the SORT statement, sequence files in the order
specified by parameters of this statement. These sequenced files can in turn be
processed by one or more JOB activities.
Note: You can code any number of JOB and/or SORT activities in your
program.
This chapter discusses the JOB and SORT statements and their associated
parameters. These statements provide CA-Easytrieve Plus with the information
required for automatic input and output of data. Data under your control is input
with the GET and READ statements, and output with the PUT and WRITE
statements.
The next exhibit illustrates the activity portion of the Sample Program including
the REPORT declaratives. The Sample Program is depicted in the “Overview”
chapter under the topic Application.
79 BONUS-CALC. PROC
81 IF SALARY GT 29999
82 DISPLAY ERRPRINT, LAST-NAME, +5, +
'INELIGIBLE FOR BONUS'
83 GOTO QUIT-BONUS
84 END-IF
85 IF SERVICE GT 19
86 BONUS = 2000
87 ELSE
88 BONUS = 1000
89 END-IF
90 PRINT BONUSRPT
91 QUIT-BONUS
92 END-PROC
93 *
94 REPORT UPD-RPT PAGESIZE 51 LINESIZE 63 NODATE NOPAGE
95 SEQUENCE DEPT LAST-NAME
96 CONTROL DEPT
97 TITLE 1 'ANNUAL UPDATE REPORT - SALARIED EMPLOYEES'
98 HEADING LAST-NAME 'NAME'
99 HEADING SERVICE 'SERV'
100 LINE DEPT LAST-NAME SERVICE RAISE SALARY
101 *
102 REPORT BONUSRPT LINESIZE 60 NODATE NOPAGE
103 SEQUENCE DEPT LAST-NAME
104 TITLE 1 'ANNUAL BONUS REPORT - SENIOR EMPLOYEES'
105 LINE DEPT LAST-NAME SERVICE BONUS
106 *
JOB Statement
The JOB statement identifies the files whose records are automatically provided
to your program (automatic input). The next exhibit diagrams the JOB statement
and associated parameters.
[INPUT (file-name [KEY(field-name...)] ...) ]
JOB [ ][NAME job-name]
[NULL ]
[INPUT]
Parameter Description
file-name Provides the name of the file you want to have controlled
automatically. This can be any name previously coded on a
FILE statement.
KEY field-name Use this subparameter to identify fields within the
above-named file when it is used in synchronized file
processing (see the “File Processing” chapter). The files are
processed in the order in which these keys appear in the
JOB statement. There is no limit on the number of fields that
you can use as keys.
Parameter Description
NULL Code this subparameter to inhibit automatic input.
Normally, a job is implicitly stopped when the automatic
input file(s) is exhausted. However, if you code NULL, the
program continues running until a STOP statement is
executed.
NAME job-name Names the JOB activity. Job-name can be up to 40 characters
long; the first character must be alphabetic. This parameter
is used only for documentation purposes.
SORT Statement
The SORT statement orders any file which can be processed sequentially. Use this
statement if you want to output a sorted file. If you do not need a sorted output
file, but simply want a report to be printed in a specific order, you can
accomplish this task through the SEQUENCE statement in the REPORT
declaratives, as illustrated in the Sample Program Activity Section shown earlier.
Refer to the illustration of the Sample Update Report in the “Overview” chapter
under the topic Application to see the result of the SEQUENCE statement in the
sample program.
The next exhibit diagrams the SORT statement and associated parameters.
SORT file-name-1 +
TO file-name-2 +
[BEFORE proc-name] +
[NAME sort-name]
file-name-1
This is the name of your input file (the file to be sorted). This name must have
been previously coded on a FILE statement in the library section of your program
and must reference a file-type that can be accessed sequentially, such as SAM,
VSAM, ISAM, or VFM (see the “Library” chapter).
TO file-name-2
This parameter provides the name of the sorted output file. If your SORT activity
is the permanent reordering of one file, this name can be the same as file-name-1
(not permitted with VSAM or ISAM files). Otherwise, requirements similar to
those for file-name-1 must be met for this TO filename, that is, the name must
have been previously provided in a FILE statement in your program's library and
the file type must be SAM, or VFM.
The USING parameter identifies data fields within the input file (file-name-1)
which you can use as sort keys. You can choose any number of fields for sort
keys, up to the limit of your installation's sort program.
These data fields must be DEFINEd in the library section before your program
can use them.
[BEFORE proc-name]
SELECT Statement
If you SELECT a record more than once, it still appears only once on the SORTed
file. The next exhibit illustrates the use of the SELECT statement in a BEFORE
procedure.
*
FILE PERSNL FB(150 1800)
OLD-EMP# 9 5 N
PAY-GROSS 94 4 P 2
*
FILE SORTPER F 150 VIRTUAL
*
SORT PERSNL +
TO SORTPER +
USING OLD-EMP# +
BEFORE SCREENER
*
SCREENER. PROC
IF PAY-GROSS LT 29999
SELECT
END-IF
END-PROC
*
[NAME sort-name]
The optional NAME parameter names the SORT activity. Sort-name can be up to
40 characters long. The first character must be alphabetic. This parameter is used
only for documentation purposes.
Data Manipulation
5
Assignment Statement
This chapter describes several ways CA-Easytrieve Plus enables you to
manipulate data within your program. The primary vehicle is the Assignment
statement.
The Assignment statement establishes the value of a field by one of two means:
■ Equivalence by copying the data from another (named) field, or from a
specified literal
■ As the result of an arithmetic expression.
Equivalence
The format used to copy data from one field to another, or from a literal to a
field, is diagrammed in the next exhibit.
{= } {field-name-2}
field-name-1 { } { }
{EQ} {literal }
Arithmetic Expression
The Sample Program Assignment Statements, shown below, illustrates the use of
this type of Assignment statement in the sample program; specifically, the
statement which reads:
SALARY = PAY-GROSS * 52
This statement directs CA-Easytrieve Plus to multiply the value in the field
named PAY-GROSS by the literal 52 and place the result into a field named
SALARY. This calculates annual salary by multiplying the weekly wage by the
number of weeks in a year. The SALARY field does not exist in file PERSNL, but
is calculated on a temporary basis by defining it as a working storage field.
22 *
23 JOB INPUT PERSNL
24 %GETDATE CURR-DATE
42 SALARY = PAY-GROSS * 52
43 PERFORM SERVICE-CALC
44 IF SERVICE LT 1
45 GO TO JOB
46 END-IF
47 PERFORM RAISE-CALC
48 BONUS = 0
49 IF SERVICE GT 14
50 PERFORM BONUS-CALC
51 END-IF
52 SALARY = SALARY + RAISE + BONUS
53 PRINT UPD-RPT
54 *
This statement uses multiple addition operations to calculate the value of field
SALARY. There is no limit to the number of arithmetic operations which can be
specified to the right of the equal sign.
Introduction
A group of CA-Easytrieve Plus statements controls the execution of your
program by means of decision and branching logic. Decisions are made in
response to an evaluation of conditional expressions coded as parameters of
CA-Easytrieve Plus decision statements. As a result of the decision, subsequent
statements can or cannot be executed, or execution can branch out of the
customary top-to-bottom line of flow to another place in the program. This group
of statements includes:
■ IF, ELSE, ELSE-IF, and END-IF
■ DO and END-DO
■ GOTO
■ PERFORM
■ STOP.
IF and DO contain the conditional expressions on which the decisions are based,
as illustrated in the next two exhibits.
Construction of IF Statement
IF condition
*Statements executed if condition is true*
[ELSE ] Optional
[ *Statements executed if condition is false*]
END-IF
Construction of DO Statement
DO WHILE condition
*Statements executed repetitively if condition is true*
END-DO
The next two exhibits illustrate the processing which takes place when an IF or
DO statement is executed.
GOTO and PERFORM cause a branch to another location in your program. STOP
halts execution of the activity.
Conditional Expressions
Single:
■ One condition, or a choice of one of several individual conditions.
Combined:
■ Any number of conditions, all of which must be considered in the evaluation.
Or unlike conditions, such as one field class condition and one field relational
condition:
IF EMPL# NUMERIC, AND EMPL# GT 15555
The next exhibit illustrates some of the conditional expressions used in the
sample program.
*
IF SERVICE GT 19
BONUS = 2000
ELSE
BONUS = 1000
END-IF
*
IF SERVICE EQ 6 THRU 10
VAC-HRS = 120
END-IF
*
includes a field series condition. If the value in field SERVICE is outside the
specified range, execution skips the Assignment statement and resumes with the
statement following END-IF.
There are four simple conditions (having at most two operands) and two
extended conditions (having potentially an unlimited number of operands). The
simple conditions are:
■ Field Relational
■ Field Class
■ File Presence
■ Record Relational.
File presence and record relational are useful only with synchronized file
processing and are discussed in detail in the “File Processing” chapter. The
extended conditions are:
■ Field Series
■ File Presence Series.
All conditions, either simple or extended, can be combined using the logical
connectors AND or OR in any combination. Combined conditions are evaluated,
as follows:
■ Conditions connected by AND are evaluated first; the combined condition is
true if ALL of the connected conditions are true.
■ Conditions connected by OR are evaluated next; the combined condition is
true when ANY of the connected conditions are true.
In the above exhibit, the first IF statement combines two field relational
conditions to test for a specific name and a specific employee number. The
second IF statement combines two field series conditions to test for a numeric
and an alphabetic range. The third IF combines a field class and a field relational
condition. The field class condition tests to see if field EMPL# is numeric. The
field relational condition tests to see if the value of this field is greater than 15555.
The last IF statement also combines the field relational and field class conditions.
The field class condition tests to see if field NET is zeros; the two field relational
conditions test to see if the value of field NET is greater than the value of field
GROSS, or if the value of field DEDUCTIONS does not equal the result of the
arithmetic expression (GROSS - NET).
Term Description
ALPHABETIC Each byte of the field is tested for either letters A through Z
or a space character.
NUMERIC The field is tested for digits 0 through 9 in the correct format
for the field's defined data type. In the case of data types N
and P, the low-order position of the field is tested for a valid
sign.
SPACE, SPACES Each byte of the field is tested for the space character.
Term Description
ZERO, ZEROS, The field is tested for a zero value in the correct format for
ZEROES the field's defined data type.
HIGH-VALUES Each byte of the field is tested for the X'FF' character.
LOW-VALUES Each byte of the field is tested for the X'00' character.
The next exhibit illustrates the use of the field class condition.
*
FILE PAYFILE
EMPL# 9 5 N
NAME 17 20 A
GROSS 94 4 P 2
*
JOB INPUT PAYFILE
IF NAME ALPHABETIC
IF EMPL# NUMERIC
IF GROSS NOT ZERO
*
You can code any number of fields and/or literals to the right of the operator.
The following rules apply to the use of this condition:
■ If field-name-1 is alphabetic, it can be compared to alphabetic or numeric
fields, and/or alphabetic literals. Numeric fields are converted to zoned
decimal before the comparison is made.
■ If field-name-1 is numeric, it can be compared to numeric fields and/or
literals. It cannot be compared to alphabetic fields or literals.
■ Each value in the series of values to the right of the operator represents either
a single value (for example, 10555) or a range of values (for example, 10555
through 15555).
Code the ELSE statement to take alternate measures in the case of a condition
testing false. ELSE is not used in any other context than with the IF statement.
The next exhibit presents portions of the sample program which illustrate the use
of these statements.
2 *
3 FILE PERSNL FB(150 1800)
4 NAME 17 16 A
5 LAST-NAME NAME 8 A
6 PAY-GROSS 94 4 P 2
7 DEPT 98 3 N
...
15 SERVICE W 2 N
...
22 *
23 JOB INPUT PERSNL
...
43 PERFORM SERVICE-CALC
44 IF SERVICE LT 1
45 GO TO JOB
46 END-IF
47 PERFORM RAISE-CALC
...
69 *
70 RAISE-CALC. PROC
72 IF DEPT LT 940
73 RAISE = SALARY * 0.1
74 ELSE
75 RAISE = SALARY * 0.15
76 END-IF
77 END-PROC
78 *
IF Statement
In the above exhibit, the first IF statement contains a field relational conditional
expression which tests to see if the value of field SERVICE is less than 1.
■ If this condition is true, the next statement (GO TO JOB) returns control to
the JOB statement, where the next input record is read.
■ If the condition is not true (SERVICE is 1 or greater), the GO TO statement is
not executed and execution continues with the statement following END-IF
(PERFORM RAISE-CALC).
ELSE Statement
END-IF Statement
Nesting IF Statements
Whenever one or more statements following an IF statement is another IF, the IFs
are considered to be nested. The format of nested IFs is simply that any statement
following an IF can be another IF statement. All IFs must be terminated by an
END-IF.
DO Statement
This statement identifies one or more CA-Easytrieve Plus statements which are to
be executed WHILE the conditional expression tests true. When the condition
tests false, the statements are bypassed. The conditional expression must have the
possibility to be false eventually or DO loops forever. In the above exhibit, each
record of file PAYFILE is read. While the value of the key is between 501 and 599,
the record is output to report PAY-RPT. Otherwise, the job is terminated by the
STOP statement.
END-DO Statement
This statement terminates the loop processing when the condition in the DO
statement tests false. Execution branches to the next executable statement
following the END-DO statement.
Nesting DO Loops
Any of the statements following the DO can also be a DO statement. You must
take care to close inner loops in proper sequence, as illustrated in the next exhibit.
GOTO Statement
This statement causes an immediate branch out of the normal top-to-bottom flow
of program execution. Its format is diagrammed in the next exhibit.
{ GOTO } { label }
{ } { }
{ GO TO } { JOB }
Statement Labels
Statement labels are names that you can code to identify the destination of a
GOTO statement. They are subject to the same restrictions as field names; that is,
they must start with a letter, can be up to 40 characters long, and can be
composed of letters, digits, and some special characters.
The next exhibit presents portions of the sample program which illustrate the use
of the GOTO statement.
22 *
23 JOB INPUT PERSNL
24 %GETDATE CURR-DATE
42 SALARY = PAY-GROSS * 52
43 PERFORM SERVICE-CALC
44 IF SERVICE LT 1
45 GO TO JOB
46 END-IF
...
54 *
55 SERVICE-CALC. PROC
57 SERVICE = CURR-YY - HIRE-YY
58 IF CURR-MM < HIRE-MM
59 SERVICE = SERVICE - 1
60 END-IF
61 IF CURR-MM NE HIRE-MM
62 GOTO QUIT-SERV-CALC
63 END-IF
64 IF CURR-DD < HIRE-DD
65 SERVICE = SERVICE - 1
66 END-IF
67 QUIT-SERV-CALC
68 END-PROC
69 *
Procedure Processing
A procedure is a set of CA-Easytrieve Plus statements that are grouped together
to accomplish a task. Once you have created a procedure and given it a name,
you can reference it in your program by name without having to repeat the lines
of code each time you want to execute them.
Procedures are defined using the PROC and END-PROC statements. They are
invoked from within your program with the PERFORM statement.
These statements identify the beginning and end of a procedure. Their format is
diagrammed in the next exhibit.
proc-name. PROC
(Statement 1)
...
...
(Statement n)
END-PROC
Proc-name
The name you assign to the procedure. It must start with a letter, can be up to 40
characters long, and can include letters, numbers, and some special characters.
This name must be followed by a period, a space, and the keyword PROC.
The CA-Easytrieve Plus statements which accomplish the procedure's task. There
is no restriction on the statements or commands that you can code in the
procedure (with the exception of input/output statements which cannot be
included in a procedure invoked during SORT or REPORT processing).
END-PROC
This keyword terminates the procedure and returns control to the point in your
program where the procedure was invoked.
Code any procedures immediately after their associated activity (JOB or SORT)
or subactivity (REPORT). Procedures which you define are invoked by
PERFORM statements. In addition, there are special-name report procedures
which are used in report processing (see the “Report Processing” chapter).
PERFORM Statement
STOP Statement
This statement terminates CA-Easytrieve Plus activities. You can use it for
premature termination of activities using automatic input. The STOP statement
must be used to terminate JOB activities which have INPUT NULL. This
statement is diagrammed in the next exhibit.
STOP [EXECUTE]
EXECUTE
The EXECUTE parameter immediately terminates the current activity and any
subsequent activities. If you do not code this parameter, only the current activity
is terminated. The next exhibit illustrates the use of the STOP statement in a
revised version of one of the procedures from the sample program.
*
BONUS-CALC. PROC
IF SALARY GT 29999
DISPLAY ERRPRINT, LAST-NAME, +5, +
'INELIGIBLE FOR BONUS'
STOP
END-IF
IF SERVICE GT 19
BONUS = 2000
ELSE
BONUS = 1000
END-IF
PRINT BONUSRPT
END-PROC
*
If you want to stop the current activity and bypass all subsequent activity, use the
EXECUTE parameter. The next exhibit provides an example of complete
termination.
...
WRITE PAYFILE, STATUS
IF PAYFILE:FILE-STATUS NE 0
DISPLAY 'I/O ERROR ON WRITE'
STOP EXECUTE
END-IF
...
Input/Output Specification
7
Introduction
For most applications, the ability of CA-Easytrieve Plus to control your input and
output is quite satisfactory. For more complex jobs, however, you can control it
yourself.
Automatic I/O
Automatic I/O provides for the automatic sequential reading of a data file and
the production of one or more reports. The statements which support this level of
I/O are:
■ JOB which specifies the input file
■ PRINT which initiates report output
■ DISPLAY which produces printed output not directly supported by a report
(for example, error messages).
Controlled I/O
Controlled I/O provides the capability to process any sequential or keyed file
(ISAM or VSAM). These statements require a comprehensive understanding of
the file structure in use. The controlled I/O statements are:
■ GET which sequentially reads one record
■ POINT which positions a keyed file to a particular record for subsequent
sequential I/O
■ PUT which sequentially writes one record
■ READ which reads one keyed record
■ WRITE which rewrites, adds, or deletes one keyed record.
Database I/O
The most complex level of input/output involves the use of databases. Refer to
the “IMS/DLI Processing” chapter.
This chapter presents brief descriptions and examples of the statements used in
automatic and controlled I/O. For an extensive discussion of their use, see the
“File Processing” chapter.
DISPLAY Statement
Use the DISPLAY statement to output data to the system printer or a named file.
This data is spaced according to the specified parameters. Its format is
diagrammed in the next exhibit.
[ ] [ literal-3 ]
[ NEWPAGE ] [ field-name ]
DISPLAY [file-name] [ SKIP literal-1 ] [ +literal-4 ]
[ CONTROL literal-2 ] [ -literal-4 ]
[ ] [ COL literal-5 ]
[file-name]
The NEWPAGE option specifies a skip to a new page before the data is printed.
The SKIP option specifies the number of lines (literal-1) to be skipped before the
data is printed. The CONTROL option sets the printer carriage control character
for the print line. Valid alphabetic values for literal-2 are 0 through 9, +, -, A, B, or
C. CONTROL is not valid in REPORT procedures. No automatic page skipping is
provided by the DISPLAY statement. It is your responsibility to issue a DISPLAY
NEWPAGE when you reach the bottom of the page.
DISPLAY ERRPRINT SKIP 10
The option for adjustment of the horizontal spacing between displayed items is
+literal-4 or -literal-4 counted in character positions. For instance, +5 specifies
five spaces between the last item and the next (DEDUCTIONS and GROSS); -3
specifies that the next item is three spaces to the left of where it would otherwise
print. The value of literal-4 can be any amount that does not extend your data
beyond the end of the line to be printed.
DISPLAY ERRPRINT, DEDUCTIONS, +5, GROSS
[COL literal-5]
The COL option specifies precisely where your data is placed on the print line.
Literal-5 specifies the column number where the first character of the next data
item appears, counting from the left of the page. In the following example,
DEDUCTIONS starts in column 1 and GROSS starts in column 40. Each character
position is one column. The value of literal-5 can be any amount that does not
extend your data beyond the end of the print line.
DISPLAY ERRPRINT, DEDUCTIONS, COL 40, GROSS
The DISPLAY statement sends a line to the printer as soon as the statement is
executed. For this reason, you must take care how you use it in your program. If
your program produces an unsequenced report, each PRINT statement in your
JOB activity sends a line of its associated report to the printer, after being
formatted according to the report declaratives.
Unless otherwise specified, any data in DISPLAY statements within your JOB
activity goes directly to the printer and is interspersed with the lines of your
report. If your report is sequenced, all of the DISPLAYed data precedes all of the
PRINTed data. The DISPLAYed data goes directly to the printer, but the
PRINTed data is spooled until the JOB activity processing is finished.
Debugging
Refer to the CA-Easytrieve Plus Reference Guide for a detailed discussion of the
ways to use this debugging aid.
PRINT Statement
The PRINT statement initiates report output by causing the named report to
extract the current values of the fields to be output and to format them according
to the specifications in the report declaratives. The report can be printed
immediately or deferred.
■ If the report is not sequenced, the PRINT statement outputs data to a print
file from which the report is produced immediately.
■ If the report is sequenced, or if another report is already using the associated
print file, the PRINT statement outputs data to a work file which is spooled
until the associated JOB activity processing is complete.
The report-name parameter is the name of the report which contains the data
being output with the PRINT statement.
If the report is sequenced, the data is output to a work file which is sorted before
the report is printed. The next exhibit illustrates this process.
GET Statement
The GET statement makes the next sequential record of the named file available
for processing. Its format is diagrammed in the next exhibit.
GET file-name
file-name
The file-name parameter is required. It can be any file defined in the library
section of your program. See the POINT statement which also provides an
example of the GET statement.
PUT Statement
The PUT statement outputs data to a sequential file whose name is specified in
the statement. The format is diagrammed in the next exhibit.
PUT file-name-1 [FROM file-name-2]
PUT creates new sequential files (SAM, VFM, VSAM), or adds consecutive
records to an existing VSAM file.
file-name-1
This parameter names the output file being created or being added to. This file
must be defined in the library section of your program.
[FROM file-name-2]
Example
In the above exhibit, the statements retrieve those records with keys between 500
and 599 inclusive from file PAYFILE, increase the value in the SALARY field of
each record by 10 percent, and output each updated record to file SALUPD and
report UPD-RPT.
POINT Statement
The POINT statement initiates a search for a position within an indexed or
relative-record file, based on a comparison between keys in the file and a search
value specified in the statement. Its format is diagrammed in the next exhibit.
{EQ}
{= } {field-name}
POINT file-name { } { }
{GE} {literal }
{>=}
The POINT statement only locates the specified position of the record in the file.
You must still issue a GET statement to retrieve the data for processing.
file-name
This must be the name of a file with an indexed or relative-record filetype (IS or
VS).
Relational Operator
The equal operator (EQ or =) directs CA-Easytrieve Plus to search for an exact
match between a key in the file and the search value specified in the POINT
statement. An error results if the exact match is not found. The
greater-than-or-equal operator (GE or >=) searches for a key in the file which is
equal to or greater than the specified search value; a condition which is more
easily satisfied.
These parameters can be any literal or any field-name defined in your library. If
the search value is higher than any key in the file, the file presence conditional
expression IF EOF file-name tests true.
The statements in the above exhibit retrieve those records with keys between 500
and 599 inclusive from file PAYFILE and output them to report PAY-RPT.
READ Statement
The READ statement provides random access to keyed and relative-record
VSAM and ISAM files. Its format is diagrammed in the next exhibit.
READ file-name KEY field-name [STATUS]
file-name
This parameter identifies the file you want to access. It must have been defined as
a VSAM or ISAM file in your program's library section.
KEY field-name
[STATUS]
This parameter is optional. If you include it, execution of the READ statement
sets a return code in the FILE-STATUS field of your input file to indicate the
success or failure of the operation. A successful READ returns a value of 0, any
other value is a code identifying the reason for failure. Check with your data
center to learn the meaning of the codes in this field. They are explained in an
IBM manual about your system.
The statements in the above exhibit search file PAYFILE for a record whose key
matches the value in EMPL#. PAYFILE is keyed by employee number. The value
of EMPL# is 44152.
■ If the READ is not successful, execution branches to the location labeled
ERRTASK.
■ If the NAME field of this record is equal to 'OLDNAME,M.', the NAME field
is changed to 'NEWNAME,M.' and the record is written back to PAYFILE.
■ If the name comparison tests false, execution branches to ERRTASK,
bypassing the Assignment and WRITE statements.
WRITE Statement
Use the WRITE statement to maintain keyed and relative-record VSAM files
(ISAM files are read/only). WRITE updates or deletes the current record of the
named file, or adds new records. Its format is diagrammed in the next exhibit.
[DELETE]
WRITE file-name-1 [UPDATE] [FROM file-name-2]
[ADD ]
file-name-1
This parameter names the file to be modified. It must have been coded in the
FILE statement with the UPDATE subparameter included.
[ DELETE ]
[ UPDATE ]
[ ADD ]
[FROM file-name-2]
If the record lengths are not the same, the length of the record from file-name-2 is
adjusted to fit the record length specified for file-name-1.
The READ statement exhibit, shown earlier, also presents an example of the
WRITE statement.
Report Processing
8
Introduction
The most noticeable thing about CA-Easytrieve Plus report processing is how
easy it makes the task of producing reports. You can design your reports any
way you prefer, such as to set up column headings, to request different types of
information, and to decide which kinds of totals you want.
You have to tell CA-Easytrieve Plus what you have decided by using a few
easy-to-remember English words. These words are either coded on the REPORT
statement as parameters or immediately follow the REPORT statement as
subsequent but related statements. These are called report declaratives.
You can let the CA-Easytrieve Plus report processor handle the details for you or
you can choose to specify every detail of your report to describe the data you
want reported and the appearance of the printed result. This facility is so
powerful and easy to use that no special programming skill is required.
Within the JOB activity section of your program, the statements which send data
to reports are:
■ The PRINT statement, which initiates the report facility
■ The DISPLAY statement, which produces single print lines.
The desired reports are defined by a set of statements at the end of the JOB
activity. These statements specify the report type, format, sequence, and content,
as follows:
REPORT
SEQUENCE
CONTROL
TITLE
HEADING
LINE
report procedures
REPORT-INPUT
BEFORE-LINE
AFTER-LINE
BEFORE-BREAK
AFTER-BREAK
ENDPAGE
TERMINATION
You can generate as many reports as you like from a JOB activity. The Sample
Program produces the Sample Update Report and Sample Bonus Report
(illustrated in the “Overview” chapter under the topic Application). The report
declarative portion of the sample program is illustrated below.
The first report specified in the above exhibit is described in seven lines of code
which supply the following information:
■ The report name is UPD-RPT. Each page of the printed output is 51 lines long
and 63 columns wide. Neither the date nor the page number is printed on the
first title line of each page.
■ The report is ordered (sequenced) by two levels: first, by department number
and, within each department, in order by last name.
■ The dollar values are subtotaled for each department, and the report is
segmented by department.
■ The title ANNUAL UPDATE REPORT - SALARIED EMPLOYEES is centered
across the top of the report page.
■ The column heading for field LAST-NAME reads NAME, and for field
SERVICE reads SERV.
■ There are five columns spaced three characters apart across the
63-character-wide report. The columns contain the data in the fields: DEPT,
LAST-NAME, SERVICE, RAISE, and SALARY in that order from left to
right.
The result of this specification is the Sample Update Report which is illustrated in
the “Overview” chapter, under the topic Application.
Report Types
There are two basic report formats: standard format and label format. The
reports produced by the sample program are standard format reports. Label
format reports include mailing labels, form letters, and other special-purpose
reports.
Standard Reports
TOP MARGIN
The top margin is the space between the physical top of the form and the point to
which the printer positions the paper when a top-of-form order is issued to the
printer. The size of the top margin is controlled by the printer carriage tape or
forms control buffer.
TITLE AREA
The Title Area consists of 1 to 99 optional title lines plus the blank lines, usually
three, between the last title line and the first heading line.
HEADING AREA
The Heading Area consists of 1 to 99 optional heading lines plus a blank line
between the last heading line and the report body.
REPORT BODY
The Report Body consists of one or more line groups. Each group consists of 1 to
99 lines plus, optionally, one or more blank lines between line groups.
BOTTOM MARGIN
The bottom margin is the area remaining between the bottom of the report body
and the physical bottom of the page.
The CA-Easytrieve Plus default values for report spacing are sufficient for most
applications.
Label Reports
Each individual label is one line group. Each PRINT statement in the JOB activity
of your program produces one label, formatted on the lines of that label
according to the report declaratives. The DOWN and SIZE parameters specify
the label dimensions.
REPORT Statement
REPORT is the first statement of the report declaratives. It establishes the type
and characteristics of your report. Although there are several parameters
available which provide a flexible capability to tailor your reports, you can
probably produce most reports using default parameter values.
[SUMMARY] +
[PAGESIZE literal-4] +
[LINESIZE literal-5] +
[SPREAD] + Spacing
[NOSPREAD] + Control
[NOADJUST] +
[NODATE] +
[NOPAGE] +
report-name
REPORT report-name
This parameter names the report. The report-name can be from 1-to-40 characters
long and must start with a letter. It is unique within each JOB activity and is
correlated with matching entries on PRINT report-name statements. In the
Sample Program Report Declaratives, shown earlier, the report-names are
UPD-RPT and BONUSRPT.
[SUMMARY]
This option inhibits printing of detail data on CONTROL reports - only totals are
printed. Since CA-Easytrieve Plus totals only quantitative fields (those fields
which are defined as having decimal positions), SUMMARY produces a report
with entries only in the control fields and the fields which are totaled. For
appearance, the LINE statement should contain only these field-names. If the
LINE statement contains names of fields which are not totaled, the headings print
with no entries under them.
LABELS
LABELS ([ACROSS literal-1] +
[DOWN literal-2] +
[SIZE literal-3] +
[NEWPAGE])
This option defines your report as having the label format. The associated
subparameters control the spacing of the labels on the report page (see the Label
Reports exhibit shown earlier).
ACROSS literal-1
DOWN literal-2
Specifies the number of print lines on each label. The value of literal-2 is the
number of print lines between the first line of each label (including any physical
space between labels).
SIZE literal-3
Specifies the width of each label, counted in print positions from left to right. The
value of literal-3 is the number of print positions between the first character of
each label (including any physical space between labels).
NEWPAGE
Directs the printer to print the first line of each label at the top of a page.
[PRINTER file-name]
This option identifies a file-name other than the default as the destination of the
printed report. The default is SYSPRINT for OS/390 and SYSLST for VSE. If a
file-name is specified, the PRINTER parameter must be specified on the
associated FILE statement.
[PAGESIZE literal-4]
This option specifies a value for the top-to-bottom length of the printed report
page. The value of literal-4 sets the number of print lines per page. At least one
line group must fit on a report page. The default is commonly 58 lines. Check
with your data center to determine the default value for your installation.
[LINESIZE literal-5]
This option specifies a value for the left-to-right width of each line of your report.
The value of literal-5 is the number of print columns on each report line. The
maximum you can specify is one character less than the physical length (record
size) of the printer file receiving the report. The default is commonly 132
characters, which is one less than the actual size of the typical printer file record
(133 characters). The first character is used for vertical form control (carriage
control). Check with your data center to determine the default value for your
installation.
LINESIZE must be able to accommodate the maximum size of all the fields listed
across your report, including extra characters for totals when requested. A
LINESIZE of 60 or 63 characters is specified for the reports in the sample
program to enable them to fit on the pages of this guide.
[SPREAD ]
[NOSPREAD]
This option adjusts the spacing of the columns of your report. SPREAD directs
CA-Easytrieve Plus to maximize the number of spaces between columns.
NOSPREAD deactivates the SPREAD option. In most cases, NOSPREAD is the
default, which puts three characters between columns and centers the report on
the printer page.
[NOADJUST]
This option left-justifies your report on the printer page. Centering is usually the
default.
[NODATE]
This option suppresses printing of the date in the leftmost eight columns of the
first line of the report title. This is useful with NOADJUST, since without it the
date overprints the first eight characters of the report title.
[NOPAGE]
This option suppresses printing of the characters PAGE and the page number in
the rightmost 11 columns of the first report title line.
Modification of the first REPORT statement and the associated LINE statement in
the sample program to include several of these format determination and spacing
control parameters, as follows:
REPORT UPD-RPT SUMMARY LINESIZE 60 SPREAD NODATE NOPAGE
...
LINE DEPT RAISE SALARY
[LIMIT literal-6]
This option specifies the number of PRINT statements accepted for this report
and is useful for testing. The value of literal-6 sets the maximum number of lines
desired. For example, you could limit the output of your report to the first 50
PRINT statements to make sure your column spacing is what you want.
[EVERY literal-7]
This option is also used for testing. Literal-7 specifies the occurrence value for
processing every Nth PRINT command directed to the report. If you specified
LIMIT 50 EVERY 10, you could sample the output from the first 500 PRINT
statements for your report.
SEQUENCE Statement
This optional statement specifies the order in which you want the contents of
your report to appear. If you do not specify SEQUENCE, the data appears on
your report in the same order as it appears in the records of the input file. You
can order any report on the contents of one or more fields in the input file or in
working storage. These fields do not have to be output to the printed report. The
syntax of the SEQUENCE statement is illustrated below.
SEQUENCE field-name-1 [D] [field-name-2 [D]] ...
field-name
This parameter identifies the field(s) on which your report is ordered. If you
specify more than one field, the sequencing is done in the order specified. For
example, the first report in the sample program is sequenced first by department
number (DEPT) and, within departments, by the last name of the employees
(LAST-NAME):
SEQUENCE DEPT LAST-NAME
CONTROL Statement
This optional statement identifies the field-name(s) on which you want your
report controlled. Also, it enables you to specify certain optional results of the
control break processing. One result of controlling a report is to produce
subtotals of the values in fields which have been specified as having decimal
positions. In the sample program, both reports are controlled on department
number. A control break occurs each time the value in field DEPT changes and at
end-of-report, producing a subtotal of the dollar values in the RAISE and
SALARY fields for each department and final totals at the end of the report. The
syntax of the CONTROL statement is diagrammed below.
[field-name] [NEWPAGE]
CONTROL [ ] [ ] [NOPRINT] ...
[FINAL ] [RENUM ]
[field-name ]
[ FINAL ]
These parameters identify the field(s) on which you want your report controlled.
This can be any defined field in your input file or working storage. Code the
FINAL parameter before the first field-name (if any) to specify options for the
control break which occurs at end-of-report. Three options alter the normal
control break processing:
NEWPAGE
Causes a skip to the top of the next page after control break processing for the
specified field is completed.
RENUM
Causes a skip to the top of the next page and resets the page number to 1 on the
page following the control break.
NOPRINT
Suppresses printing the summary line for the specified control break. All other
control break processing is performed as usual.
TITLE Statement
This optional statement defines the title lines to appear on your report. The
TITLE statement syntax is illustrated below.
{field-name }
{'literal-2' }
TITLE [literal-1] {+literal-3 }
{-literal-3 }
{COL literal-4 }
Each title line is centered horizontally within the title area of the report. The first
title line includes two additional items as follows:
■ The current date is printed in the leftmost eight positions unless the
NODATE option is specified on the REPORT statement.
■ The word PAGE and the current page number are printed in the right-most
11 positions unless the NOPAGE option is specified on the REPORT
statement.
[literal-1]
The value of literal-1 specifies the position of the title line within the title area in
the case where you have more than one line. Literal-1 does not need to be
specified for the first TITLE statement; if it is, its value must be 1. These numbers
must be specified in ascending order with no duplicates.
field-name
Specifies that the contents of the named field appears on the title line. This name
can be a field from any active file, a field from working storage, or a system-
defined field.
'literal-2'
Specifies a character string for the title item. The character string must be
enclosed in single quotes. For example, the TITLE line for the first report in the
sample program is:
TITLE 1 'ANNUAL UPDATE REPORT - SALARIED EMPLOYEES'
You can specify more than one title item on the same line as long as the number
of characters in the combined items, plus three characters between items, does
not exceed the current LINESIZE value. Two options enable you to adjust the
spacing between title items:
+literal-3 or -literal-3
produces:
PROJECTED INCOME FOR: SOUTHEAST TAMPA BAY
The whole title line is centered as usual, but additional space is left between the
region and branch names to make the title more readable.
COL literal-4
Specifies the print column number where the first character of the next title item
is printed. The value of literal-4 cannot force the following title item(s) beyond
the end of the value of the associated LINESIZE parameter. COL is permitted
only with the NOADJUST option of the REPORT statement.
HEADING Statement
This statement optionally defines an alternate column heading to be printed on
the report in place of the specified field-name. Its syntax is diagrammed below.
HEADING field-name ('literal' ... )
field-name
This parameter specifies the name of a field coded on the LINE statement. The
value of the literal is the content of the new heading. For example, in the first
report of the sample program, the column heading LAST-NAME appears as
NAME through the statement:
HEADING LAST-NAME 'NAME'
Multiple literals within parentheses are stacked vertically over the column when
it is printed. The statement:
HEADING LAST-NAME ('EMPLOYEE' 'NAME')
produces:
EMPLOYEE
NAME
LINE Statement
This statement defines the contents of the lines of the report. The contents of the
fields, whose names are specified in this statement, are printed across each line of
the report page. The LINE statement syntax is diagrammed below.
{ field-name }
{ 'literal-2' }
{ +literal-3 }
LINE [literal-1] { } ...
{ -literal-3 }
{ COL literal-4 }
{ POS literal-5 }
The LINE statement in the first report of the sample program is:
LINE DEPT LAST-NAME SERVICE RAISE SALARY
[literal-1]
The value of literal-1 specifies the position of this LINE within the line group
when you have multiple lines. An example of this is the specification for the
mailing labels illustrated earlier. The first line contains names, the second line
contains the street address, and the third line contains the city, state, and zip
code, as follows:
LINE 1 FIRST-NAME -3 LAST-NAME
LINE 2 STREET
LINE 3 CITY -3 STATE ZIP
Literal-1 can be omitted in the first LINE statement. If it is specified, its value
must be 1. Position numbers must be specified in ascending order with no
duplicates.
field-name
Specifies that the contents of the named field appear on the print line. This name
can be a field from any active file or from working storage. For file and W fields,
data is transferred to the print line as soon as the PRINT statement is executed.
For S fields, data is transferred to the print line when the line is actually printed.
literal-2
Specifies a character string for the line item. The character string must be
enclosed in single quotes.
You can specify more than one line item on the same line as long as the number
of characters in the combined items, plus three characters between items, does
not exceed the current LINESIZE value. Three options enable you to adjust the
spacing between line items:
+literal-3 or -literal-3
produce the names and addresses illustrated earlier, with the last name and the
state moved three spaces to the left of where it would otherwise print. This
provides more readable labels.
COL literal-4
Specifies the column number where the first character of the next line item is
printed. The value of literal-4 cannot force the following item(s) beyond the end
of the value of the LINESIZE parameter. COL is permitted only with the
NOADJUST option of the REPORT statement.
POS literal-5
Line 1 consists of the region, social security number, name, and date of birth of
each employee.
Line 2 lists the telephone number under the social security number, the street
address under the name, and the date of hire under the date of birth.
Line 3 lists the city, state, and zip code under the name and street address.
Report Procedures
Although REPORT statements meet the vast majority of all report requirements,
some reports depend upon special data manipulation. Report procedures are
asynchronous routines which facilitate this requirement.
Code any report procedures at the end of their associated report. The report
processor invokes special-name procedures (such as BEFORE-LINE or
AFTER-BREAK), as required.
Coding Techniques
Coding report procedures is the same as coding procedures within JOB activities,
with the following exceptions:
1. You cannot use the input/output generating statements listed below:
DLI
GET
IDMS
POINT
PRINT
PUT
READ
WRITE
2. You cannot use the STOP statement.
3. Use the DISPLAY statement to perform special report annotations. Use of
DISPLAY requires the following extra considerations:
You cannot code the DISPLAY statement's file-name-1 parameter. DISPLAY
is only to the associated report.
You cannot code the HEX option of DISPLAY.
DISPLAY lines are counted and included in the end-of-page determination.
However, the ENDPAGE procedure is not invoked by these lines.
In report procedures, you can reference any field contained in an active file or in
working storage. When control or total fields are referenced, CA-Easytrieve Plus
automatically adjusts so that SUMFILE data is used. This assures access to the
field actually used in the report.
LEVEL is a system-defined field provided for control reports. The field is defined
as a two-byte binary field. The value in LEVEL indicates the control break level
and varies from 0 to 'n + 1' where:
Report procedures are invoked at specific points of the report processing activity.
By analyzing these points, you can determine the specific use of the various
procedures. The exhibit that follows illustrates the procedures listed below:
REPORT-INPUT
Final screening of report input data. Report data can be selected and/or
modified.
BEFORE-LINE
Detail line has been created but not yet printed. Typical use is to annotate the
body of the report before line printing. Detail line data cannot be modified.
AFTER-LINE
Detail line has been printed. Typical use is to annotate the body of the report
after each line is printed.
BEFORE-BREAK
AFTER-BREAK
Total line has been printed. Typical use is special annotation following total lines
on control reports.
ENDPAGE
TERMINATION
(BEFORE-LINE)
detail NA 1A 1
(AFTER-LINE)
(BEFORE-LINE)
detail NA 1B 1
(AFTER-LINE)
(BEFORE-BREAK)
total NA 4
(AFTER-BREAK)
...
...
(ENDPAGE)
(BEFORE-BREAK)
total xx ...
(AFTER-BREAK)
(BEFORE-BREAK)
total ...
(AFTER-BREAK)
...
...
(ENDPAGE)
(TERMINATION)
REPORT-INPUT
When the report data has been spooled (because the report had been
SEQUENCEd or the printer file had been in use), the REPORT-INPUT procedure
is invoked as each spooled record is read to produce this report.
Although you can code the logic within the JOB activity itself, it is occasionally
desirable to place the logic in a REPORT-INPUT procedure. The next exhibit
illustrates use of the REPORT-INPUT procedure in final report input selection.
The first 10 report inputs for each code are the only ones selected for ultimate
report input:
DEFINE COUNT S 2 P 0
DEFINE HOLD-CODE S CODE
...
REPORT-INPUT. PROC
IF CODE NE HOLD-CODE
HOLD-CODE = CODE
COUNT = 0
END-IF
IF COUNT LT 10
COUNT = COUNT + 1
SELECT
END-IF
END-PROC
BEFORE-BREAK
This procedure can be used in control reports to modify totals before they are
printed. A typical application is to calculate averages and/or percentages for the
fields totaled.
AFTER-BREAK
ENDPAGE
TERMINATION
A TERMINATION procedure is invoked at the end of the report. You can use
this procedure to print report footing information, including control totals and
distribution information. The next exhibit is an example of report footing:
...
TERMINATION. PROC
DISPLAY NEWPAGE
DISPLAY GRAND-TOTAL ' IS THE CONTROL TOTAL'
DISPLAY SKIP 5 'ROUTE TO: ...'
...
END-PROC
File Processing
9
Introduction
Data file creation can be a very complex process. It is not within the scope of this
Application Guide to provide sufficient information to enable you to create data
files from scratch. Rather, this guide enables you to use CA-Easytrieve Plus to
process any existing file to read it, change records within it, add new records, or
delete existing records.
If you want to create new files, you need to enlist the help of your data center.
CA-Easytrieve Plus can process files or databases from the simplest to the most
complex. File types include sequential access method (SAM), indexed sequential
access method (ISAM), virtual storage access method (VSAM), virtual file
manager (VFM) files, IMS/DLI, and IDMS databases. You can let CA-Easytrieve
Plus do all your file processing automatically, or you can control some or all of
the operations yourself.
You can use I/O control statements within a JOB activity, with or without
automatic I/O, by observing the following restrictions:
■ No I/O control statements are valid in REPORT procedures.
■ No I/O control statements are valid for files involved in automatic input
processing, except:
- The POINT statement can be used with automatic input for VSAM and
ISAM files to enable skip-sequential input processing
- The PUT and WRITE statements can be used to update an automatic
input VSAM file.
Record Formats
All formats must adhere to established IBM processing standards. Check with
your data center if you have questions about these format standards.
CA-Easytrieve Plus makes these assumptions about the record formats of CARD,
PUNCH, and VSAM files:
■ CARD and PUNCH file records are fixed-length, 80 characters long.
■ VSAM file records are undefined-length.
The record lengths of variable and undefined records being output are controlled
by the current contents of the RECORD-LENGTH field for that file. If the current
record (the last record you either input or output) is smaller than the record you
want to output, you can increase the record length by an Assignment statement
which precedes the output statement. For example:
SALUPD:RECORD-LENGTH = 200
PUT SALUPD
...
System-Defined Fields
CA-Easytrieve Plus provides three special data fields for each file:
RECORD-LENGTH
RECORD-COUNT
Contains the number of logical I/O operations performed for the file.
FILE-STATUS
Contains a code which indicates the result of the most recent I/O operation.
Error Conditions
Error conditions during file processing usually fall into one of three categories:
■ File OPEN errors, usually caused by incorrect or missing JCL information.
The operating system terminates processing. This type of problem should be
referred to your data center.
■ Invalid file reference errors, caused by statements that refer to data from a
file with no currently available record (for example, after end-of-file). A
CA-Easytrieve Plus diagnostic message is issued and processing terminates.
■ Improper handling of nonzero STATUS conditions returned from I/O
statements. You are responsible for handing these types of errors.
You can use several conditional expressions to test for the availability of data for
file processing. These are discussed in the “Input/Output Specification” chapter
and later in this chapter.
SAM Files
CA-Easytrieve Plus processes Sequential Access Method (SAM) files according to
the following rules:
1. You cannot process the same SAM file as both an input and an output file
within the same JOB activity. This is allowable for SORT activities.
2. You can create SAM files in one activity and process them in subsequent
activities.
3. Only one CARD file is permitted in a CA-Easytrieve Plus program.
Input
CA-Easytrieve Plus permits both automatic and controlled I/O for SAM files.
The sample program uses automatic I/O exclusively. The next two exhibits
illustrate how to process a SAM file using each facility:
You can process only one of your input files as CARD input. CARD input is
placed into the system input stream (SYSIN for OS/390, SYSIPT for VSE). If your
operating mode is the default (syntax check, compile, and execute), your file data
must follow an END statement after your program, as illustrated under the
Device-type Parameters topic in the “Library” chapter.
Output
You can load output files with the PUT statement, as described in the
“Input/Output Specification” chapter. The next exhibit illustrates this operation.
*
FILE PAYFILE F(150)
REC-KEY 1 3 N
SALARY 94 4 P 2
*
FILE SALUPD VS CREATE
*
JOB INPUT NULL
GET PAYFILE
DO WHILE (REC-KEY < 600, AND NOT EOF PAYFILE)
SALARY = SALARY * 1.1
PUT SALUPD FROM PAYFILE
PRINT UPD-RPT
GET PAYFILE
END-DO
STOP
*
REPORT UPD-RPT ...
...
You can specify the PUNCH attribute on the FILE statement when the Card
Punch is the output device for a SAM file produced under VSE, as illustrated in
the next exhibit. For OS/390, JCL defines the PUNCH output.
FILE CARDOUT PUNCH
COUNTER 12 4 N
*
JOB INPUT NULL
...
COUNTER = COUNTER + 1
PUT CARDOUT
...
VFM Files
Virtual File Manager (VFM) is a sequential access method used for all
CA-Easytrieve Plus work file requirements. You can also use VFM files for
temporary sequential processing. VFM processing is identical to SAM processing.
The next exhibit illustrates a typical use of VFM:
*
FILE PERSNL FB(150 1800)
EMP# 9 5 N
FILE SORTPER F 150 VIRTUAL
UPD-EMP# 9 5 N
*
SORT PERSNL TO SORTPER USING EMP#
*
JOB INPUT SORTPER
*
SORTPER is a virtual file. You do not have to define it in the JCL since it is
actually stored and retrieved by VFM from storage.
ISAM Files
CA-Easytrieve Plus processes Indexed Sequential Access Method (ISAM) files as
input only. You can perform sequential, skip-sequential, or random processing
on these files.
Sequential Processing
Skip-Sequential Processing
Random Processing
Random processing enables you to choose specific records within a file for
processing, regardless of their location in the file. Random processing is always
performed with controlled I/O. The next exhibit illustrates random processing.
FILE PAYFILE IS
EMPL# W 4 N
NAME 5 20 A
*
FILE NEWFILE VS CREATE
*
JOB INPUT NULL
EMPL# = 1126
READ PAYFILE, KEY EMPL#, STATUS
IF PAYFILE:FILE-STATUS NOT ZERO
DISPLAY 'RECORD NOT FOUND'
STOP
END-IF
IF NAME EQ 'OLDNAME'
NAME = 'NEWNAME'
PUT NEWFILE
ELSE
DISPLAY 'NAME DOES NOT MATCH'
END-IF
STOP
*
VSAM Files
CA-Easytrieve Plus processes Virtual Storage Access Method (VSAM) files as
both input and output files. You can perform the same types of processing
(sequential, skip-sequential, and random processing) on VSAM files as on ISAM
files. VSAM files are organized as one of the following types:
You must identify your VSAM file organization before coding your program.
File Loading
You can enter (load) data for the first time into a new VSAM file with the PUT
statement in the JOB activity portion of your program, as illustrated in the next
exhibit.
FILE PAYMSTR VS UPDATE
REC-KEY 1 3 N
SALARY 94 4 P 2
FILE SALUPD VS CREATE
*
JOB INPUT NULL
POINT PAYMSTR GE '300'
GET PAYMSTR
DO WHILE (REC-KEY < 500, AND NOT EOF PAYMSTR)
SALARY = SALARY * 1.1
WRITE PAYMSTR
PUT SALUPD FROM PAYMSTR
GET PAYMSTR
END-DO
STOP
*
This routine updates the PAYMSTR records between 300 and 499 with a 10
percent salary increase and also loads the updated records into the newly created
file SALUPD.
Input
CA-Easytrieve Plus processes VSAM input files the same as ISAM files. You can
perform sequential, skip-sequential, or random processing on VSAM input files.
■ Sequential processing can be performed under automatic or controlled I/O.
The next exhibit illustrates sequential processing under automatic control.
FILE PAYMSTR VS
SALARY 94 4 P 2
*
JOB INPUT PAYMSTR
SALARY = SALARY * 1.1
PRINT SAL-RPT
*
■ Random processing enables you to choose specific records within a file for
processing, regardless of their location in the file. Random processing is
always performed with controlled I/O. The next exhibit illustrates random
processing.
FILE PAYMSTR VS UPDATE
DEPT W 3 N
JOB-CATEGORY 132 2 N
*
JOB INPUT NULL
DEPT = 914
READ PAYMSTR, KEY DEPT, STATUS
IF PAYMSTR:FILE-STATUS NOT ZERO
STOP
END-IF
IF JOB-CATEGORY GT 25
JOB-CATEGORY = 77
ELSE
DISPLAY DEPT +3 JOB-CATEGORY +3 'NOT COVERED'
END-IF
STOP
*
Record Addition
You can use the WRITE or PUT statement to add records to an established VSAM
file. Either statement adds a single record to the file, but the PUT statement is
more efficient if you are inserting many records into the same place in the file. To
add records to a file, you must code the UPDATE parameter on the FILE
statement as illustrated in the next two exhibits.
Record Deletion
You can delete individual records from a VSAM file with the WRITE statement
using the DELETE parameter as illustrated in the next exhibit. The deleted record
is the specified file's current input record.
FILE PAYMSTR VS UPDATE
EMPL# 1 5 N
*
JOB INPUT PAYMSTR
IF EMPL# EQ 44152 THRU 44449
WRITE PAYMSTR DELETE
END-IF
IF EMPL# GE 44450
STOP
END-IF
*
Record Update
You can modify and update the current record of a VSAM input file using the
WRITE statement as illustrated in the next exhibit.
FILE PAYMSTR VS UPDATE
EMPL# W 5 N
NAME 6 20 A
*
JOB INPUT NULL
EMPL# = 41452
READ PAYMSTR, KEY EMPL#, STATUS
IF PAYMSTR:FILE-STATUS NOT ZERO
DISPLAY 'NO PAYMSTR RECORD EXISTS FOR ' EMPL#
STOP
END-IF
IF NAME EQ 'AMAN'
NAME EQ 'NICHOLSON'
WRITE PAYMSTR UPDATE
ELSE
DISPLAY 'EMPLOYEE NUMBER 41452 IS ' NAME
END-IF
STOP
*
The sample program illustrated in the above exhibit sorts the Personnel Master
File PERSNL into order by employee number, then matches the sorted output file
(SORTPER), against a card file (PERSUPD) containing raise calculations for
specified employees. The data for the CARD input file, also in order by employee
number, is coded immediately following the last CA-Easytrieve Plus statement
(END) in the program.
A new master file (NEWPERS) is created which contains the updated salary
information, and a report is printed to list the names and associated data about
the employees who received raises. The report is illustrated in the next exhibit.
SALARY UPDATE REPORT
EMPLOYEES WITH OVER 25 YEARS SERVICE
The key can be any defined field in the named file, while the file is in order
by the value of the contents of the specified key field.
■ The same number of keys must be specified for each file.
■ The corresponding keys for both files must have the same data class. That is,
corresponding keys must both be alphabetic or both be numeric. The keys
can have different lengths. Numeric keys can have different data types (N, P,
U, B).
Input
Files for synchronized processing are specified in the library the same as any
other sequential file; the only difference is how the file is specified on the JOB
statement. The next exhibit illustrates the I/O specification for the sample
program.
2 *
3 FILE PERSNL FB(150 1800)
4 OLD-EMP# 9 5 N
5 *
6 FILE PERSUPD CARD
7 EMP# 1 5 N
8 RAISE-PERCENT 7 2 N
9 *
10 FILE SORTPER F 150 VIRTUAL
11 UPD-EMP# 9 5 N
12 NAME 17 8 A
13 PAY-GROSS 94 4 P 2
14 NEWSAL W 4 P 2
15 *
16 FILE NEWPERS FB(150 1800)
17 *
18 FILE ERRPRINT PRINTER
20 *
21 SORT PERSNL TO SORTPER USING OLD-EMP#
22 *
23 JOB INPUT (SORTPER KEY(UPD-EMP#) +
PERSUPD KEY(EMP#) )
24 *
Conditional Expressions
This condition determines if a record of the named input file is available for
processing. The format is diagrammed in the next exhibit.
IF [NOT] [EOF] file-name
The next exhibit illustrates how this is used in the sample program.
IF SORTPER
PUT NEWPERS FROM SORTPER
ELSE
DISPLAY ERRPRINT EMP# ' RECORD NOT FOUND'
END-IF
This condition determines if the records from more than one file have the same
key. The format is diagrammed in the next exhibit.
IF [NOT] MATCHED
A record from one file is considered to be available for processing if its key
matches the key of a record from the other file. The result is true if the input files
have matching keys. The optional NOT parameter reverses the condition test; the
result is true if the keys do not match.
The next exhibit illustrates how this is used in the sample program.
IF MATCHED
NEWSAL = PAY-GROSS * (1 + RAISE-PERCENT / 100)
PRINT NEW-RPT
PAY-GROSS = NEWSAL
END-IF
When this condition (IF MATCHED) is true, a record is available from both
PERSUPD and SORTPER.
This condition tests for duplicate records within one file. The current record of
the named file is compared to the previous and next records of the same file. The
optional NOT parameter reverses the condition tests. The next exhibit diagrams
this condition.
DUPLICATE
IF [NOT] FIRST-DUP file-name
LAST-DUP
DUPLICATE
The current record of the named file is compared to the previous and next
records of the same file. The result is true if the current record has the same key
as either of the other two records. The optional NOT parameter returns a true
result if neither of the contiguous records has the same key.
FIRST-DUP
The current record of the named file is compared to the previous and next
records of the same file. The result is true if the current record's key is different
from the previous record's key but the same as the next record's key.
LAST-DUP
The current record of the named file is compared to the previous and next
records of the same file. The result is true if the current record's key is the same
as the previous record's key but different from the next record's key.
Table Processing
10
Table Definition
A table is a collection of uniform data records. Tables have two parts:
■ The argument uniquely identifies a table entry.
■ The description is information directly associated with the argument.
Tables are defined by FILE statements in the library section of your program. The
TABLE option must be coded on the FILE statement, as discussed in the
“Library” chapter. This option identifies the file as the target of a SEARCH
statement issued in your program.
[INSTREAM]
FILE file-name TABLE [ ]
[literal ]
The only fields that can be defined for TABLE files are ARG (argument) and
DESC (description). ARG defines the field used to search the table. DESC defines
the field which contains the desired information. Data within a TABLE must be
sorted in ascending order by its search argument. The maximum length for an
alphanumeric ARG or DESC field is 254 bytes.
There are two types of TABLEs, instream and external. Instream tables reside
within your program — they are established for use when your program is
compiled. If you make changes to data in an instream table, you must recompile
your program. External tables are stored on files external to your program —
they are established for use during initiation of the JOB activity that contains the
SEARCH statement which references them.
Instream Tables
External Tables
If you specify the TABLE option with no subparameter, the file is an external
table whose maximum number of entries is limited by a value in the options table
established at installation. Check with your data center to determine this value. If
the number of entries in your external table is larger than the default value, you
can code a numeric literal as the subparameter of the TABLE option to specify
the maximum number of entries.
A file which meets the following criteria can be defined as an external table:
■ An existing file that is in ascending order by the field used as a search
argument
■ A file created by having its name specified as the TO parameter of a SORT
statement which is sorted into ascending order by the search argument.
SEARCH Statement
Use the SEARCH statement to access table information. Its syntax is illustrated
next.
SEARCH file-name WITH field-name-1 GIVING field-name-2
file-name
This is the name of the file which describes the table and its source. The file must
be defined with the TABLE attribute.
WITH field-name-1
This parameter identifies the field that contains the search argument.
Field-name-1 can be defined in working storage or in any file except a file with
the TABLE attribute.
GIVING field-name-2
This parameter identifies the receiving field for the results of the table search.
This field can be defined in working storage or in any file except a file with the
TABLE attribute.
The named TABLE file is searched for an ARGument whose value is the same as
the value of field-name-1. If a match is found, the content of field-name-2 is set to
the value of the DESCription associated with the ARGument. The content of
field-name-2 is not changed if a match for field-name-1 is not found in the named
TABLE file. An IF statement with a file presence condition (see the “File
Processing” chapter) can be coded after the SEARCH statement to determine the
success of the table search.
You can code SEARCH statements any place within a JOB activity, SORT
procedure, or REPORT procedure. The next exhibit illustrates the retrieval of
names of the days of the week based on numeric identification codes.
*
FILE CALENDR
DAY-OF-WEEK 12 1 A
NAME-OF-DAY 14 20 A
*
FILE WEEKDAY TABLE INSTREAM
ARG 1 1 A
DESC 3 9 A
1 SUNDAY
2 MONDAY
3 TUESDAY
4 WEDNESDAY
5 THURSDAY
6 FRIDAY
7 SATURDAY
ENDTABLE
*
JOB INPUT CALENDR
SEARCH WEEKDAY WITH DAY-OF-WEEK, GIVING NAME-OF-DAY
IF WEEKDAY
DISPLAY NAME-OF-DAY, ' IS DAY ', DAY-OF-WEEK
ELSE
DISPLAY '****INVALID DAY OF WEEK = ', DAY-OF-WEEK
END-IF
*
The next exhibit is a more extensive example that illustrates the retrieval of
month name translations, based on the English name.
*
FILE CALENDR
ENGL-NAME 12 10 A
EURO-NAME 22 40 A
FREN-NAME 22 10 A
ITAL-NAME 32 10 A
GERM-NAME 42 10 A
SPAN-NAME 52 10 A
*
FILE MONTH TABLE
ARG 1 10 A
DESC 11 40 A
*
JOB INPUT CALENDR
SEARCH MONTH WITH ENGL-NAME, GIVING EURO-NAME
IF NOT MONTH
DISPLAY 'INVALID ENGLISH NAME = ', ENGL-NAME
GO TO JOB
END-IF
PRINT MON-RPT
*
REPORT MON-RPT LINESIZE 80
SEQUENCE ENGL-NAME
TITLE 1 'WESTERN EUROPEAN MONTH NAME'
TITLE 2 'TRANSLATION TABLE'
HEADING ENGL-NAME ('ENGLISH' 'NAME')
HEADING FREN-NAME ('FRENCH' 'NAME')
HEADING ITAL-NAME ('ITALIAN' 'NAME')
HEADING GERM-NAME ('GERMAN' 'NAME')
HEADING SPAN-NAME ('SPANISH' 'NAME')
LINE ENGL-NAME FREN-NAME ITAL-NAME GERM-NAME SPAN-NAME
*
IMS/DLI Processing
11
Introduction
Through the IMS/DL/I interface, CA-Easytrieve Plus provides facilities for
information retrieval from databases. To use this interface efficiently, you should
have a thorough knowledge of IMS/DL/I and of the database(s) to be processed.
Refer to the CA-Easytrieve Plus Reference Guide for detailed discussions of the
processing techniques needed and to your Database Administrator for specific
information regarding the structure of your database.
This chapter briefly describes the CA-Easytrieve Plus statements which define
database processing:
Statement Description
FILE Identifies the database.
RECORD Identifies the database segments available for processing.
RETRIEVE Describes automatic database input.
Three special terms used in database processing are referenced throughout this
chapter:
Terms Description
Database Description A control block that describes the structure of the
(DBD) database. The DBD also defines the appearance and
contents (fields or records) that make up each of the
segment types in the database.
Program Defines an application program's view of the
Communication Block database. An application program often needs to
(PCB) process only some of the segments in a database. A
PCB defines which of the segments in the database the
program is allowed to access.
Program Specification Contains the PCBs for a particular application
Block (PSB) program. A program can use one or several PCBs.
There is one PSB for each application program.
FILE Statement
FILE file-name DLI (dbd-name [literal])
The FILE statement (see the “Library” chapter) identifies the database by
specifying DLI as the file-type parameter and by identifying the PCB to be
processed as follows:
■ dbd-name is the name of the DBD.
■ literal is a numeric integer that specifies the relative occurrence of the DBD
within the PSB to be processed.
All field definitions coded immediately after the FILE statement relate to the
PCB. The PCB data format is described in the IBM publication, IMS/DLI
Applications Programming Manual. PCB references are normally made in
association with controlled database activities (which are not covered in this
Application Guide.)
RECORD Statement
RECORD statements are coded immediately after the FILE statement to identify
the database segments which are to be available for processing. RECORD
allocates a work space which contains the segment data during execution.
Field-definition statements, coded immediately following a RECORD statement,
relate to data fields within that segment. A RECORD statement must be coded
for each segment of the database to be processed. The RECORD statements must
be coded in the same order as in the PSB which defines the database. All
segments of a database do not need to be defined. However, since incomplete
paths are not supported, the parent segment of each RECORD must be coded.
The next exhibit illustrates the RECORD statement syntax.
RECORD segment-name-1 literal-1 [segment-name-2] +
[KEY (field-name, literal-2, literal-3)]
segment-name-1
literal-1
segment-name-2
[KEY]
field-name
This is the one- to eight- character name used to designate the key field to the
IMS/DLI database. The name must correspond to a field named in the segment
in the DBD.
literal-2
Literal-2 is a numeric integer that specifies the location of the key within the
segment.
literal-3
Literal-3 is a numeric integer that specifies the length of the key field.
RETRIEVE Statement
Code the RETRIEVE statement immediately following the JOB statement to
describe automatic database input. You can code only one RETRIEVE statement
per JOB. Automatic database input is processed in the same manner as
non-database input. The syntax of the RETRIEVE statement is illustrated next.
RETRIEVE file-name-1 +
SELECT (record-name +
[ID literal-1] +
[LIMIT literal-2] +
[WHILE (condition)] +
...)
file-name-1
File-name-1 identifies the database being accessed. This is the name coded on the
JOB INPUT and FILE statements.
You can designate the tickler file option by coding both the KEYFILE and the
KEYVALUE parameters on the RETRIEVE statement and the KEY parameter on
the RECORD statement for the root segment.
■ File-name-2 is the name of a file which is sequentially processed to obtain the
keys of the root segments to be retrieved.
■ Field-name is a data field from file-name-2 which contains the key. The key
values are used to retrieve the root segments.
Automatic input is terminated when all of the keys in file-name-2 have been
processed.
SELECT
record-name
[ID literal-1]
The path ID designations CAN be any two-character alphabetic literals that you
choose.
[LIMIT literal-2]
LIMIT literal-2 optionally controls the number of segment occurrences that are
retrieved. The LIMIT applies to each path. For example, if it is known that a
particular segment never occurs more than two times in a path, code LIMIT 2 for
that segment. When you do not code this parameter, CA-Easytrieve Plus
retrieves all qualified occurrences of the segment.
[WHILE (condition)]
Code the record-name parameter (and optionally the ID, LIMIT, and WHILE
subparameters) for every segment of the database to be processed by the JOB.
Sweep of a Database
Sweeping the entire database provides the default input. A GN (get next) call is
issued at the root level until the database has been exhausted. LIMIT, SSA, or
WHILE options, if specified, control the sweep.
Optionally, a file of root segment keys can control the extent of the database to be
processed. Root segment keys are obtained one-at-a-time from the tickler file. GU
(get unique) calls are issued at the root level for each key in the tickler file. GNP
calls are issued to obtain all segments associated with the root.
Automatic input of IMS/DLI databases uses path processing. Each database path
identified by the SELECT parameter is processed in a top-to-bottom,
front-to-back, and left-to-right order. A root segment is accessed first; path
accessing continues downward to the left until the end of the path. As the end of
each path is reached, that data is made available to the program as an input
record.
CA-Easytrieve Plus exhausts each path before proceeding to the next path. When
it exhausts the last path, it retrieves the next root and processing begins again
with the leftmost path.
OS/390 JCL
12
Introduction
All CA-Easytrieve Plus programs require a set of associated commands or
statements called Job Control Language (JCL) when they are submitted to be
compiled and/or executed. This set of statements defines the components and
requirements of the CA-Easytrieve Plus program to the operating system under
which it runs.
This chapter provides some general information about OS/390 JCL requirements.
Examples are provided of the JCL used for the sample programs in Part I of this
Application Guide. Within these examples of JCL, material in lowercase letters is
dependent on your installation.
SALARY REPORT
DEPARTMENTS 900 - 911
EMPLOYEE TOTAL
DEPT NAME SALARY
4,295.12
CURR-DATE S 6 N
CURR-MM CURR-DATE 2 N
CURR-DD CURR-DATE +2 2 N
CURR-YY CURR-DATE +4 2 N
*
JOB INPUT PERSNL
%GETDATE CURR-DATE
PERFORM SERVICE-CALC
IF SERVICE GT 19
PRINT MAILOUT
END-IF
*
SERVICE-CALC. PROC
SERVICE = CURR-YY - HIRE-YY
IF CURR-MM < HIRE-MM
SERVICE = SERVICE - 1
END-IF
IF CURR-MM NE HIRE-MM
GOTO QUIT-SERV-CALC
END-IF
IF CURR-DD < HIRE-DD
SERVICE = SERVICE - 1
END-IF
QUIT-SERV-CALC
END-PROC
*
REPORT MAILOUT LABELS (ACROSS 2 DOWN 4 SIZE 30)
SEQUENCE LAST-NAME
LINE 1 FIRST-NAME -3 LAST-NAME
LINE 2 STREET
LINE 3 CITY -3 STATE ZIP
/*
EMP# 1 5 N
RAISE-PERCENT 7 2 N
*
FILE SORTPER F 150 VIRTUAL
UPD-EMP# 9 5 N
NAME 17 8 A
PAY-GROSS 94 4 P 2
NEWSAL W 4 P 2
*
FILE NEWPERS FB(150 1800)
*
FILE ERRPRINT PRINTER
*
SORT PERSNL TO SORTPER USING OLD-EMP#
*
*
JOB INPUT (SORTPER KEY(UPD-EMP#) +
PERSUPD KEY(EMP#) )
*
IF MATCHED
NEWSAL = PAY-GROSS * (1 + RAISE-PERCENT / 100)
PRINT NEW-RPT
PAY-GROSS = NEWSAL
END-IF
IF SORTPER
PUT NEWPERS FROM SORTPER
ELSE
DISPLAY ERRPRINT EMP# ' RECORD NOT FOUND'
END-IF
*
REPORT NEW-RPT LINESIZE 80 NOPAGE NODATE
SEQUENCE NAME
TITLE 1 'SALARY UPDATE REPORT'
TITLE 2 'EMPLOYEES WITH OVER 25 YEARS SERVICE'
HEADING UPD-EMP# ('EMPL' 'NUMBER')
HEADING NAME ('EMPL' 'NAME')
HEADING PAY-GROSS ('OLD' 'SALARY')
HEADING NEWSAL ('NEW' 'SALARY')
HEADING RAISE-PERCENT ('RAISE' '%')
LINE UPD-EMP# NAME PAY-GROSS NEWSAL RAISE-PERCENT
*
END
01730 08
04225 09
09481 09
11473 11
11710 10
12267 12
/*
SORTPER, the sort output file, is not defined in the JCL because it is a temporary
VIRTUAL file. PERSUPD, the input employee number file, is also not defined in
the JCL, since it is a CARD file whose data is obtained from the records after the
END statement following the CA-Easytrieve Plus program.
VSE JCL
13
Introduction
All CA-Easytrieve Plus programs require a set of associated commands or
statements called Job Control Language (JCL) when they are submitted to be
compiled and/or executed. This set of statements defines the components and
requirements of the CA-Easytrieve Plus program to the operating system under
which it runs.
This chapter provides some general information about VSE JCL requirements.
Examples are provided of the JCL used for the sample programs in Part I of this
Application Guide. Within these examples of JCL, material in lowercase letters is
dependent on your installation.
SALARY REPORT
DEPARTMENTS 900 - 911
EMPLOYEE TOTAL
DEPT NAME SALARY
4,295.12
SORTPER, the sort output file, is not defined in the JCL because it is a temporary
VIRTUAL file. PERSUPD, the input employee number file, is also not defined in
the JCL, since it is a CARD file whose data is obtained from the records after the
END statement following the CA-Easytrieve Plus program.
Applications
14
Introduction
Part II of the Application Guide is a composite of sample CA-Easytrieve Plus jobs
which perform typical data processing functions. The examples are presented in
two forms:
■ The first form processes pre-existing data files. The “Basic Examples” and
“Advanced Techniques” chapters present examples of reports generated
from two sample files: a Personnel Master File and an Inventory Master File.
■ The second form implements entire application systems. The “Bank System”
and “Project Management System” chapter contain mini-applications that
demonstrate the wide scope of CA-Easytrieve Plus capabilities.
Scan the examples to get a feel for the language. If you find an example similar to
your needs, use the ideas and the code (if possible) to implement your solution.
Application Overview
Four distinct applications are the basis for all of the examples. They are:
■ Personnel System
■ Inventory System
■ Bank Customer System
■ Project Management System.
Each of these applications has its own master and auxiliary files. Each file
structure is defined in the description of the particular system.
Applications 14–1
Introduction
The Personnel System and Inventory System are sample files to be used by the
sample programs in later chapters. The Bank Customer and Project Management
Systems are complete, working mini-systems.
These guidelines help make the programs more readable. Similar guidelines used
in the development of your programs enable the logic and structure of the
programs to be easily discerned. Liberally supplying meaningful comments can
make program maintenance much easier.
CA-Easytrieve Plus can generate a report in nearly any format. In this guide, we
limit all reports to a maximum of 80-character print lines to accommodate our
page size. Wider print lines enable you considerable flexibility in this area.
The Inventory sample file is the basis for many of the examples in the following
chapters. Following is a macro listing of %INVMSTR that provides the field
definitions for the Inventory file in the examples. These field definitions are not
repeated in the examples. Refer to this chapter when studying examples which
use the Inventory file.
MACRO
*
* INVENTORY MASTER FIELD DEFINITIONS
*
PART-INFO 1 43 A
PART-DESCRIPTION 1 35 A -
HEADING('PART DESCRIPTION')
PART-NUMBER 36 8 N MASK '999-99-999' -
HEADING('PART' 'NUMBER')
*
LOCATION-INFO 44 18 A
LOCATION-CITY 44 7 A HEADING 'CITY'
LOCATION-STATE 51 2 A HEADING 'STATE'
LOCATION-CODE 53 3 P HEADING 'CODE'
LOCATION-BAY 56 1 A HEADING 'BAY'
LOCATION-BIN 57 3 N HEADING 'BIN'
LOCATION-LEVEL 60 2 N HEADING 'LEVEL'
*
ITEM-INFO 62 29 A
ITEM-SELLING-PRICE 62 4 P 2 -
HEADING('SELLING' 'PRICE' '(DOLLARS)')
ITEM-REORDER-POINT 66 4 N 0 -
HEADING('REORDER' 'POINT')
ITEM-LAST-SALE-DATE 70 6 N MASK(D 'Z9/99/99') -
HEADING('LAST SALE' 'DATE')
ITEM-LAST-INVENTORY-DATE 76 6 N MASK D -
HEADING('LAST' 'INVENTORY' 'DATE')
ITEM-LAST-INVENTORY-QUANTITY 82 4 P 0 -
HEADING('LAST' 'INVENTORY' 'QUANTITY')
ITEM-MFGD-COMMODITY-GROUP 86 3 P -
HEADING('MFGD' 'COMMODITY' 'GROUP')
ITEM-WEIGHT-POUNDS 89 2 P 0 MASK 'ZZ9 #' -
HEADING('WEIGHT' '(POUNDS)')
*
LAST-PURCHASE-INFO 91 13 A
LAST-PURCHASE-QUANTITY 91 3 P 0 -
HEADING('LAST' 'PURCHASE' 'QUANTITY')
LAST-PURCHASE-PRICE 94 4 P 2 -
HEADING('LAST' 'PURCHASE' 'PRICE')
LAST-PURCHASE-DATE 98 6 N MASK D -
HEADING('LAST' 'PURCHASE' 'DATE')
*
VENDOR-INFO 104 17 A
VENDOR-NUMBER 104 8 N MASK '99-99-9-999' -
HEADING('VENDOR' 'NUMBER')
VENDOR-LOCATION-CITY 112 7 A HEADING('VENDOR' 'CITY')
VENDOR-LOCATION-STATE 119 2 A HEADING('VENDOR' 'STATE')
*
SHIPPING-INFO 121 6 A
SHIPPING-FOB-CODE 121 2 P HEADING('FOB' 'CODE')
SHIPPING-CARRIER-ALPHA-CODE 123 4 A HEADING('CARRIER' 'CODE')
*
Applications 14–3
Introduction
The Personnel sample file is the basis for many of the examples in the following
chapters. The following JOB lists the contents of the file. The field definitions are
imbedded as macro %PERSNL. These field definitions are not repeated in the
examples. Refer to this chapter when studying an example which uses the
Personnel file.
1 *
2 * PERSONNEL MASTER FILE LISTING
3 *
4 FILE PERSNL FB(150 1800)
5 %PERSNL
6 *
7 * TEST FILE FIELD DEFINITIONS
8 *
9 REGION 1 1 N
10 BRANCH 2 2 N
11 SSN 4 5 P MASK '999-99-9999' -
HEADING('SOCIAL' 'SECURITY' 'NUMBER')
12 EMP# 9 5 N HEADING('EMPLOYEE' 'NUMBER')
13 NAME 17 16 A HEADING 'EMPLOYEE NAME'
14 NAME-LAST NAME 8 A HEADING('LAST' 'NAME')
15 NAME-FIRST NAME +8 8 A HEADING('FIRST' 'NAME')
16 ADDRESS 37 39 A
17 ADDR-STREET 37 20 A HEADING 'STREET'
18 ADDR-CITY 57 12 A HEADING 'CITY'
19 ADDR-STATE 69 2 A HEADING 'STATE'
20 ADDR-ZIP 71 5 N HEADING('ZIP' 'CODE')
21 PAY-NET 90 4 P 2 HEADING('NET' 'PAY')
22 PAY-GROSS 94 4 P 2 HEADING('GROSS' 'PAY')
23 DEPT 98 3 N
24 DATE-OF-BIRTH 103 6 N MASK(Y 'Z9/99/99') -
HEADING('DATE' 'OF' 'BIRTH')
25 TELEPHONE 117 10 N MASK '(999) 999-9999' -
HEADING('TELEPHONE' 'NUMBER')
26 SEX 127 1 N HEADING('SEX' 'CODE')
27 * 1 - FEMALE
28 * 2 - MALE
29 MARITAL-STAT 128 1 A HEADING('MARITAL' 'STATUS')
30 * M - MARRIED
31 * S - SINGLE
32 JOB-CATEGORY 132 2 N HEADING('JOB' 'CATEGORY')
33 SALARY-CODE 134 2 N HEADING('SALARY' 'CODE')
34 DATE-OF-HIRE 136 6 N MASK Y -
HEADING('DATE' 'OF' 'HIRE')
35 *
36 JOB INPUT PERSNL
37 PRINT PERSNL-LIST
38 *
39 *
40 REPORT PERSNL-LIST SKIP 1 SPACE 1 LINESIZE 80
41 *
42 TITLE 'NEW PERSONNEL SAMPLE FILE LISTING'
43 *
44 HEADING REGION ('R' 'G' 'N')
45 HEADING BRANCH ('BRCH')
46 HEADING EMP# ('EMPL' 'NUMBER')
47 HEADING SSN ('SOCIAL SECURITY' 'NUMBER/' 'TELEPHONE')
48 HEADING PAY-GROSS ('PAY - ' 'GROSS/' 'NET')
49 HEADING SEX ('SEX/' 'M/S')
50 HEADING DEPT ('DPT/' 'J*C/' 'S*C')
51 HEADING DATE-OF-BIRTH ('DATE OF' 'BIRTH/' 'HIRE')
52 *
53 LINE 1 REGION -
BRANCH -
SSN -
EMP# -
NAME -
+2 PAY-GROSS -
DEPT -
DATE-OF-BIRTH -
SEX
54 LINE 2 POS 3 -1 TELEPHONE -
POS 5 ADDR-STREET -
POS 6 PAY-NET -
POS 7 +1 JOB-CATEGORY -
POS 8 DATE-OF-HIRE -
POS 9 +1 MARITAL-STAT
55 LINE 3 POS 5 ADDR-CITY -
-1 ADDR-STATE -
ADDR-ZIP -
POS 7 +1 SALARY-CODE
Applications 14–5
Introduction
Applications 14–7
Introduction
Applications 14–9
Introduction
Basic Examples
15
Introduction
This chapter illustrates the use of CA-Easytrieve Plus to solve a variety of basic
data processing problems. The emphasis is placed on reading data files and
printing reports.
The input data for these examples are the Inventory and Personnel sample files
described in the “Applications” chapter. The field definitions for the files are
contained in the macros, which are discussed later in this chapter. The field
definitions are not repeated for each example; refer to the original field
definitions as required.
The output for each job is typically some form of report. A wide variety of
reports are printed to give you an idea of what is possible using CA-Easytrieve
Plus. For some examples, the volume of output has been condensed.
Employees in Region 1
The Personnel Department has requested a list of all employees in Region 1. The
list must include the employees' first and last names, their employee numbers,
and the branches in which they work. The list and columns must be titled, and
must be in readable format.
This is a simple job for CA-Easytrieve Plus since the report formatting is done
automatically. The Personnel file is read through automatic I/O. All records with
a region code of 1 are selected for the report, which is defined simply with a
TITLE statement and a LINE statement.
1 *
2 * EXAMPLE 15.1
3 *
4 FILE PERSNL FB(150 1800)
5 %PERSNL
35 *
36 *
37 JOB
38 IF REGION = 1
39 PRINT
40 END-IF
41 *
42 REPORT LINESIZE 70
43 TITLE 'EMPLOYEES IN REGION 1'
44 LINE NAME-FIRST NAME-LAST EMP# BRANCH
------------------------------------------------------------------
11/10/83 EMPLOYEES IN REGION 1 PAGE 1
Region 4 employees are actually selected by rejecting all records with a region
code other than 4. The raise percentage value is set based on the job category. The
raise amount (in dollars), and the new gross salary are calculated for each
selected employee.
Note: The sequence of each report is independent. This enables a wide variety of
reports to be generated with a single pass of the input file.
1 *
2 * EXAMPLE 15.2
3 *
4 FILE PERSNL FB(150 1800)
5 %PERSNL
35 RAISE-PERCENT W 3 P 2 HEADING('RAISE' '(PERCENT)')
36 RAISE-DOLLARS W 4 P 2 HEADING('RAISE' '(DOLLARS)')
37 NEW-SALARY W 4 P 2 HEADING('PROPOSED' 'SALARY')
38 *
39 *
40 JOB
41 IF REGION NQ 4 . * REJECT UNDESIRED RECORDS
43 GOTO JOB
44 END-IF
45 IF JOB-CATEGORY = 10 . * SET RAISE AMT BASED ON
47 RAISE-PERCENT = 7.00 . * JOB-CATEGORY
49 ELSE
50 RAISE-PERCENT = 9.00
51 END-IF
52 * CALCULATE RAISE IN DOLLARS AND NEW GROSS PAY
53 RAISE-DOLLARS = RAISE-PERCENT * PAY-GROSS / 100 + .005
54 NEW-SALARY = PAY-GROSS + RAISE-DOLLARS
55 PRINT DETAIL-BY-BRANCH . * PRINT DESIRED REPORTS
57 PRINT SUMMARY-BY-CATEGORY
58 *
59 REPORT DETAIL-BY-BRANCH LINESIZE 78
60 SEQUENCE BRANCH PAY-GROSS D
61 CONTROL BRANCH
Employee Letters
The Personnel Department has decided to accept the proposed salary
adjustments and wants to generate letters to all employees, informing them of the
salary adjustment. In addition to the letter, a mailing label must be generated.
The letters and mailing labels should be ordered by Zip code to minimize mailing
costs.
This is the same basic job as the previous example, but the output is different.
Instead of a standard report, a letter is generated.
By including the parameters SKIP 1 and PAGESIZE 40, we insure only one letter
per page.
The mailing labels are generated by specifying their content. The ACROSS 2
parameter enables the labels to fit on the page of this document - ACROSS 4 is
normal for most label runs.
KAREN WALTERS
1022 5 KENSINGTON PK
LOS ANGELES CA 90030
DEAR KAREN
SINCERELY,
FRANK K. WILLIAMS
PRESIDENT
ALFRED JONES
2070 BELMONT ROAD NW
LOS ANGELES CA 90052
DEAR ALFRED
SINCERELY,
FRANK K. WILLIAMS
PRESIDENT
JANET ZOLTAN
2026 FORT DAVIS ST S
LOS ANGELES CA 90091
DEAR JANET
SINCERELY,
FRANK K. WILLIAMS
PRESIDENT
ARTHUR HAFER
806 CONNECTICUT AVE
SAN DIEGO CA 92031
DEAR ARTHUR
SINCERELY,
FRANK K. WILLIAMS
PRESIDENT
LISA JOHNSON
806 CONNECTICUT AVE
SAN DIEGO CA 92045
DEAR LISA
SINCERELY,
FRANK K. WILLIAMS
PRESIDENT
PAULA JUDAR
4333 46TH ST N W
SAN FRANCISC CA 94041
DEAR PAULA
SINCERELY,
FRANK K. WILLIAMS
PRESIDENT
RUTH TALUS
9331 CAROLINE AVE
SEATTLE WA 98003
DEAR RUTH
SINCERELY,
FRANK K. WILLIAMS
PRESIDENT
PAMELA RYAN
1717 R NW #301
SEATTLE WA 98009
DEAR PAMELA
SINCERELY,
FRANK K. WILLIAMS
PRESIDENT
MARINA WARD
1725 H ST NE APT 2
SEATTLE WA 98015
DEAR MARINA
SINCERELY,
FRANK K. WILLIAMS
PRESIDENT
MARINA WARD
1725 H ST NE APT 2
SEATTLE WA 98015
Mailing Labels
The Personnel Department has requested a mailing label run for all employees in
Regions 1 and 2. These labels should be ordered by Zip code, with a break on Zip
code prefix (first three digits), in order to receive a lower postage rate.
Selecting the desired employee records to be passed to the report processor for
formatting into labels is simple. More complex is the control break when the Zip
code prefix changes.
Note: The redefinition of the Zip code field enables sorting on the first three
digits. After a break occurs, the next label begins on a new line. Additional
spacing can be obtained by a BEFORE-BREAK procedure which issues a
DISPLAY SKIP 6 statement.
1 *
2 * EXAMPLE 15.4
3 *
4 FILE PERSNL FB(150 1800)
5 %PERSNL
35 ZIP-PREFIX ADDR-ZIP 3 N . * REDEFINE FIRST 3 DIGITS OF ZIP
37 *
38 *
39 JOB
40 IF REGION EQ 1 2 . * SELECT DESIRED RECORDS
42 PRINT MAILING-LABEL . * PRINT MAILING LABEL
44 END-IF
45 *
46 REPORT MAILING-LABEL LABELS (ACROSS 3 SIZE 28) SPACE 1
47 SEQUENCE ADDR-ZIP . * SORT ON ZIP CODE
49 CONTROL ZIP-PREFIX . * BREAK ON ZIP PREFIX
51 LINE 1 EMP# REGION BRANCH
52 LINE 3 NAME-FIRST NAME-LAST
53 LINE 4 ADDR-STREET
54 LINE 5 ADDR-CITY ADDR-STATE ADDR-ZIP
12267 1 01 02200 1 01
11602 1 03 02688 1 03
11931 1 04
ELAINE TALL
1412 36TH ST NW
NEW YORK NY 10091
00577 2 03
KATHY PETRIK
5005 BENTON AVE
WASHINGTON DC 20032
00370 1 02 11473 1 02
04225 2 05 01895 2 05
11710 2 02 03571 2 02
00445 2 04
JEAN POST
1250 4TH ST SW
JACKSONVILLE FL 32052
11376 2 01
PATTI HUSS
1355 TEWKESBURY PLAC
CLEARWATER FL 33512
Tally Reports
The Personnel Department wants tallies on various fields within the personnel
file. Each tally report lists the number of employees in the specified category and
the percent of the total employees that number represents. The desired categories
are:
■ Sex
■ Marital status
■ Job category
■ Salary code
■ Gross pay in $100 increments
■ City.
This job generates five separate summary reports; the first two categories are
combined in the first report. The report process does most of the work. All that is
done explicitly is the percent calculation in the BEFORE-BREAK procedure.
If the illustration of the coding seems overwhelming to read, follow one report at
a time (the way CA-Easytrieve Plus processes the code). The report data is
collected in work files, usually one for each report. After the input file is read, the
output for each report is formatted serially. There are some exceptions to this
flow, but it is the norm.
As you are reading the code, notice the use of W and S fields, and how rounding
is performed in the percent calculations.
Note: Also, generating a number of reports from a single pass of the file
dramatically reduces the resources required without increasing the complexity of
the job.
1 *
2 * EXAMPLE 15.5
3 *
4 FILE PERSNL FB(150 1800)
5 %PERSNL
35 SEX-CODE W 6 A HEADING 'SEX'
36 GROSS-RANGE W 3 P HEADING ('SALARY RANGE' 'HUNDRED $ INCR')
37 TOTAL-EMPLOYEES S 3 P 0
38 PERCENT W 3 P 2 HEADING('PERCENT' 'OF' 'TOTAL')
39 *
40 *
41 JOB
42 TOTAL-EMPLOYEES = TOTAL-EMPLOYEES + 1
43 *
44 IF SEX EQ 1 . * SET PROPER SEX CODE
46 SEX-CODE = 'FEMALE'
47 ELSE
48 SEX-CODE = 'MALE'
49 END-IF
50 PRINT SEX-MARITAL-STAT-RPT . * PRINT REPORT
52 *
53 PRINT JOB-CATEGORY-RPT . * PRINT REPORT
55 *
56 PRINT SALARY-CODE-RPT . * PRINT REPORT
58 *
59 GROSS-RANGE = PAY-GROSS / 100.00 . * CALCULATE GROSS SALARY
61 GROSS-RANGE = GROSS-RANGE * 100 . * RANGE
63 PRINT GROSS-PAY-RPT . * PRINT THE REPORT
65 *
66 PRINT CITY-RPT . * PRINT THE CITY REPORT
68 *
69 REPORT SEX-MARITAL-STAT-RPT SUMMARY LINESIZE 78
70 SEQUENCE SEX-CODE MARITAL-STAT . * SORT REPORT
72 CONTROL SEX-CODE MARITAL-STAT . * BREAK SPECIFICATION
74 TITLE 1 'TALLY OF EMPLOYEES BY SEX AND MARITAL STATUS'
75 LINE 1 SEX-CODE MARITAL-STAT TALLY PERCENT
76 BEFORE-BREAK. PROC . * CALCULATE PERCENT
79 PERCENT = TALLY * 100 / TOTAL-EMPLOYEES + .005
80 END-PROC
81 *
82 REPORT JOB-CATEGORY-RPT SUMMARY LINESIZE 78
83 SEQUENCE JOB-CATEGORY . * SORT REPORT
85 CONTROL JOB-CATEGORY . * BREAK SPECIFICATION
87 TITLE 1 'TALLY OF EMPLOYEES BY JOB CATEGORY'
88 LINE 1 JOB-CATEGORY TALLY PERCENT
89 BEFORE-BREAK. PROC . * CALCULATE PERCENT
92 PERCENT = TALLY * 100 / TOTAL-EMPLOYEES + .005
93 END-PROC
94 *
95 REPORT SALARY-CODE-RPT SUMMARY LINESIZE 78
96 SEQUENCE SALARY-CODE . * SORT REPORT
98 CONTROL SALARY-CODE . * BREAK SPECIFICATION
100 TITLE 1 'TALLY OF EMPLOYEES BY SALARY CODE'
101 LINE 1 SALARY-CODE TALLY PERCENT
102 BEFORE-BREAK. PROC . * CALCULATE PERCENT
105 PERCENT = TALLY * 100 / TOTAL-EMPLOYEES + .005
106 END-PROC
107 *
108 REPORT GROSS-PAY-RPT SUMMARY LINESIZE 78
109 SEQUENCE GROSS-RANGE D . * SORT REPORT
111 CONTROL GROSS-RANGE . * BREAK SPECIFICATION
113 TITLE 1 'TALLY OF EMPLOYEES BY GROSS SALARY RANGE'
114 HEADING PAY-GROSS ('AVERAGE' 'GROSS' 'SALARY')
115 LINE 1 GROSS-RANGE TALLY PERCENT PAY-GROSS
116 BEFORE-BREAK. PROC . * CALCULATE PERCENT
119 PERCENT = TALLY * 100 / TOTAL-EMPLOYEES + .005
120 PAY-GROSS = PAY-GROSS / TALLY + .005
121 END-PROC
122 *
123 REPORT CITY-RPT SUMMARY LINESIZE 78
124 SEQUENCE ADDR-CITY . * SORT REPORT
126 CONTROL ADDR-CITY . * BREAK SPECIFICATION
128 TITLE 1 'TALLY OF EMPLOYEES BY HOME CITY'
129 LINE 1 ADDR-CITY TALLY PERCENT
130 BEFORE-BREAK. PROC . * CALCULATE PERCENT
133 PERCENT = TALLY * 100 / TOTAL-EMPLOYEES + .005
134 END-PROC
PERCENT
MARITAL OF
SEX STATUS TALLY TOTAL
FEMALE M 13 27.08
FEMALE S 23 47.92
FEMALE 36 75.00
MALE M 5 10.42
MALE S 7 14.58
MALE 12 25.00
48 100.00
PERCENT
JOB OF
CATEGORY TALLY TOTAL
10 22 45.83
20 2 4.17
23 1 2.08
25 8 16.67
30 2 4.17
40 6 12.50
60 7 14.58
48 100.00
PERCENT
SALARY OF
CODE TALLY TOTAL
01 20 41.67
02 2 4.17
03 9 18.75
05 2 4.17
06 7 14.58
08 8 16.67
48 100.00
PERCENT AVERAGE
SALARY RANGE OF GROSS
HUNDRED $ INCR TALLY TOTAL SALARY
PERCENT
OF
CITY TALLY TOTAL
ATLANTA 2 4.17
BALTIMORE 2 4.17
BOSTON 2 4.17
CHICAGO 6 12.50
CLEARWATER 1 2.08
DALLAS 6 12.50
JACKSONVILLE 1 2.08
KANSAS CITY 4 8.33
LOS ANGELES 3 6.25
MINNEAPOLIS 3 6.25
NEW YORK 4 8.33
RALEIGH 2 4.17
SAN DIEGO 2 4.17
SAN FRANCISC 1 2.08
SEATTLE 3 6.25
TRENTON 2 4.17
WASHINGTON 4 8.33
48 100.00
This example is a simple process of selecting records based on the value in two
fields, ADDR and SEX, then sequencing the report by name.
1 *
2 * EXAMPLE 15.6
3 *
4 FILE PERSNL FB(150 1800)
5 %PERSNL
35 *
36 *
37 JOB . * SELECT DESIRED RECORDS
39 IF ADDR-CITY EQ 'CHICAGO' AND SEX = 1
40 PRINT PHONE-LIST . * PRINT PHONE LIST
42 END-IF
43 *
44 REPORT PHONE-LIST LINESIZE 78
45 SEQUENCE NAME-LAST NAME-FIRST . * SORT ON NAME
47 TITLE 1 'CHICAGO AREA WOMEN AND TELEPHONE NUMBERS'
48 LINE 1 NAME-FIRST NAME-LAST TELEPHONE
-----------------------------------------------------------------------------
11/11/83 CHICAGO AREA WOMEN AND TELEPHONE NUMBERS PAGE 1
------------------------------------------------------------------------------
12/01/83 TALLY OF EMPLOYEES BY GROSS SALARY RANGE PAGE 1
PERCENT
SALARY RANGE OF PERCENT OF EMPLOYEES
HUNDRED $ INCR TALLY TOTAL EACH ASTERISK EQUALS 2%
1000 1 2.08 *
800 2 4.17 **
700 3 6.25 ***
600 1 2.08 *
500 2 4.17 **
400 4 8.33 ****
300 17 35.42 ******************
200 10 20.83 **********
100 7 14.58 *******
1 2.08 *
48 100.00
File Expansion
The Personnel master file record has run out of room, and it is necessary to
expand and reformat it.
The key to this example is the proper definition of the fields within each file. By
using the same name for the corresponding fields in each file, one MOVE LIKE
statement performs all five data moves. The MOVE statement initializes the new
fields.
1 *
2 * EXAMPLE 15.8
3 *
4 FILE PERSIN . * INPUT FILE
6 DATA-1 1 50 A
7 DATA-2 51 20 A
8 DATA-3 71 50 A
9 DATA-4 121 20 A
10 DATA-5 141 10 A
11 *
12 FILE PERSOUT FB(200 3600) . * REFORMATTED OUTPUT FILE
14 DATA-1 1 50 A
15 NEW-1 51 10 N 0
16 DATA-2 61 20 A
17 NEW-2 81 4 P
18 NEW-3 85 5 P
19 NEW-4 90 6 N 0
20 DATA-3 96 50 A
21 NEW-5 146 10 A
22 DATA-5 156 10 A
23 NEW-6 166 13 A
24 NEW-7 179 2 B
25 DATA-4 181 20 A
26 *
27 *
28 JOB FINISH WRAP-UP
29 MOVE LIKE PERSIN TO PERSOUT . * MOVE LIKE NAMED FIELDS
31 * FROM PERSIN TO PERSOUT
32 MOVE ZERO TO NEW-1 NEW-2 NEW-3 NEW-4 NEW-7
33 * INITIALIZE NUMERIC FIELDS
34 MOVE SPACE TO NEW-5 NEW-6 . * INITIALIZE ALPHA FIELDS
36 PUT PERSOUT . * OUTPUT THE REFORMATTED FILE
38 *
39 WRAP-UP. PROC
41 DISPLAY NEWPAGE 'TOTAL INPUT RECORDS = ' RECORD-COUNT(PERSIN)
42 DISPLAY SKIP 2 'TOTAL OUTPUT RECORDS = ' RECORD-COUNT(PERSOUT)
43 END-PROC
----------------------------------------------------------------------
----------------------------------------------------------------------
Note: The SEQUENCE statement specifies the region code while the CONTROL
break is based on REGION-TEXT. This enables the report to be ordered on region
code while still printing the region text.
Also, most of the printed values are generated in the BEFORE-BREAK procedure.
The order of the first two statements in that procedure is mandatory because the
second statement modifies the AVERAGE-GROSS.
1 *
2 * EXAMPLE 15.9
3 *
4 FILE PERSNL FB(150 1800)
5 %PERSNL
35 AVERAGE-GROSS W 4P 2 HEADING ('AVERAGE' 'GROSS' 'SALARY')
36 TOTAL-GROSS S 6P 2
37 PERCENT-GROSS W 3P 2 HEADING ('PERCENT OF' 'COMPANY' 'GROSS')
38 PERCENT-TALLY W 3P 2 -
HEADING('PERCENT OF' 'COMPANY' 'EMPLOYEES')
39 SALARY-RATIO W 3 P 3 HEADING('RATIO OF' '%-GROSS /' '%-TALLY')
40 TOTAL-EMPLOYEES S 3 P 0
41 REGION-TEXT W 10 A HEADING('COMPANY' 'REGION')
42 *
43 FILE RGNID TABLE INSTREAM . * DEFINE INSTREAM REGION TABLE
45 ARG 1 1 N. DESC 3 10 A. * DEFINE TABLE SPECIAL FIELD IDS
48 1 NORTHEAST
2 SOUTHEAST
3 CENTRAL
4 WEST
ENDTABLE
49 *
50 *
51 JOB
52 TOTAL-EMPLOYEES = TOTAL-EMPLOYEES + 1 . * CALCULATE TOTAL EMPLOYEES
54 AVERAGE-GROSS = PAY-GROSS . * AVERAGE = GROSS FOR EACH RECD
56 TOTAL-GROSS = TOTAL-GROSS + PAY-GROSS
57 * CALCULATE TOTAL GROSS FOR COMP
58 * SEARCH TABLE FOR MATCHING REGION INFORMATION
59 SEARCH RGNID WITH REGION GIVING REGION-TEXT
60 *
61 PRINT AVG-SALARY-RPT . * PRINT THE REPORT
63 *
64 REPORT AVG-SALARY-RPT SUMMARY LINESIZE 78
65 SEQUENCE REGION . * SORT REPORT
67 CONTROL REGION-TEXT . * BREAK SPECIFICATION
69 TITLE 1 'AVERAGE GROSS SALARY BY REGION'
70 HEADING TALLY ('NUMBER' 'OF' 'EMPLOYEES')
------------------------------------------------------------------------------
11/12/83 AVERAGE GROSS SALARY BY REGION PAGE 1
First, we select all employees in Region 3 (Central Region). For each such
employee, we search the DPTCODE table for the corresponding department
name. If no entry is found, we insert a dummy department name (*NO TABLE
ENTRY) and issue a PRINT to an error report. Regardless whether a department
name is found, we issue a PRINT statement to both the ALPHA-LIST and the
RPT-BY-DEPT reports.
Note: The use of the HEADING statement supplies alternate report headings for
the specified fields; this is the only way to change the heading for TALLY.
SOCIAL
LAST FIRST SECURITY DEPARTMENT
NAME NAME NUMBER DEPT NAME
NUMBER
DEPARTMENT LAST FIRST OF
NAME BRANCH NAME NAME EMPLOYEES
19
MISSING NUMBER
DEPARTMENT OF
CODES EMPLOYEES
942 1
944 1
The CA-Easytrieve Plus job to perform this request is quite simple; all processing
is performed in the report section. The NOPRINT option on the CONTROL
statement is used to suppress printing the summary lines.
1 *
2 * EXAMPLE 15.11
3 *
4 FILE INVMSTR FB(200 3000)
5 %INVMSTR
44 *
45 JOB
46 PRINT INV-BY-CITY . * SELECT EACH RECORD IN FILE
48 *
49 REPORT INV-BY-CITY LINESIZE 80
50 SEQUENCE LOCATION-CITY PART-NUMBER
51 CONTROL FINAL NOPRINT LOCATION-CITY NOPRINT
52 TITLE 1 'INVENTORY BY CITY ORDERED BY PART NUMBER'
53 LINE 1 LOCATION-CITY PART-NUMBER PART-DESCRIPTION
54 BEFORE-BREAK. PROC
56 DISPLAY . * ADDITIONAL SPACING BETWEEN GROUPS
58 END-PROC
PART
CITY NUMBER PART DESCRIPTION
The items must be grouped by city and must include a total for each city and a
grand total. In addition, Materials wants a summary report which lists the total
dollar value of the parts located in each city and what percentage of the total
inventory value is represented by the local totals.
CA-Easytrieve Plus produces both reports with only one pass of the Inventory
Master File.
■ The first report is similar to the previous example, without the parts
descriptions, and with added dollar values.
■ The second report requests the SUMMARY option, which prints only
summary total lines - no detail lines are printed.
The percentages are calculated in the BEFORE-BREAK procedure, using the total
of the extended values generated in the JOB activity.
1 *
2 * EXAMPLE 15.12
3 *
4 FILE INVMSTR FB(200 3000)
5 %INVMSTR
44 *
45 ITEM-EXT-VALUE W 6 P 2 HEADING('EXTENDED' 'VALUE')
46 TOTAL-EXT-VALUE S 7 P 2
47 PERCENT W 3 P 2 HEADING('PERCENT OF' 'TOTAL VALUE')
48 JOB
49 * CALC EXTENDED ITEM VALUE AND TOTAL OF ITEM VALUES
50 *
51 ITEM-EXT-VALUE = ITEM-SELLING-PRICE * ITEM-LAST-INVENTORY-QUANTITY
52 TOTAL-EXT-VALUE = TOTAL-EXT-VALUE + ITEM-EXT-VALUE
53 *
54 PRINT INV-BY-CITY . * SELECT EACH RECORD IN FILE
56 PRINT SMY-BY-CITY
57 *
58 REPORT INV-BY-CITY SPREAD LINESIZE 80
59 SEQUENCE LOCATION-CITY PART-NUMBER
60 CONTROL LOCATION-CITY
61 TITLE 1 'INVENTORY BY CITY ORDERED BY PART NUMBER'
62 LINE 1 LOCATION-CITY PART-NUMBER -
ITEM-LAST-INVENTORY-QUANTITY ITEM-SELLING-PRICE -
ITEM-EXT-VALUE
63 *
64 REPORT SMY-BY-CITY SUMMARY LINESIZE 80
65 SEQUENCE LOCATION-CITY
66 CONTROL LOCATION-CITY
67 TITLE 1 'INVENTORY VALUE SUMMARY BY CITY'
68 LINE 1 LOCATION-CITY ITEM-EXT-VALUE PERCENT
69 BEFORE-BREAK. PROC
71 PERCENT = ITEM-EXT-VALUE * 100 / TOTAL-EXT-VALUE + .005
72 END-PROC
LAST SELLING
PART INVENTORY PRICE EXTENDED
CITY NUMBER QUANTITY (DOLLARS) VALUE
LAST SELLING
PART INVENTORY PRICE EXTENDED
CITY NUMBER QUANTITY (DOLLARS) VALUE
EXTENDED PERCENT OF
CITY VALUE TOTAL VALUE
Error Correction
After reviewing the Inventory by City report in Example 15.12, shown in the
sample report, an error has been detected in the Inventory Master File. The
location for part number 000-19-360 is currently MAMMOND instead of the
correct city HAMMOND. A CA-Easytrieve Plus job can correct it easily.
The required job reads the existing file, finds the record in error, makes the
correction, generates an audit trail to reflect the change, and outputs an updated
master file. All of the records in the updated file are identical to the current file,
except the record for part number 000-19-360.
1 *
2 * EXAMPLE 15.13
3 *
4 FILE INVMSTR FB(200 3000)
5 %INVMSTR
44 UPDATE-STATUS W 6 A
45 *
46 FILE NEWMSTR FB(200 3000)
47 *
48 JOB
49 IF PART-NUMBER = 00019360 . * SCAN FOR THE RECORD IN ERROR
51 UPDATE-STATUS = 'BEFORE' . * INDICATE BEFORE UPDATE
53 PRINT AUDIT-TRAIL . * OUTPUT AUDIT TRAIL BEFORE UPDATE
55 LOCATION-CITY = 'HAMMOND' . * MODIFY RECORD
57 UPDATE-STATUS = 'AFTER' . * INDICATE AFTER UPDATE
59 PRINT AUDIT-TRAIL . * OUTPUT AUDIT TRAIL AFTER UPDATE
61 END-IF
62 *
63 PUT NEWMSTR FROM INVMSTR . * OUTPUT UPDATED FILE
65 *
66 REPORT AUDIT-TRAIL LINESIZE 80
67 TITLE 1 'INVENTORY MASTER FILE UPDATE -- AUDIT TRAIL'
68 LINE 1 PART-NUMBER LOCATION-CITY UPDATE-STATUS
PART
NUMBER CITY UPDATE-STATUS
Inventory Reduction
A new accountant for the company wants to reduce the inventory of truck parts
(commodity group 19720) by 15 percent. She thinks that this would save a
substantial amount of money (since the interest rate is so high) and, therefore,
has requested a report which indicates how much could be saved.
69 STOCK-REDUCTION-QUANT = ITEM-LAST-INVENTORY-QUANTITY -
- PROPOSED-STOCK-QUANT
70 END-IF
71 PERFORM REDUCTION-REPORT
72 *
73 REDUCTION-REPORT. PROC
75 STOCK-VALUE-SAVINGS = STOCK-REDUCTION-QUANT * LAST-PURCHASE-PRICE
76 STOCK-INT-SAVINGS = .015 * STOCK-VALUE-SAVINGS
77 PRINT SAVINGS-REPORT
78 END-PROC
79 *
80 REPORT SAVINGS-REPORT SKIP 1 LINESIZE 80
81 SEQUENCE STOCK-VALUE-SAVINGS D
82 CONTROL
83 TITLE 1 'STOCK REDUCTION ANALYSIS FOR COMMODITY GROUP 19720'
84 LINE 1 PART-NUMBER ITEM-LAST-INVENTORY-QUANTITY -
PROPOSED-STOCK-QUANT -
STOCK-VALUE-SAVINGS STOCK-INT-SAVINGS
85 LINE 2 PART-DESCRIPTION
LAST PROPOSED
PART INVENTORY STOCK STOCK VALUE STOCK INTEREST
NUMBER QUANTITY QUANTITY SAVINGS SAVINGS
CA-Easytrieve Plus provides a variety of ways to update files. One method is the
technique used in “Error Correction, Example 15.13,” but this requires an IF
statement for each record to be modified and is too cumbersome for a large
number of records.
Table Files
As data is read from the master file, a check is made against the table for a match.
■ If no match is found, the record is written unmodified.
■ If a match occurs, the quantity and inventory date are changed, the updated
record is written, and an audit report is generated.
In addition, if the inventory for a particular item has been depleted by more than
20 percent of its original value, a management report is generated.
1 *
2 * EXAMPLE 15.15
3 *
4 FILE INVMSTR FB(200 3000)
5 %INVMSTR
44 *
45 TABLE-DESC W 20 A
46 NEW-DATE TABLE-DESC 6 N 0 MASK 'Z9/99/99' -
HEADING('NEW' 'INVENTORY' 'DATE')
47 NEW-QUANT TABLE-DESC +7 5 N 0 -
HEADING('NEW' 'INVENTORY' 'QUANTITY')
48 PERCENT-DROP W 3 P 2 HEADING('PERCENT' 'DROP IN' 'INVENTORY')
49 *
50 FILE NEWMSTR FB(200 3000)
51 *
52 FILE UPDTBL TABLE INSTREAM
53 ARG 1 8 N. DESC 10 20 A
-------------------------------------------------------------------------
As complicated as this job sounds, the basic features of CA-Easytrieve Plus still
provide for a simple program. Each record in the inventory master is read.
■ If the item does not require reordering, it is output as it is to the new master
file.
■ If a reorder is required, the desired quantity is established, the
LAST-PURCHASE data is updated, an extended total for the item is
calculated, the reports are written, and the updated master file record is
output.
The three reports generated from this program demonstrate the power and
flexibility of CA-Easytrieve Plus. The first report is a simple control report which
lists all items ordered.
Note: Use the SUM statement to explicitly specify which fields to total at control
breaks. It does not make sense to total the purchase quantity or estimated item
price.
The final report is again a simple control report, but controlled on warehouse
location, instead of vendor.
Note: Again, the use of the control variable is on the title line.
1 *
2 * EXAMPLE 15.16
3 *
4 FILE INVMSTR FB(200 3000)
5 %INVMSTR
44 *
45 PO# S 10 N HEADING('PURCHASE' 'ORDER' 'NUMBER')
46 PO-DATE PO# 6 N
47 PO-SEQ PO# +6 4 N
48 EXTENDED-TOTAL W 5 P 2 HEADING('EXTENDED' 'TOTAL')
49 *
50 FILE NEWMSTR FB(200 3000)
51 *
52 JOB
53 *
54 IF ITEM-LAST-INVENTORY-QUANTITY > 4.0 * ITEM-REORDER-POINT
55 PUT NEWMSTR FROM INVMSTR . * OUTPUT NEW MASTER RECORD IF NO
57 GOTO JOB . * CHANGE, AND GET NEXT RECORD
59 END-IF
60 *
61 IF ITEM-LAST-INVENTORY-QUANTITY < ITEM-REORDER-POINT
62 LAST-PURCHASE-QUANTITY = 1.2 * LAST-PURCHASE-QUANTITY
63 END-IF
64 *
65 %GETDATE PO-DATE . * GET DATE IN MMDDYY FORMAT
84 LAST-PURCHASE-DATE = PO-DATE . * SET NEW PURCHASE DATE
86 EXTENDED-TOTAL = LAST-PURCHASE-QUANTITY * LAST-PURCHASE-PRICE
87 *
88 PRINT ACTIVITY-REPORT . * PRINT MASTER ACTIVITY REPORT
90 PRINT PURCHASE-ORDERS . * PRINT PURCHASE ORDERS
92 PRINT RECEIVING-REPORTS . * PRINT RECEIVING REPORTS
94 *
95 PUT NEWMSTR FROM INVMSTR . * OUTPUT UPDATED FILE
97 *
98 *
99 REPORT ACTIVITY-REPORT SKIP 1 SUMCTL TAG LINESIZE 80
100 SEQUENCE VENDOR-NUMBER PART-NUMBER
101 CONTROL VENDOR-NUMBER
102 SUM EXTENDED-TOTAL
103 TITLE 1 'PURCHASE ORDER ACTIVITY BY VENDOR'
104 HEADING LAST-PURCHASE-QUANTITY 'QUANTITY'
105 HEADING LAST-PURCHASE-PRICE ('ESTIMATED' 'PRICE')
106 LINE 1 VENDOR-NUMBER PART-NUMBER -
LAST-PURCHASE-QUANTITY LAST-PURCHASE-PRICE -
EXTENDED-TOTAL
107 LINE 2 VENDOR-LOCATION-CITY -2 VENDOR-LOCATION-STATE -
POS 2 PART-DESCRIPTION
108 *
109 REPORT PURCHASE-ORDERS NOADJUST SKIP 1 SUMCTL NONE LINESIZE 80
-------------------------------------------------------------------------
11/20/83 ABC COMPANY PAGE 1
PURCHASE ORDER
PO# 1120810000
VENDOR 00-00-0-562
MILW WI
47,940.00
-------------------------------------------------------------------------
PO# 1120810001
VENDOR 00-00-9-128
BAY CIT MI
9,774.00
-------------------------------------------------------------------------
PO# 1120810002
VENDOR 00-03-4-091
PHIL PA
45,500.00
-------------------------------------------------------------------------
PO# 1120810003
VENDOR 10-03-0-443
LVILLE KY
70,448.40
-------------------------------------------------------------------------
VENDOR PART
NUMBER NUMBER QUANTITY
-------------------------------------------------------------------------
11/20/83 RECEIVING REPORT FOR INDIANP WAREHOUSE PAGE 1
VENDOR PART
NUMBER NUMBER QUANTITY
-------------------------------------------------------------------------
11/20/83 RECEIVING REPORT FOR MEMPHIS WAREHOUSE PAGE 1
VENDOR PART
NUMBER NUMBER QUANTITY
-------------------------------------------------------------------------
11/20/83 RECEIVING REPORT FOR MUSKEGN WAREHOUSE PAGE 1
VENDOR PART
NUMBER NUMBER QUANTITY
Advanced Techniques
16
Introduction
This chapter provides examples of some of the advanced processing techniques
available in CA-Easytrieve Plus. These examples illustrate the use of a more
complex operating system interface and CA-Easytrieve Plus facilities.
The examples in this chapter stress one or two particular processing techniques.
Because of this, no attempt has been made to provide examples as complete as
the ones in the “Basic Examples” chapter. These examples do not have any
situation posed, as in the “Basic Examples” chapter. The preamble simply
describes the processing techniques.
The topics covered in this chapter include:
■ GET/PUT of sequential and VSAM files
■ Random access of VSAM files
READ
WRITE (add/replace/delete)
POINT
Path processing with non-unique keys
■ SORT command
SORT exit
■ Synchronized file processing
■ Advanced report features
Control LEVEL
S-fields
TERMINATION procedure
ENDPAGE procedure
SUMMARY file
■ Processing JCL parameters
■ Macro definition and processing.
NUMBER OF
REGION BRANCH EMPLOYEES
1 01 2
1 02 2
1 03 2
1 04 4
1 10
2 01 1
2 02 2
2 03 4
2 04 1
2 05 2
2 10
3 01 4
3 02 6
3 03 6
3 04 3
3 19
4 01 3
4 02 2
4 03 3
4 04 1
4 9
To highlight the most valuable stock locations, this report might be more useful
ordered by the decreasing value of the inventory for each warehouse.
To do this with CA-Easytrieve Plus, we use the multijob and summary file
facilities. The first job generates a normal summary report by location, along with
a special summary file which is used as input to the second job. For comparison
purposes, the two reports are identical except for the ordering.
Remember, use this technique when a report must be ordered, based on values
which are calculated across groups of input records. The process is easy using the
multijob and the summary file facilities.
1 *
2 * EXAMPLE 16.2
3 *
4 FILE INVMSTR FB(200 3000)
5 %INVMSTR
44 *
45 TOTAL-VALUE W 6 P 2 HEADING('TOTAL VALUE' 'OF PARTS')
46 *
47 * SUMMARY FILE DEFINITION
48 *
49 * THE SUMMARY FILE FROM THE INV-BY-CITY REPORT HAS THE FOLLOWING
50 * GENERAL FORMAT:
51 * CONTROL FIELDS + TALLY + TOTAL FIELDS
52 *
53 * FOR THIS PARTICULAR FILE IT HAS THE FOLLOWING FORMAT:
54 *
55 * LOCATION LENGTH FIELD
56 * 1 7 CONTROL FIELD - LOCATION-CITY
57 * 8 10 TALLY
58 * 18 10 TOTAL FIELD - TOTAL-VALUE
59 *
60 * NOTICE IN THE BELOW FIELD DEFINITIONS HOW THE FIELDS ARE DEFINED
61 * TO FIT WITHIN THE FORMAT. SINCE THE TALLY VALUE WILL NOT EXCEED
62 * SEVEN DIGITS, PARTS-IN-CITY ONLY DEFINES THAT PART. THE SAME IS
63 * TRUE FOR VALUE-IN-CITY. THE LENGTH OF THE RECORD IS 28 BYTES AND
64 * IT IS SPOOLED TO THE VIRTUAL FILE MANAGER.
65 *
66 FILE SMYFIL F 27 VIRTUAL
67 CITY 1 7 A
68 PARTS-IN-CITY 14 4 P 0 HEADING('NUMBER OF' 'PART TYPES')
69 VALUE-IN-CITY 22 6 P 2 HEADING('TOTAL VALUE' 'OF PARTS')
70 *
71 JOB
72 TOTAL-VALUE = LAST-PURCHASE-PRICE * ITEM-LAST-INVENTORY-QUANTITY
73 *
74 PRINT INV-BY-CITY . * SELECT EACH RECORD IN FILE
76 *
77 REPORT INV-BY-CITY SUMMARY SUMFILE SMYFIL LINESIZE 80
78 SEQUENCE LOCATION-CITY
79 CONTROL LOCATION-CITY
CHICAGO 2 233,379.60
E MOLIN 5 160,522.97
HAMMOND 1 81,982.00
INDIANP 8 191,825.42
KANS CT 1 9,737.02
MAMMOND 1 25,009.00
MEMPHIS 4 630,366.23
MUSKEGN 3 32,794.14
ST PAUL 2 162,160.05
27 1,527,776.43
-------------------------------------------------------------------------
MEMPHIS 4 630,366.23
CHICAGO 2 233,379.60
INDIANP 8 191,825.42
ST PAUL 2 162,160.05
E MOLIN 5 160,522.97
HAMMOND 1 81,982.00
MUSKEGN 3 32,794.14
MAMMOND 1 25,009.00
KANS CT 1 9,737.02
27 1,527,776.43
PART
NUMBER PART DESCRIPTION
-------------------------------------------------------------------------
PART
NUMBER PART DESCRIPTION
-------------------------------------------------------------------------
PART
NUMBER PART DESCRIPTION
-------------------------------------------------------------------------
PART
NUMBER PART DESCRIPTION
-------------------------------------------------------------------------
PART
NUMBER PART DESCRIPTION
-------------------------------------------------------------------------
PART
NUMBER PART DESCRIPTION
-------------------------------------------------------------------------
PART
NUMBER PART DESCRIPTION
-------------------------------------------------------------------------
PART
NUMBER PART DESCRIPTION
001-84-200 BUMPERS
001-85-200 DOORS
001-86-600 FENDERS
001-88-800 HUBS
-------------------------------------------------------------------------
PART
NUMBER PART DESCRIPTION
PART
NUMBER PART DESCRIPTION
-------------------------------------------------------------------------
R. M. HODGES
MATERIALS PROCUREMENT
In this example, we select all inventory records for items which cost more than
$200 and sort them by commodity group. Then, we generate control, detail, and
summary reports without SEQUENCE statements. A BEFORE sort exit performs
the required record selection.
1 *
2 * EXAMPLE 16.4
3 *
4 FILE INVMSTR FB(200 3000)
5 VENDOR-CITY 112 7 A
6 PART-PRICE 62 4 P 2
7 *
8 FILE SRTMSTR F 200 VIRTUAL
9 %INVMSTR
48 *
49 SORT INVMSTR TO SRTMSTR BEFORE SCAN-INV USING VENDOR-CITY
50 *
51 SCAN-INV. PROC
53 IF PART-PRICE > 200.00 . * SELECT PART RECORDS IF
55 SELECT . * THEY COST MORE THAN $200
57 END-IF
58 END-PROC
59 *
60 *
11/25/83 DETAIL LIST OF ALL PARTS SELLING FOR MORE THAN $200 PAGE 1
VENDOR PART
CITY NUMBER PART DESCRIPTION
-------------------------------------------------------------------------
11/25/83 CONTROLLED LIST OF PARTS SELLING FOR MORE THAN $200 PAGE 1
BY VENDOR LOCATION
VENDOR PART
CITY NUMBER PART DESCRIPTION TALLY
11/25/83 SUMMARY LIST OF PARTS SELLING FOR MORE THAN $200 PAGE 1
BY VENDOR LOCATION
VENDOR
CITY TALLY
DES MOI 1
GR BAY 1
LVILLE 1
NEWARK 1
TUPEL 1
5
The synchronized update process requires the files to be in the same order by the
defined key. This requirement causes us to add two Sort activities to the job.
From this example, you can see that the table file method is simpler for moderate
updates.
66 *
67 IF MATCHED . * IF MATCH FOUND
69 PRINT AUDIT-TRAIL . * OUTPUT AUDIT TRAIL
71 PERFORM EXCESS-CHECK . * CHECK FOR LARGE QUANT VARIATION
73 ITEM-LAST-INVENTORY-DATE = TRAN-INV-DATE . * UPDATE DATE AND
75 ITEM-LAST-INVENTORY-QUANTITY = TRAN-INV-QUAN . * QUANTITY
77 END-IF
78 *
79 * OUTPUT NEW MASTER IF MATCHED OR MASTER AND NO TRANSACTION
80 * DISPLAY ERROR MSG FOR A TRANSACTION WITH NO MATCHING MASTER
81 *
82 IF SRTMSTR
83 PUT NEWMSTR FROM SRTMSTR . * OUTPUT UPDATED FILE
85 ELSE
86 DISPLAY 'NO MASTER FILE RECORD FOR TRANSACTION ' TRAN-PART-NBR
87 END-IF
88 *
89 EXCESS-CHECK. PROC
91 IF TRAN-INV-QUAN < .8 * ITEM-LAST-INVENTORY-QUANTITY
92 PERCENT-DROP = 100 -
- (TRAN-INV-QUAN * 100 / ITEM-LAST-INVENTORY-QUANTITY)
93 PRINT MGMT-WARNING . * IF UNUSUAL DROP IN QUANTITY
95 END-IF . * INFORM THE MANAGEMENT
97 END-PROC
98 *
99 REPORT AUDIT-TRAIL LINESIZE 80
100 TITLE 1 'INVENTORY MASTER FILE UPDATE -- AUDIT TRAIL'
101 LINE 1 PART-NUMBER ITEM-LAST-INVENTORY-DATE -
ITEM-LAST-INVENTORY-QUANTITY -
TRAN-INV-DATE TRAN-INV-QUAN
102 *
103 REPORT MGMT-WARNING LINESIZE 80
104 TITLE 1 'INVENTORY WITH A 20% OR GREATER DROP IN QUANTITY'
105 LINE 1 PART-NUMBER LOCATION-CITY -
ITEM-LAST-INVENTORY-QUANTITY -
TRAN-INV-QUAN PERCENT-DROP
-------------------------------------------------------------------------
LAST NEW
PART INVENTORY INVENTORY PERCENT
NUMBER CITY QUANTITY QUANTITY DROP
This example shows how to extract VSAM CI/CA split information for review.
The Assignment statement, using the OR feature, is a way of converting the
hyphens (x'60') on the report to EBCDIC zeros (x'FO').
1 *
2 * EXAMPLE 16.6
3 *
4 FILE AMSINFO VB(125 629) WORKAREA 125
5 P-CLEAR 1 125 A
6 P-LIST-DATA 1 70 A
7 P-CLUSTER-ID 2 9 A
8 P-CLUSTER-NAME 18 40 A
9 P-COMPONENT-ID 5 5 A
10 P-SPLIT-ID 38 7 A
11 P-SPLIT-TYPE 45 2 A
12 P-SPLIT-COUNT 57 5 N
13 *
14 * WORKING STORAGE FIELDS
15 *
16 CLUSTER W 40 A
17 COMPONENT W 5 A
18 SPLIT-TYPE W 2 A
19 SPLIT-COUNT W 5 N 0
20 *
21 JOB
22 PRINT INPUT-DATA
23 *
24 IF P-CLUSTER-ID = 'CLUSTER -'
25 CLUSTER = P-CLUSTER-NAME
26 END-IF
27 *
28 IF P-COMPONENT-ID = 'DATA ', 'INDEX'
29 COMPONENT = P-COMPONENT-ID
30 END-IF
31 *
32 IF P-SPLIT-ID = 'SPLITS-'
33 SPLIT-TYPE = P-SPLIT-TYPE
34 SPLIT-COUNT = P-SPLIT-COUNT OR X'F0F0F0F0F0'
35 END-IF
36 *
37 IF SPLIT-COUNT NOT ZERO
38 PRINT SPLIT-INFO
39 SPLIT-COUNT = 0
40 END-IF
41 *
42 MOVE SPACES TO P-CLEAR * CLEAR WORKAREA AFTER EACH RECORD
44 *
45 REPORT SPLIT-INFO SPREAD LINESIZE 80
46 SEQUENCE SPLIT-TYPE CLUSTER COMPONENT
47 CONTROL SPLIT-TYPE
48 TITLE 1 'VSAM CI/CA SPLIT INFORMATION'
49 LINE 1 SPLIT-TYPE SPLIT-COUNT COMPONENT CLUSTER
50 *
51 REPORT INPUT-DATA NOHEADING LINESIZE 80 LIMIT 50
52 TITLE 1 'TYPICAL INPUT DATA FOR RUN - FIRST 50 LINES'
53 LINE 1 P-LIST-DATA
--------------------------------------------------------------------------------
SORT (DEVICE SYSDA ALTSEQ NO MSG DEFAULT MEMORY MAX WORK 3) VFM ( 16 D
--------------------------------------------------------------------------------
CI 23 DATA ABELMAN.MACRO.FILE
4 DATA VARVERI.MACRO.LIBRARY
CI 27
27
To demonstrate the use of CA-Easytrieve Plus with VSAM files, two data
structures are built from the Personnel Master File. The first structure is an ESDS
cluster, with the same format as the sequential file used in the “Basic Examples”
chapter. In addition, an alternate index is built across the ESDS, keyed on the
employee number. A path is defined for the combination of the alternate index
and the base ESDS cluster.
The second structure is a KSDS cluster, built from the Personnel Master File,
keyed on the employee number. A non-unique alternate index is built across the
KSDS cluster, keyed on the department number. Also, a path is defined for this
alternate index and KSDS cluster combination.
This example shows how to define and load a VSAM data set using
CA-Easytrieve Plus. In this example, we build the two VSAM structures
described previously. First, we define the base clusters through IDCAMS.
Define Base Clusters through IDCAMS
* EXAMPLE 16.7A
DELETE (RETSYS$.PERSNL.KSDS/MSTPER)
DELETE (RETSYS$.PERSNL.ESDS/MSTPER)
SET MAXCC = 0
DEFINE CLUSTER -
(NAME(RETSYS$.PERSNL.KSDS) -
RECORDS(50 10) VOLUMES(USER53) -
KEYS(5 8) OWNER(EZTP) -
RECORDSIZE(150 150) -
UPDATEPW(UPDPER) MASTERPW(MSTPER)) -
DATA (NAME(RETSYS$.PERSNL.KSDS.DATA)) -
INDEX(NAME(RETSYS$.PERSNL.KSDS.INDEX))
DEFINE CLUSTER -
(NAME(RETSYS$.PERSNL.ESDS) -
RECORDS(50 10) VOLUMES(USER53) -
NONINDEXED OWNER(EZTP) -
RECORDSIZE(150 150) -
UPDATEPW(UPDPER) MASTERPW(MSTPER)) -
DATA (NAME(RETSYS$.PERSNL.ESDS.DATA))
Next, a CA-Easytrieve Plus job is used to load the data into the VSAM clusters
from the sequential version of the Personnel Master File. A SORT is required to
order the KSDS input by employee number.
1 *
2 * EXAMPLE 16.7B
3 *
4 FILE PERSNL FB(150 1800)
5 %PERSNL
35 *
36 FILE PERESDS VS(ES PASSWORD 'UPDPER' CREATE)
37 *
38 FILE PERKSDS VS(PASSWORD 'UPDPER' CREATE)
39 *
40 FILE TWORK F 150 VIRTUAL
41 *
42 JOB FINISH WRAP-UP
43 PUT PERESDS FROM PERSNL . * BUILD ESDS VERSION OF PERSNL
45 *
46 WRAP-UP. PROC
48 DISPLAY NEWPAGE 'TOTAL RECORDS WRITTEN TO PERESDS = ' -
RECORD-COUNT(PERESDS)
49 END-PROC
50 *
51 SORT PERSNL TO TWORK USING EMP# . * SORT PERSNL INTO EMP# ORDER
53 *
54 JOB FINISH WRAP-UP
55 PUT PERKSDS FROM TWORK . * BUILD KSDS VERSION OF PERSNL
57 *
58 WRAP-UP. PROC
60 DISPLAY NEWPAGE 'TOTAL RECORDS WRITTEN TO PERKSDS = ' -
RECORD-COUNT(PERKSDS)
61 END-PROC
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
Now that the base clusters are built, use IDCAMS to define and build the
alternate indexes, and also to define the paths.
* EXAMPLE 16.7C
DEFINE ALTERNATEINDEX -
(NAME(RETSYS$.PERSNL.ESDS.AX) -
RELATE(RETSYS$.PERSNL.ESDS/MSTPER) -
RECORDS(50 10) VOLUMES(USER53) -
KEYS(5 8) MASTERPW(MSTPER) -
OWNER(PRO) RECORDSIZE(17 34) -
REUSE SPEED UNIQUEKEY) -
DATA -
(NAME(RETSYS$.PERSNL.ESDS.AX.DATA)) -
INDEX -
(NAME(RETSYS$.PERSNL.ESDS.AX.INDEX))
DEFINE ALTERNATEINDEX -
(NAME(RETSYS$.PERSNL.KSDS.AX) -
RELATE(RETSYS$.PERSNL.KSDS/MSTPER) -
RECORDS(50 10) VOLUMES(USER53) -
KEYS(3 97) MASTERPW(MSTPER) -
OWNER(PRO) RECORDSIZE(28 99) -
REUSE SPEED NONUNIQUEKEY) -
DATA -
(NAME(RETSYS$.PERSNL.KSDS.AX.DATA)) -
INDEX -
(NAME(RETSYS$.PERSNL.KSDS.AX.INDEX))
BLDINDEX -
IDS(RETSYS$.PERSNL.ESDS/MSTPER) -
ODS(RETSYS$.PERSNL.ESDS.AX/MSTPER)
BLDINDEX -
IDS(RETSYS$.PERSNL.KSDS/MSTPER) -
ODS(RETSYS$.PERSNL.KSDS.AX/MSTPER)
DEFINE PATH -
(NAME(RETSYS$.PERSNL.ESDS.PATH) -
PATHENTRY(RETSYS$.PERSNL.ESDS.AX))
DEFINE PATH -
(NAME(RETSYS$.PERSNL.KSDS.PATH) -
PATHENTRY(RETSYS$.PERSNL.KSDS.AX))
This example demonstrates the random reading and updating of a VSAM KSDS
cluster. The ESDS is in the original order of the Personnel Master file; it is a
reproduction of the sequential version. The file is in order by region number.
In this example, we read all of the records with a region code of 1 from the ESDS.
We then use the employee number as the key for the KSDS. The KSDS record is
read, modified, and updated on the file. This is a typical random update
operation using an input tickler file.
1 *
2 * EXAMPLE 16.8
3 *
4 FILE PERESDS VS ES
5 REGION-CODE 1 1 N
6 EMP-NBR 9 5 N
7 *
8 FILE PERKSDS VS(PASSWORD 'UPDPER' UPDATE)
9 %PERSNL
39 *
40 JOB
41 IF REGION-CODE GT 1
42 STOP . * STOP IF DONE WITH REGION CODE 1
44 END-IF
45 *
46 READ PERKSDS KEY EMP-NBR
47 PRINT BEFORE-UPDATE . * PRINT BEFORE-UPDATE INFO
49 PAY-GROSS = 1.05 * PAY-GROSS . * GIVE EVERYONE IN REGION 1 A 5% RAISE
51 WRITE PERKSDS UPDATE . * UPDATE THE FILE
53 *
54 REPORT BEFORE-UPDATE LINESIZE 80
55 SEQUENCE EMP#
56 TITLE 1 'REGION 1 EMPLOYEES GROSS SALARIES BEFORE UPDATE'
57 LINE 1 EMP# NAME-LAST NAME-FIRST PAY-GROSS
58 *
59 *
60 JOB INPUT PERKSDS
61 IF REGION = 1
62 PRINT AFTER-UPDATE . * SHOW UPDATED SALARIES
64 END-IF
65 *
66 REPORT AFTER-UPDATE LINESIZE 80
67 SEQUENCE EMP#
68 TITLE 1 'REGION 1 EMPLOYEES GROSS SALARIES AFTER UPDATE'
69 LINE 1 EMP# NAME-LAST NAME-FIRST PAY-GROSS
-------------------------------------------------------------------------
This example reads employee records looking for a specified department. The
POINT command is used against the department path to the KSDS. The STATUS
parameter of the POINT command detects invalid department codes. The DO
WHILE construct provides a simple method of reading records sequentially until
the department code changes or we reach end-of-file.
1 *
2 * EXAMPLE 16.9
3 *
4 FILE DEPTCOD F 80
5 DEPARTMENT 1 3 N
6 *
7 FILE PTHKSDS VS
8 %PERSNL
38 *
39 JOB
40 POINT PTHKSDS EQ DEPARTMENT STATUS
41 IF PTHKSDS:FILE-STATUS NE 0
42 DISPLAY 'NO EMPLOYEES IN DEPARTMENT ' DEPARTMENT
43 GOTO JOB
44 END-IF
45 *
46 GET PTHKSDS . * GET FIRST DEPT RECORD
48 DO WHILE PTHKSDS AND DEPARTMENT = DEPT . * LOOP WHILE VALID DEPT
50 PRINT SELECTED-DEPARTMENTS . * PRINT REPORT
52 GET PTHKSDS . * GET NEXT RECORD IN DEPT
54 END-DO
55 *
56 REPORT SELECTED-DEPARTMENTS LINESIZE 80
57 CONTROL DEPT NOPRINT
58 TITLE 1 'SELECTED DEPARTMENTS VIA VSAM PATH PROCESSING'
59 LINE 1 DEPT EMP# NAME-LAST NAME-FIRST
61 *
62 * VALIDATE PREVIOUS UPDATE
63 JOB
64 IF REGION > 2
65 STOP . * STOP IF PAST RECORDS OF INTEREST
67 END-IF
68 IF REGION NE 2
69 GOTO JOB . * IGNORE IF NOT DESIRED REGION
71 END-IF
72 *
73 PRINT VALIDATION . * PRINT VALIDATION
75 *
76 REPORT VALIDATION LINESIZE 80
77 SEQUENCE BRANCH EMP#
78 TITLE 1 'UPDATE VALIDATION -- REGION 2 SALARY CHANGE'
79 LINE 1 BRANCH EMP# NAME-LAST NAME-FIRST PAY-GROSS
NEW
EMPLOYEE LAST FIRST GROSS GROSS
BRANCH NUMBER NAME NAME PAY SALARY
-------------------------------------------------------------------------
This example shows how to delete and add records to a VSAM KSDS. The
employee numbers of three employees must be changed. Since the file is keyed
on the employee number, each record must be deleted and then added again
with the new employee number. The automatic input file contains the transaction
records.
In the first job activity, each record to be deleted is read. If it is not present, an
error message is issued. Otherwise, the employee number is changed, a copy is
placed in a sequential work file for later addition, the original record is deleted,
and an audit report is generated.
In the second job activity, the records written to the work file are read by
automatic input. A READ is performed to make sure no existing record in the
file has the new employee number; if so, an error message is issued. Otherwise,
the employee record with the new employee number is added to the file. A
READ is issued to validate the ADD; this is not done typically, but is done here to
show that the ADD actually occurred. An audit report is output.
1 *
2 * EXAMPLE 16.11
3 *
4 FILE TRANS F 80
5 OLD-EMP# 1 5 N
6 NEW-EMP# 7 5 N
7 *
8 FILE PERKSDS VS(PASSWORD 'UPDPER' UPDATE)
9 %PERSNL
39 *
40 FILE PERSTMP F 150 VIRTUAL . * TEMP HOLD FILE FOR RECORDS
42 TMP-EMP# 9 5 N
43 *
44 JOB
45 READ PERKSDS KEY OLD-EMP# STATUS
46 IF PERKSDS:FILE-STATUS NE 0
47 DISPLAY 'INVALID EMPLOYEE NUMBER ' OLD-EMP#
48 GOTO JOB . * TRY NEXT TRANSACTION
50 END-IF
51 *
52 TMP-EMP# = NEW-EMP# . * SET NEW EMP# INTO RECORD
54 PUT PERSTMP FROM PERKSDS . * SAVE RECORD FOR SECOND JOB
56 WRITE PERKSDS DELETE . * DELETE THE OLD RECORD
58 PRINT AUDIT-REPORT . * PRINT THE AUDIT
60 *
61 REPORT AUDIT-REPORT LINESIZE 80
62 TITLE 1 'AUDIT REPORT -- EMPLOYEE NUMBER CHANGE ACTIVITY'
63 TITLE 2 'FIRST PASS -- DELETED RECORDS'
64 LINE 1 OLD-EMP# NAME-LAST NAME-FIRST
65 *
66 *
67 JOB INPUT PERSTMP
68 READ PERKSDS KEY TMP-EMP# STATUS . * VALIDATE KEY
70 IF PERKSDS:FILE-STATUS EQ 0
71 DISPLAY 'EMP# ALREADY ON FILE - ' TMP-EMP#
72 GOTO JOB
73 END-IF
74 WRITE PERKSDS ADD FROM PERSTMP . * WRITE NEW RECORD
76 READ PERKSDS KEY TMP-EMP# . * VALIDATE WRITE (OPTIONAL)
78 PRINT AUDIT-REPORT . * PRINT AUDIT REPORT
80 *
81 REPORT AUDIT-REPORT LINESIZE 80
82 TITLE 1 'AUDIT REPORT -- EMPLOYEE NUMBER CHANGE ACTIVITY'
83 TITLE 2 'SECOND PASS -- ADD RECORDS'
84 LINE 1 TEMP-EMP# NAME-LAST NAME-FIRST
LAST FIRST
OLD-EMP# NAME NAME
-------------------------------------------------------------------------
GETDATE Macro
CA-Easytrieve Plus provides a macro facility to ease the burden of repetitive
coding. Typically, a macro might contain file and field definitions and be used as
a data dictionary. This technique is demonstrated in almost every example in this
guide. Another use of the macro facility is to store functions, such as field
reformatting, and report definitions, as illustrated in Examples 16.12A and 16.12B
(shown below).
Example 16.12A is a macro to obtain the system date and strip out the slashes. It
was also used in Example 15.14 (as shown in the “Basic Examples” chapter). The
macro is defined with a single positional parameter -- the receiving field. All
other required fields are defined within the macro.
* EXAMPLE 16.12A
MACRO USER-DATE
*
* GET THE CURRENT DATE AND PUT INTO USER FIELD LESS SLASHES
*
DEFINE GETDATE-DATE W 8 A
DEFINE GETDATE-FIRST6 GETDATE-DATE 6 N
DEFINE GETDATE-LAST5 GETDATE-DATE +3 5 A
DEFINE GETDATE-LAST6 GETDATE-DATE +2 6 A
DEFINE GETDATE-LAST3 GETDATE-DATE +5 3 A
DEFINE GETDATE-LAST2 GETDATE-DATE +6 2 A
GETDATE-DATE = SYSDATE . * MOVE ALL 8
GETDATE-LAST3 = GETDATE-LAST2 . * SHIFT LEFT OVER NEXT /
GETDATE-LAST6 = GETDATE-LAST5 . * SHIFT LEFT OVER FIRST /
&USER-DATE = GETDATE-FIRST6 . * MOVE TO USER FIELD
-----------------------------------------------------------------------
CONCAT Macro
This is an example of a macro which concatenates two fields into one, with
variable spacing between fields. Following is the macro definition:
* EXAMPLE 16.13A
*
MACRO RECEIVE SPACE PART2
*
* CONCAT MACRO
* FORMAT:
* %CONCAT RECEIVE N PART2
*
* IT PERFORMS AS:
* RECEIVE = RECEIVE +SPC(N) + PART2
*
DEFINE CONCAT-HOLD W 254 A
DEFINE CONCAT-SCAN CONCAT-HOLD 1 A INDEX CONCAT-NDX
DEFINE CONCAT-LENGTH W 2 P 0
CONCAT-NDX = 253 . * START AT END
CONCAT-HOLD = &RECEIVE . * COPY PART1
DO WHILE CONCAT-SCAN EQ ' ' AND CONCAT-NDX GE 0
CONCAT-NDX = CONCAT-NDX - 1 . * FIND 1ST #BLANK
END-DO
CONCAT-NDX = CONCAT-NDX + 1 + &SPACE . * DO SPACES FACTOR
CONCAT-LENGTH = 253 - CONCAT-NDX
MOVE &PART2 TO CONCAT-SCAN CONCAT-LENGTH . * MOVE PART 2 AFTER
&RECEIVE = CONCAT-HOLD . * GIVE BACK TO USER
------------------------------------------------------------------------
SEE HOW
SEE HOW IT PUTS
SEE HOW IT PUTS THE PARTS
SEE HOW IT PUTS THE PARTS TOGETH
SEE HOW IT PUTS THE PARTS TOGETHER
A START procedure receives control at the beginning of the job. This procedure
calls a subprogram which moves the PARM information into a CA-Easytrieve
Plus field. A JCL parameter can be from 1 to 100 characters long. The maximum
length of the field you defined (PARM-DATA in this case) must be specified in
PARM-LTH. The subprogram, EZTPX01, moves up to 10 characters from the JCL
PARM-DATA, in this example.
In this example, the expected JCL parameter is defined to be three digits; the first
digit specifies the region number and the next two contain the branch number.
The format and content of the parameter is validated after calling EZTPX01. A
PARM-LTH of 10 was used to detect either a missing JCL parameter or one
which is not the correct length. If PARM-LTH = 3 was coded, CA-Easytrieve Plus
could not detect a parameter which was longer than 3, since EZTPX01 would
truncate it to three characters.
Note: The use of field redefinition defines subfields of the JCL parameter. The
value of the JCL parameter is 302 for this example.
58 PARM-LTH = 10
59 CALL EZTPX01 USING (PARM-REGISTER PARM-INFO)
60 IF PARM-LTH NE 3
61 DISPLAY SKIP 3 '******* MISSING OR INVALID JCL PARM'
62 STOP EXECUTE
63 END-IF
64 IF SELECT-REGION NE 1 THRU 4
65 DISPLAY SKIP 3 '******* INVALID REGION NUMBER'
66 STOP EXECUTE
67 END-IF
68 IF SELECT-BRANCH NE 1 THRU 5
69 DISPLAY SKIP 3 '******* INVALID BRANCH NUMBER'
70 STOP EXECUTE
71 END-IF
72 END-PROC
73 *
74 REPORT LINESIZE 70
75 TITLE 'EMPLOYEES IN REGION' -2 SELECT-REGION -
'BRANCH' -2 SELECT-BRANCH
76 LINE NAME-FIRST NAME-LAST EMP#
Bank System
17
Introduction
The BANK system is a combination of online and batch processing which
illustrates the adaptability of CA-Easytrieve Plus to a wide range of
environments, and demonstrates a variety of coding techniques. This system is a
sample application for a BANK, but could be adapted to other applications with
minor modifications. However, implementation of a system as sophisticated as
this requires considerable knowledge of generalized program development and
substantial experience in data processing. If your professional expertise lies
primarily in other fields, you do need help from your data center to undertake
this task.
A common need is to have ready access to data; that is, the ability to quickly
locate and modify specific items. This requires the means to search a file for a
certain record or set of records and, once located, to update the record. This
ready access is typically called online processing. Online processing offers speed
and flexibility advantages over batch processing. When you are working online
you can access any record, look at it on a terminal, and perform any function
based on the values in the record at that time. A batch job requires you to specify
in advance not only which records to access, but what functions to perform on
them.
Online access is most appropriate for accessing a small number of records and
performing varied activities, such as deleting one record, changing the name on
another, and adding a middle initial to a third. A batch job is more efficient to list
all records from a file, or to read all records from a file and to choose certain
individuals to receive a letter.
Online Processing
The online portion of this system runs under TSO, CMS, or ICCF. The discussion
in this chapter assumes TSO. The data is stored on a key-sequenced VSAM data
set (KSDS) created by running the IDCAMS utility with the following commands:
DEFINE CLUSTER (NAME ('your.bank.masterfile') -
KEYS (6 0) -
REUSE -
VOLUMES (volser) -
RECORDSIZE (200 200) -
RECORDS (50 50) )
This group of statements defines the file to the system and must be followed by
an initialization job to prepare the file for processing, as illustrated in Example
17.1 below.
As previously mentioned, the master file used is a key-sequenced data set whose
key is a derived field - the record number. Therefore, the first record added to the
file has a key of 000001, the second 000002, and so forth.
The record number (key) of the next available record on the file is stored in field
'NEXT-ID' of record zero. This field is set to a value of 000001 by the initialization
job. As data is added to the file by subsequent processing, this field is updated.
The key field is the first six bytes of each record. The other fields are:
PERS-TITLE (i.e. MR, MRS, MISS, MS)
FIRST-NAME
LAST-NAME
MIDDLE-INITIAL
ADDRESS LINE 1
ADDRESS LINE 2
CITY
STATE
ZIP
LOCAL INDICATOR (YES,NO)
CREDIT RATING (0-9)
SAVINGS ACCOUNT (YES,NO)
CHECKING (YES,NO)
SAFE DEPOSIT (YES,NO)
C AND D (YES,NO)
ALL SAVERS (YES,NO)
VISA (YES,NO)
MASTER CARD (YES,NO)
MONEY MARKET (YES,NO)
TREASURY BILL (YES,NO)
Once the IDCAMS and initialization jobs are run, you can begin adding data to
the file.
The first step is to log onto TSO and create the Job Control Setup command list
(CLIST), as follows:
* BANK CLIST FOR TSO
FREE F(SYSIN SYSPRINT PANDD1 CUST TERMIN EZTVFM)
ALLOC F(PANDD1) DA ('your macro library') SHR
ALLOC F(SYSPRINT) DA(*)
ALLOC F(TERMIN) DA(*)
ALLOC F(CUST) DA('your bank masterfile') SHR
ALLOC F(SYSIN) DA(*)
ALLOC F(EZTVFM) SP(2,2) CYL
CALL 'your program library(EZTPA00)'
The system introduces itself and prepares to accept commands. The valid
commands and their descriptions are:
ADD
This command is used to add a new record to a file. After you enter the ADD
keyword, the system displays the attributes (number, name, length, and type) of
each field of the next available record, in order by field number, and asks you to
enter a value for that field.
When you have entered data into the last field of the new record, the system
displays its record number (key) as a customer ID.
BROWSE
To search for a field, enter the field number. The system displays the attributes of
that field and asks you to enter a value. When you finish entering the search
values for one record, you can enter NEXT to begin entering search values for the
next record, or END to terminate the search and begin the BROWSE activity.
Only those records that have all fields equal to the search data can be displayed.
Repeat END to terminate BROWSE. The last record read is the current record
that can be used by DISPLAY, DEL, or UPD.
DEL
This command deletes a record. After you enter the DEL keyword, the system
displays the ID of the current record and asks if this is the one you want.
■ If you enter YES, that record is deleted.
■ If you enter NO, the system requests the ID of the desired record, and deletes
the record you specify.
DISPLAY
This command displays the fields of the current record or any other record you
specify. After you enter the DISPLAY keyword, the system displays the ID of the
current record and asks if this is the one you want.
■ If you answer YES, the fields of that record are displayed.
■ If you answer NO, the system requests the ID of the desired record and
displays the fields of the record you specify.
ECHO
END
This command terminates the current activity; when used on the primary
command line it terminates the session. When in BROWSE or UPDate processing,
this command terminates the field value specification phase and begins the
BROWSE or UPDate activity.
ESC
This command is valid at anytime and returns you to the major command entry
of the session. It is useful when you are in the middle of processing a command
which you do not want to continue.
NOECHO
UPD
This command enables you to enter UPDate mode. If a record is active from a
previous activity, its ID is displayed and the system asks if this is the one you
want. If you enter NO, the system requests the ID of the desired record. Once
that record is found, the system requests the field number of the field to be
updated. That field's attributes are displayed and the system requests new data.
This process of specifying a field number and entering new data continues until
you enter END. The system then inquires whether you are ready to update.
■ If you answer NO, you return to specifying field numbers and entering new
data.
■ If you answer YES, the record is updated.
The CA-Easytrieve Plus coding required for the BANK system and the sample
terminal session using this system are illustrated in Example 17.2, as shown in
the next two exhibits. The first page of this example provides a listing of the
macro %BANKLIB, which is used throughout the BANK system.
BANKLIB Macro
MACRO 0 VSAMOPT 'UPDATE'
*
* COMMON TABLE FILE TO DEFINE ACCOUNT TYPES
*
FILE ACCTNAME TABLE INSTREAM
ARG 1 2 N
DESC 4 30 A
01 SAVINGS
02 CHECKING
03 SAFE DEPOSIT
04 CERTIFICATE OF DEPOSIT
05 ALL SAVERS
06 VISA
07 MASTER CARD
08 MONEY MARKET
09 TREASURY BILL
ENDTABLE
*
* BANK CUSTOMER FILE DESCRIPTION
*
FILE CUST VS(F &VSAMOPT) WORKAREA 200
*
CUST-ID 1 6 N
NAME 7 25 A
PERS-TITLE 7 4 A
FIRST-NAME 11 10 A
LAST-NAME 21 15 A
MIDDLE-INITIAL 36 1 A
ADDRESS1 38 25 A
ADDRESS2 63 25 A
CITY 88 15 A
STATE 103 2 A
ZIP 105 9 A
LOCAL 114 1 A
CREDIT-RATING 115 1 A -
HEADING ('CREDIT' 'RATING')
ACCT-DATA 116 9 A
SAVINGS 116 1 N 0
CHECKING 117 1 N 0
SAFE-DEPOSIT 118 1 N 0 -
HEADING ('SAFE' 'DEPOSIT')
C-AND-D 119 1 N 0
ALL-SAVERS 120 1 N 0 -
HEADING ('ALL' 'SAVERS')
VISA 121 1 N 0
MASTER-CARD 122 1 N 0 -
HEADING ('MASTER' 'CARD')
MONEY-MARKET 123 1 N 0 -
HEADING ('MONEY' 'MARKET')
T-BILL 124 1 N 0
ACCT-IND ACCT-DATA 1 N 0 -
OCCURS 9 INDEX ACCT-NDX
*
ACCT-MAX W 2 P 0 VALUE 9
CUST-KEY W 6 N
*
521 END-DO
522 DISPLAY DSP-LINE
523 DISPLAY 'ENTER COMMAND'
524 PERFORM GET-LINE
525 IF CMD-IN SPACE AND CMD-DEFAULT GT 0
526 CMD-ID = CMD-DEFAULT
527 CMD-FND = 'Y'
528 GOTO NOT-FOUND
529 END-IF
530 CMD-NDX = 0
531 MOVE CMD-NAME CMD-LEN TO CMD-HOLD
532 DO WHILE CMD-HOLD NE CMD-IN OR CMD-STATE NE CUR-STATE -
OR TERM-LEN NE CMD-LEN
533 IF CMD-LEN EQ 0 . * ZERO LEN IS END OF TABLE
535 DISPLAY 'INVALID COMMAND:' CMD-IN
536 GOTO NOT-FOUND
537 ELSE
538 CMD-NDX = CMD-NDX + CMD-LEN + CMD-OVHD
539 MOVE CMD-NAME CMD-LEN TO CMD-HOLD
540 END-IF
541 END-DO
542 CMD-FND = 'Y'
543 CMD-ID = CMD-NO
544 NOT-FOUND
545 END-DO
546 END-PROC
547 *
548 GET-FIELD. PROC
550 *
551 * GET ONE FIELD FROM THE USER FIELD NUMBER IS IN 'FIELD-ID'
552 * LOOP UNTIL A VALID FIELD IS ENTERED
553 *
554 SEARCH FIELDTBL WITH FIELD-ID GIVING FIELD-DATA
555 FIELD-ERR = 'Y'
556 IF NOT FIELDTBL
557 DISPLAY 'ERROR INVALID FIELD NUMBER'
558 GOTO GET-FIELD-ERR
559 END-IF
560 DO WHILE FIELD-ERR = 'Y'
561 DISPLAY 'ENTER VALUE FOR FIELD:' FIELD-ID +1 FIELD-NAME -
'(' FIELD-TYPE ',' FIELD-LEN ' CHARACTERS)'
562 PERFORM GET-LINE
563 PERFORM FIELD-EDIT-MOVE
564 END-DO
565 GET-FIELD-ERR
566 END-PROC
567 *
568 GET-FIELD-NUMBER. PROC
570 *
571 * THIS ROUTINE ASKS FOR A NUMBER OF A FIELD
572 * LOOP UNTIL VALID NUMBER ENTERED
573 *
574 GET-FIELD-LOOP
575 PERFORM GET-LINE
576 IF FIRST3 = 'END'
577 GOTO GOT-FIELD-NUMBER
578 END-IF
579 IF TERM-LEN NE 3 OR TERM-FIELD-NO NOT NUMERIC
580 DISPLAY 'NUMBER MUST BE 3 DIGITS NUMERIC'
581 GOTO GET-FIELD-LOOP
582 END-IF
583 GOT-FIELD-NUMBER
584 END-PROC
585 *
586 GET-LINE. PROC
588 *
655 *
656 HELLO. PROC
658 *
659 * START PROCEDURE, INTRODUCE YOURSELF, READ RECORD 0 TO GET
660 * NEXT FREE KEY
661 *
662 * TEST FOR EXISTANCE OF NEXT RECORD, IF IT IS THERE THEN SOME ERROR
663 * OCCURED DURING THE LAST DATA ENTRY SESSION
664 * THEN FIND NEXT AVAILABLE SLOT
665 *
666 DISPLAY NEWPAGE 'HELLO, WELCOME TO BRILLIG BANKS DATA ENTRY SYSTEM'
667 CUST-KEY = 0
668 READ CUST KEY CUST-KEY STATUS
669 PERFORM CUST-FILE-TEST
670 NEXT-KEY = NEXT-ID
671 POINT CUST GE NEXT-KEY . * TEST FOR ERROR
673 IF NOT EOF CUST
674 DISPLAY 'INITIALIZATION ERROR, READING TILL FREE RECORD'
675 END-IF
676 DO WHILE NOT EOF CUST
677 DISPLAY 'CUSTOMER ID:' NEXT-KEY ' FOUND, SKIPPING TO NEXT'
678 NEXT-KEY = NEXT-KEY + 1 . * IF THERE THEN ERROR
680 POINT CUST GE NEXT-KEY . * LAST UPDATE SESSION
682 END-DO
683 END-PROC
684 *
685 NEXT-RECORD. PROC
687 GET CUST STATUS
688 PERFORM CUST-FILE-TEST
689 IF CUST
690 CUST-KEY = CUST-ID
691 ELSE
692 CUST-KEY = 0
693 END-IF
694 END-PROC
695 *
696 READ-CUST. PROC
698 *
699 * READ ONE RECORD, KEY:CUST-KEY
700 *
701 READ CUST KEY CUST-KEY STATUS
702 IF CUST
703 CUST-ERR = 'N'
704 ELSE
705 DISPLAY 'ERROR, CUSTOMER NOT FOUND:' CUST-KEY
706 END-IF
707 END-PROC
708 *
709 SELECT-RECORD. PROC
711 ANSWER = 'N'
712 IF CUST-KEY GT 0
713 DISPLAY 'CURRENT CUSTOMER IS:' CUST-KEY
714 DISPLAY 'IS THIS THE DESIRED RECORD(Y/N)?'
715 PERFORM GET-YES-NO
716 END-IF
717 IF ANSWER = 'Y'
718 PERFORM READ-CUST
719 ELSE
720 PERFORM FIND-CUST
721 END-IF
722 END-PROC
723 *
724 UPDATE-RECORD. PROC
726 *
727 * THIS RECORD WILL UPDATE THE FIELDS OF THE CURRENT RECORD
728 * THE USER SELECTS, BY FIELD NUMBER, THE FIELD TO UPDATE
ADD
ENTER VALUE FOR FIELD:001 TITLE (A,04 CHARACTERS)
MR
ENTER VALUE FOR FIELD:002 FIRST NAME (A,10 CHARACTERS)
TOM
ENTER VALUE FOR FIELD:003 LAST NAME (A,15 CHARACTERS)
LEONARD
ENTER VALUE FOR FIELD:004 MIDDLE INITIAL (A,01 CHARACTERS)
CALCULAS
ENTER VALUE FOR FIELD:008 STATE (A,02 CHARACTERS)
CA
ENTER VALUE FOR FIELD:009 ZIP (X,09 CHARACTERS)
31095
ENTER VALUE FOR FIELD:010 IS IT LOCAL (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:011 CREDIT RATING (N,01 CHARACTERS)
5
ENTER VALUE FOR FIELD:012 SAVINGS (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:013 CHECKING (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:015 C AND D (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:016 ALL SAVERS (Q,01 CHARACTERS)
Y
ENTER VALUE FOR FIELD:017 VISA (Q,01 CHARACTERS)
Y
ENTER VALUE FOR FIELD:018 MASTER CARD (Q,01 CHARACTERS)
Y
ENTER VALUE FOR FIELD:019 MONEY MARKET (Q,01 CHARACTERS)
Y
ENTER VALUE FOR FIELD:020 T BILL (Q,01 CHARACTERS)
N
CUSTOMER 000001 ADDED
VALID COMMANDS ARE:ESC, END, DISPLAY, ADD, UPD, DEL, ECHO, NOECHO, BROWSE
ENTER COMMAND
ADD
ENTER VALUE FOR FIELD:001 TITLE (A,04 CHARACTERS)
MISS
ENTER VALUE FOR FIELD:002 FIRST NAME (A,10 CHARACTERS)
JANE
ENTER VALUE FOR FIELD:003 LAST NAME (A,15 CHARACTERS)
NEARY
ENTER VALUE FOR FIELD:004 MIDDLE INITIAL (A,01 CHARACTERS)
I
ENTER VALUE FOR FIELD:005 ADDRESS LINE 1 (X,25 CHARACTERS)
MARLBOUROUGH
ENTER VALUE FOR FIELD:008 STATE (A,02 CHARACTERS)
VA
ENTER VALUE FOR FIELD:009 ZIP (X,09 CHARACTERS)
22211
ENTER VALUE FOR FIELD:010 IS IT LOCAL (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:011 CREDIT RATING (N,01 CHARACTERS)
8
ENTER VALUE FOR FIELD:012 SAVINGS (Q,01 CHARACTERS)
Y
ENTER VALUE FOR FIELD:013 CHECKING (Q,01 CHARACTERS)
Y
ENTER VALUE FOR FIELD:015 C AND D (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:016 ALL SAVERS (Q,01 CHARACTERS)
Y
ENTER VALUE FOR FIELD:017 VISA (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:018 MASTER CARD (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:019 MONEY MARKET (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:020 T BILL (Q,01 CHARACTERS)
Y
CUSTOMER 000002 ADDED
VALID COMMANDS ARE:ESC, END, DISPLAY, ADD, UPD, DEL, ECHO, NOECHO, BROWSE
ENTER COMMAND
BROWSE
YOU CAN ENTER UP TO 20 QUERIES FOR THE SEARCH
THE QUERIES WILL BE 'ANDED' TOGETHER
ENTER FIELD NUMBER FOR SEARCH 'END' WHEN DONE
002
ENTER VALUE FOR FIELD:002 FIRST NAME (A,10 CHARACTERS)
TOM
ENTER FIELD NUMBER FOR SEARCH 'END' WHEN DONE
001
ENTER VALUE FOR FIELD:001 TITLE (A,04 CHARACTERS)
MR
ENTER FIELD NUMBER FOR SEARCH 'END' WHEN DONE
END
CUST-ID:000001
FIELD:001 TITLE MR
FIELD:002 FIRST NAME TOM
FIELD:003 LAST NAME LEONARD
FIELD:004 MIDDLE INITIAL
FIELD:005 ADDRESS LINE 1 1781 ORANGE PLACE
FIELD:006 ADDRESS LINE 2
FIELD:007 CITY CALCULAS
FIELD:008 STATE CA
FIELD:009 ZIP 31095
FIELD:010 IS IT LOCAL N
FIELD:011 CREDIT RATING 5
FIELD:012 SAVINGS N
FIELD:013 CHECKING N
FIELD:014 SAFE DEPOSIT BOX N
FIELD:015 C AND D N
FIELD:016 ALL SAVERS Y
FIELD:017 VISA Y
FIELD:018 MASTER CARD Y
FIELD:019 MONEY MARKET Y
FIELD:020 T BILL N
END
BROWSE COMPLETE
VALID COMMANDS ARE:ESC, END, DISPLAY, ADD, UPD, DEL, ECHO, NOECHO, BROWSE
ENTER COMMAND
ADD
ENTER VALUE FOR FIELD:001 TITLE (A,04 CHARACTERS)
MR
ENTER VALUE FOR FIELD:002 FIRST NAME (A,10 CHARACTERS)
KIP
ENTER VALUE FOR FIELD:003 LAST NAME (A,15 CHARACTERS)
LING
ENTER VALUE FOR FIELD:004 MIDDLE INITIAL (A,01 CHARACTERS)
227 BEETLE LN
ENTER VALUE FOR FIELD:006 ADDRESS LINE 2 (X,25 CHARACTERS)
PALMER
ENTER VALUE FOR FIELD:008 STATE (A,02 CHARACTERS)
MA
ENTER VALUE FOR FIELD:009 ZIP (X,09 CHARACTERS)
01072
ENTER VALUE FOR FIELD:010 IS IT LOCAL (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:011 CREDIT RATING (N,01 CHARACTERS)
1
ENTER VALUE FOR FIELD:012 SAVINGS (Q,01 CHARACTERS)
Y
ENTER VALUE FOR FIELD:013 CHECKING (Q,01 CHARACTERS)
Y
ENTER VALUE FOR FIELD:014 SAFE DEPOSIT BOX (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:015 C AND D (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:016 ALL SAVERS (Q,01 CHARACTERS)
Y
ENTER VALUE FOR FIELD:017 VISA (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:018 MASTER CARD (Q,01 CHARACTERS)
N
ENTER VALUE FOR FIELD:019 MONEY MARKET (Q,01 CHARACTERS)
Y
CUSTOMER 000003 ADDED
VALID COMMANDS ARE:ESC, END, DISPLAY, ADD, UPD, DEL, ECHO, NOECHO, BROWSE
ENTER COMMAND
DISPLAY
CURRENT CUSTOMER IS:000003
IS THIS THE DESIRED RECORD(Y/N)?
FIELD:001 TITLE MR
FIELD:002 FIRST NAME KIP
FIELD:003 LAST NAME LING
FIELD:004 MIDDLE INITIAL
FIELD:005 ADDRESS LINE 1 227 BEETLE LN
FIELD:006 ADDRESS LINE 2
FIELD:007 CITY PALMER
FIELD:008 STATE MA
FIELD:009 ZIP 01072
FIELD:010 IS IT LOCAL N
FIELD:011 CREDIT RATING 1
FIELD:012 SAVINGS Y
FIELD:013 CHECKING Y
FIELD:014 SAFE DEPOSIT BOX N
FIELD:015 C AND D N
FIELD:016 ALL SAVERS Y
FIELD:017 VISA N
FIELD:018 MASTER CARD N
FIELD:019 MONEY MARKET N
FIELD:020 T BILL Y
VALID COMMANDS ARE:ESC, END, DISPLAY, ADD, UPD, DEL, ECHO, NOECHO, BROWSE
ENTER COMMAND
UPD
CURRENT CUSTOMER IS:000003
IS THIS THE DESIRED RECORD(Y/N)?
Y
ENTER FIELD NUMBER TO ALTER DATA, (IE 001)
ENTER 'END' WHEN READY TO UPDATE
001
ENTER VALUE FOR FIELD:001 TITLE (A,04 CHARACTERS)
MS
ENTER FIELD NUMBER TO ALTER DATA, (IE 001)
ENTER 'END' WHEN READY TO UPDATE
002
ENTER VALUE FOR FIELD:002 FIRST NAME (A,10 CHARACTERS)
LOIS
ENTER FIELD NUMBER TO ALTER DATA, (IE 001)
ENTER 'END' WHEN READY TO UPDATE
END
READY TO UPDATE RECORD(Y/N)?
Y
RECORD 000003 SUCCESSFULLY UPDATED
VALID COMMANDS ARE:ESC, END, DISPLAY, ADD, UPD, DEL, ECHO, NOECHO, BROWSE
ENTER COMMAND
DEL
CURRENT CUSTOMER IS:000003
IS THIS THE DESIRED RECORD(Y/N)?
N
ENTER CUSTOMER ID
000001
RECORD 000001 DELETED
VALID COMMANDS ARE:ESC, END, DISPLAY, ADD, UPD, DEL, ECHO, NOECHO, BROWSE
ENTER COMMAND
ESC
VALID COMMANDS ARE:ESC, END, DISPLAY, ADD, UPD, DEL, ECHO, NOECHO, BROWSE
ENTER COMMAND
END
DATA ENTRY SESSION COMPLETE
Batch Processing
The efficient batch processing capabilities of CA-Easytrieve Plus enable you to
use the data you have entered into the file for many purposes. Several examples
are presented here.
Detail Report
One practical use for this file is to output a list of all bank customers with a list of
their individual accounts. Example 17.3, as shown in the next exhibit, illustrates
the CA-Easytrieve Plus coding and the resulting report. In this example, the
START parameter of the JOB statement tells CA-Easytrieve Plus to execute the
specified procedure (HELLO) after opening all the files, but before reading the
first record. The HELLO procedure positions the file to the next record after
record zero, which contains no data, only the key of the next available record in
this file. This enables all subsequent program logic to operate only on records
containing valid data.
Each record is searched for a 1 in the fields which contain the account names -
field numbers 012 through 020. If it is found, that account name is stored into a
working storage field named ACCT-WORK, which eventually is printed on the
report along with the corresponding customer name. In the REPORT group, the
CONTROL command provides a total of the number of accounts for each
customer. The NOPRINT option suppresses printing the total line for the
FIRST-NAME control break.
1 *
2 * EXAMPLE 17.3 DETAIL LISTING OF CUSTOMERS
3 *
4 %BANKLIB
45 ACCT-ID W 2 N
46 ACCT-WORK W 30 A
47 *
48 JOB START HELLO
49 *
50 ACCT-NDX = 0
51 DO WHILE ACCT-NDX LT ACCT-MAX
52 IF ACCT-IND = 1
53 ACCT-ID = ACCT-NDX + 1
54 SEARCH ACCTNAME WITH ACCT-ID GIVING ACCT-WORK
55 PRINT ACCT-DETAIL
56 END-IF
57 ACCT-NDX = ACCT-NDX + 1
58 END-DO
59 HELLO. PROC
61 CUST-KEY = 1
62 POINT CUST GE CUST-KEY
63 END-PROC
64 REPORT ACCT-DETAIL LINESIZE 80 SPACE 1
65 SEQUENCE LAST-NAME
66 CONTROL LAST-NAME FIRST-NAME NOPRINT
67 TITLE 'LIST OF ALL CUSTOMERS WITH THEIR ACCOUNTS'
68 HEADING ACCT-WORK ('ACCOUNT' 'NAME')
69 LINE LAST-NAME FIRST-NAME ACCT-WORK TALLY
ACCOUNT
LAST-NAME FIRST-NAME NAME TALLY
ACCOUNT
LAST-NAME FIRST-NAME NAME TALLY
ACCOUNT
LAST-NAME FIRST-NAME NAME TALLY
ACCOUNT
LAST-NAME FIRST-NAME NAME TALLY
ACCOUNT
LAST-NAME FIRST-NAME NAME TALLY
140
Mass Mailing
Another use for the file developed from the previous DETAIL Report is the
generation of a letter to all customers who do not have an ALL-SAVERS account,
notifying them of the potential savings this account can provide. As shown in the
next exhibit, Example 17.4 illustrates the coding required, and the letter and the
labels.
SINCERELY,
George Million
Vice President
Fourth National Bank of Virginia
----------------------------------------------------------------------
SINCERELY,
George Million
Vice President
Fourth National Bank of Virginia
----------------------------------------------------------------------
SINCERELY,
George Million
Vice President
Fourth National Bank of Virginia
SINCERELY,
George Million
Vice President
Fourth National Bank of Virginia
----------------------------------------------------------------------
SINCERELY,
George Million
Vice President
Fourth National Bank of Virginia
------------------------------------------------------------------------
SINCERELY,
George Million
Vice President
Fourth National Bank of Virginia
SINCERELY,
George Million
Vice President
Fourth National Bank of Virginia
------------------------------------------------------------------------
SINCERELY,
George Million
Vice President
Fourth National Bank of Virginia
Summary Report
As shown in the next exhibit, Example 17.5 produces a summary of the customer
accounts by location; in this case by state. Summary reports can have a variety of
uses and they can be sequenced on any field.
This example also provides totals by state, through the CONTROL command.
This summary report does not list customers by name, but simply counts the total
number of accounts for each account type.
1 *
2 * BANK EXAMPLE 17.5 - SUMMARY REPORT
3 *
4 %BANKLIB
45 *
46 *
47 JOB START HELLO
48 PRINT ACCT-SUMMARY
49 *
50 HELLO. PROC
52 CUST-KEY = 1
53 POINT CUST GE CUST-KEY
54 END-PROC
55 *
56 REPORT ACCT-SUMMARY SUMMARY SPACE 1 LINESIZE 80
57 SEQUENCE STATE
58 CONTROL STATE
59 TITLE 1 'SUMMARY OF ACCOUNTS BY STATE'
60 LINE 1 STATE SAVINGS -
CHECKING -
SAFE-DEPOSIT -
C-AND-D -
ALL-SAVERS -
VISA -
MASTER-CARD -
MONEY-MARKET -
T-BILL
CA 2 2 2 2 2 3 2 2 2
DC 1 1 1 1 1 1 1
FL 1 1 2 2 1 2 2 2 1
IL 1 1 1 1
MA 3 3 1 3 4 4 3 4 1
MD 1 1 1 1 1 1
MI 1 1 1 1 1 1
NC 1 1 1 1 1
NH 1 1 1 1 1 1 1 1
NY 2 1 1 1 2 1 2 2
VA 5 5 5 3 3 2 2 2 1
WA 1 1 1 1 1
17 15 15 16 16 19 17 18 7
Introduction
This chapter illustrates how CA-Easytrieve Plus might be used for a classical data
processing application: a Project Management System. The structure is typical of
many data processing systems, and is composed of:
1. The Project Master file, defined in Example 18.1.
2. The File Maintenance Program, illustrated in Example 18.1. The output from
the file update process is illustrated in Example 18.2.
3. Various report programs, illustrated in Examples 17.3, 17.4, and 17.5. The
reports are generated using data from the updated Master File.
There are several reasons why Project Management was chosen as an example.
However, the primary consideration is that it enables us to present a complete
base to a working system. Although this system is somewhat simple compared to
many Project Management Systems, it is usable for many applications.
The master file is a physical sequential file containing fixed length records. There
are two record types, the project record and the task record. A project definition
is composed of a project record and optionally, one or more task records, as
illustrated below:
project record for project 1
task record for task 1 of project 1
task record for task 2 of project 1
task record for task 3 of project 1
.
project record for project 2
task record for task 1 of project 2
task record for task 2 of project 2
.
project record for project 3
task record for task 1 of project 3
task record for task 2 of project 3
.
The formats of the project and task records are the same - only the data is
different. This combination enables us to represent many projects on one file,
with each project having its own set of tasks, as illustrated below.
MACRO FILE-PARMS
*
* PROJECT MANAGEMENT SYSTEM -- MASTER FILE DEFINITION
*
FILE PRJIN FB (110 4400) &FILE-PARMS
*
PROJ-REC 1 110 A
PROJ-TASK 1 10 A
PROJ-NO 1 5 A -
HEADING ('PROJECT' 'NUMBER')
TASK-NO 6 5 A -
HEADING ('TASK' 'NUMBER')
NAME 11 25 A
MANAGER-ID 36 5 A -
HEADING ('MANAGER' 'ID')
*
STATISTICS 41 39 A
*
ESTIMATED-DATA 41 12 A
EST-MAN-HRS 41 4 P 1 -
HEADING ('EST' 'HOURS')
EST-START-DATE 45 4 P -
HEADING ('EST' 'START' 'DATE') MASK(BWZ 'Z99/99/99')
EST-END-DATE 49 4 P -
HEADING ('EST' 'END' 'DATE') MASK(BWZ 'Z99/99/99')
*
ACTUAL-DATA 53 12 A
ACT-MAN-HRS-SO-FAR 53 4 P 1 -
HEADING ('ACTUAL' 'HOURS')
ACT-START-DATE 57 4 P -
HEADING ('ACTUAL' 'START' 'DATE') MASK(BWZ 'Z99/99/99')
ACT-END-DATE 61 4 P -
HEADING ('ACTUAL' 'END' 'DATE') MASK(BWZ 'Z99/99/99')
*
LAST-TRANSACTION-DATE 65 4 P -
HEADING ('LAST' 'TRANS' 'DATE') MASK(BWZ 'Z99/99/99')
LAST-ACTIVITY-HRS 69 4 P 1
PCT-COMPLETE 73 2 P -
HEADING ('PERCENT' 'COMPLETE')
PREDECESSOR-TABLE 75 7 A OCCURS 5 -
INDEX PRE-NDX
PRE-NO PREDECESSOR-TABLE 5 A
PRE-PCT PREDECESSOR-TABLE 2 P
PRE-NO1 75 5 A
PRE-PCT1 80 2 P
PRE-NO2 82 5 A
PRE-PCT2 87 2 P
PRE-NO3 89 5 A
PRE-PCT3 94 2 P
PRE-NO4 96 5 A
PRE-PCT4 101 2 P
PRE-NO5 103 5 A
PRE-PCT5 108 2 P
*
Programs
There are two classes of programs which operate on the Project Master -- file
maintenance and report generation.
File Maintenance
Transactions are matched against the Base Master File. The requested operation
is performed (if valid), the Updated Master File is produced, and three reports
are generated which indicate the success of the run:
1. Listing of Edited Transactions
2. Transaction Error Report
3. Change Register.
Transaction Codes
As you can see, each transaction refers not only to a particular project/task, but
also to a particular field of that record. To add a new project, one transaction is
needed for each field to be added. The table below lists the valid transactions.
Transaction Description
Code
AP,AT ADD transaction; AP=add project, AT=add task
DP,DT DELETE transaction for project, or task
CP,CT Change transaction for project, or task
IT Increment transaction to add to task field
Field Types
The system sorts the transactions in order of DELETES, ADDS, CHANGES, and
INCREMENTS for a given project/task. Thus, it is possible to delete a project,
then ADD it again all in one run. Data in the TRANS-DATA field (positions 18-?)
is edited to correspond to the field it pertains to. The table below lists the
different types of fields.
Examples 18.1 and 18.2 illustrate two functions; building a new Master File, then
updating it.
1. As shown earlier in the Transaction Record Format table, Example 18.1 lists
the CA-Easytrieve Plus code which both creates the new Master File, and
subsequently updates it. The function performed by running the
CA-Easytrieve Plus program depends upon the items contained in the
Transaction file, TRANSIN, which are identified by the codes illustrated
earlier in the Transaction Codes table. To create the new Master File, the
program is first run with TRANSIN containing only Project (AP) and Add
Task (AT) items. The input file is listed at the end of the run in the Listing of
Edited Transactions described in the Change Register Report at the end of
this chapter. There is no Transaction Error Report generated for this run.
2. As shown earlier in the Transaction Codes table, Example 18.2 illustrates the
output reports after the program is run a second time with new items in
TRANSIN, which include change task transactions (CT), increment
transactions (IT), add project (AP) and add task (AT) transactions. The new
input data is listed in the Listing of Edited Transactions and described in the
Change Register Report later in this chapter. A duplicate transaction is listed
on the Transaction Error Report at the end of this chapter.
53 TRANS-ID-OP 2 1 A
54 TRANS-PROJ-TASK 3 10 A
55 TRANS-PROJ 3 5 A
56 TRANS-TASK 8 5 A
57 TRANS-FIELD 13 5 A
58 TRANS-DATA 18 25 A
59 TRANS-DATE 18 6 N
60 TRANS-L7-D1 TRANS-DATA 7 N 1
61 TRANS-L7-D0 TRANS-DATA 7 N 0
62 TRANS-L3-D0 TRANS-DATA 3 N 0
63 TRANS-L7 TRANS-DATA 7 N
64 TRANS-L3 TRANS-DATA 3 N
65 TRANS-SCAN TRANS-DATA 1 A -
INDEX TRANS-NDX
66 TRANS-ID-CNV 79 2 A
67 *
68 * WORKING STORAGE
69 *
70 ADD-PROJ-ID W 2 A VALUE 'AP'
71 ADD-CMD ADD-PROJ-ID 1 A
72 PROJ-OP ADD-PROJ-ID +1 1 A
73 ADD-TASK-ID W 2 A VALUE 'AT'
74 TASK-OP ADD-TASK-ID 1 A
75 CHANGE-PROJ-ID W 2 A VALUE 'CP'
76 CHANGE-CMD CHANGE-PROJ-ID 1 A
77 CHANGE-TASK-ID W 2 A VALUE 'CT'
78 DELETE-PROJ-ID W 2 A VALUE 'DP'
79 DELETE-CMD DELETE-PROJ-ID 1 A
80 DELETE-TASK-ID W 2 A VALUE 'DT'
81 INC-TASK-ID W 2 A VALUE 'IT'
82 INC-CMD INC-TASK-ID 1 A
83 MSG W 55 A
84 CHANGE-MSG W 15 A
85 TRANS-ERR-FLAG W 1 A
86 FIELD-DATA W 25 A
87 MASTER-WAITING W 1 A
88 LAST-PROJ W PROJ-NO
89 LAST-TASK W PROJ-NO
90 DELETED-PROJ W PROJ-NO
91 DELETED-TASK W PROJ-NO
92 LAST-TRANS-KEY W TRANS-KEY
93 LAST-TRANS-ID W TRANS-ID
94 LAST-TRANS-CMD LAST-TRANS-ID 1 A
95 LAST-TRANS-OP LAST-TRANS-ID +1 1 A
96 TRANS-ERR-COUNT W 3 P MASK('ZZZZ9')
97 SYSTEM-DATE W 4 P
98 *
99 * RECEIVING AREA FOR SEARCH ON TRANSACTION TABLE
100 *
101 TRANS-ATTRIBUTES W 40 A
102 TRANS-TBL-CNV TRANS-ATTRIBUTES 2 A
103 TRANS-MSG TRANS-ATTRIBUTES +3 20 A
104 *
105 * RECEIVING AREA FOR SEARCH ON FIELD TABLE
106 *
107 FIELD-ATTRIBUTES W 63 A
108 FIELD-NAME FIELD-ATTRIBUTES 25 A
109 FIELD-OFFSET FIELD-ATTRIBUTES +25 3 N 0
110 FIELD-LEN FIELD-ATTRIBUTES +29 2 N 0
111 FIELD-TYPE FIELD-ATTRIBUTES +32 1 A
112 FIELD-DEC FIELD-ATTRIBUTES +34 1 N
113 FIELD-SAVE FIELD-ATTRIBUTES +36 3 N . * XREF TO LOCATION
115 * WHERE INC TRANSACTION TO BE SAVED
116 FIELD-ID W 5 A
117 *
118 * THE FOLLOWING TABLE CONTAINS ALL FIELDS ON THE MASTER FILE
553 *
554 * THIS ROUTINE VERIFIES THAT THE ADD TRANSACTION FOR A MATCHING
555 * MASTER WAS PRECEDED BY A DELETE TRANSACTION
556 *
557 IF DELETED-PROJ NE PROJ-NO
558 GOTO ADD-TRANS-ERR
559 END-IF
560 *
561 IF DELETED-TASK NE TRANS-TASK AND DELETED-TASK NE ' '
562 GOTO ADD-TRANS-ERR
563 END-IF
564 IF MASTER-WAITING NE 'Y'
565 PERFORM INIT-NEW-RECORD
566 END-IF
567 PERFORM UPDATE-RECORD
568 GOTO ADD-TRANS-OK
569 ADD-TRANS-ERR
570 MSG = 'ADD TRANS INVALID FOR EXISTING PROJ/TASK'
571 PRINT ERROR-REPORT
572 ADD-TRANS-OK
573 END-PROC
574 *
575 REPORT CHANGES-REPORT PRINTER UPDRPT LINESIZE 80 SPACE 1
576 CONTROL PRJOUT:PROJ-NO PRJOUT:TASK-NO
577 TITLE 'CHANGE REGISTER'
578 LINE 1 PRJOUT:PROJ-NO PRJOUT:TASK-NO CHANGE-MSG FIELD-ID -
FIELD-DATA TALLY
579 *
580 REPORT ERROR-REPORT PRINTER TRANERR SKIP 1 LINESIZE 80
581 TITLE 'TRANSACTION ERROR REPORT 2'
582 LINE 1 TRANS-REC
583 LINE 2 MSG
584 *
585 REPORT TRANS-REG PRINTER TRANREG LINESIZE 80
586 CONTROL
587 TITLE 'LISTING OF EDITED TRANSACTIONS'
588 LINE TRANS-REC
Output Reports
TRANS-REC
APINVSM EENDT030581
APINVSM ESTDT030181
APINVSM MGRIDM0002
APINVSM NAME INVENTORY VSAM CONVERT
ATINVSMT0001ASTDT030181
ATINVSMT0001EENDT030281
ATINVSMT0001EMAN 0000080
ATINVSMT0001ESTDT030181
ATINVSMT0001MGRIDM0001
ATINVSMT0001NAME DETERMINE SPACE NEEDS
ATINVSMT0001PCTCP010
ITINVSMT0001AMAN 0000020
ATINVSMT0002EENDT030381
ATINVSMT0002EMAN 0000080
ATINVSMT0002ESTDT030281
ATINVSMT0002MGRIDM0002
ATINVSMT0002NAME MAKE JCL CHANGES
ATINVSMT0003EENDT030381
ATINVSMT0003EMAN 0000040
ATINVSMT0003ESTDT030381
ATINVSMT0003MGRIDM0003
ATINVSMT0003NAME DEFINE VSAM SPACE
ATINVSMT0004EENDT030481
ATINVSMT0004EMAN 0000060
ATINVSMT0004ESTDT030481
ATINVSMT0004MGRIDM0002
ATINVSMT0004NAME TEST CHANGES
ATINVSMT0005EENDT030581
ATINVSMT0005EMAN 0000040
ATINVSMT0005ESTDT030481
ATINVSMT0005MGRIDM0002
ATINVSMT0005NAME PUT IN PRODUCTION
APONLST EENDT062881
APONLST ESTDT060181
APONLST MGRIDM2001
APONLST NAME ONLINE CONVERT STUDY
ATONLSTT0001EENDT061081
ATONLSTT0001EMAN 0000400
ATONLSTT0001ESTDT060181
TRANS-REC
ATONLSTT0001MGRIDM0001
ATONLSTT0001NAME DETERMINE NEEDS
ATONLSTT0002EENDT062181
ATONLSTT0002EMAN 0000800
ATONLSTT0002ESTDT061181
ATONLSTT0002MGRIDM0002
ATONLSTT0002NAME ONLINE MONITOR ANALYSIS
ATONLSTT0003EENDT062481
ATONLSTT0003EMAN 0000150
ATONLSTT0003ESTDT062281
ATONLSTT0003MGRIDM0003
ATONLSTT0003NAME DET. MANPOWER AVAIL.
ATONLSTT0004EENDT062881
ATONLSTT0004EMAN 0000150
ATONLSTT0004ESTDT062581
ATONLSTT0004MGRIDM0003
ATONLSTT0004NAME PREPARE REPORT
APTAXCH EENDT021481
APTAXCH ESTDT020181
APTAXCH MGRIDM0001
APTAXCH NAME PAYROLL TAX CHANGE
ATTAXCHT0001EENDT020481
ATTAXCHT0001EMAN 0000100
ATTAXCHT0001ESTDT020281
ATTAXCHT0001MGRIDM0001
ATTAXCHT0001NAME ANALYZE CHANGES
ATTAXCHT0002EENDT020681
ATTAXCHT0002EMAN 0000100
ATTAXCHT0002ESTDT020581
ATTAXCHT0002MGRIDM0002
ATTAXCHT0002NAME DETERMINE PROGRAM CHANGES
ATTAXCHT0002PREN1T0001
ATTAXCHT0003EENDT021081
ATTAXCHT0003EMAN 0000200
ATTAXCHT0003ESTDT020681
ATTAXCHT0003MGRIDM0002
ATTAXCHT0003NAME MAKE PROGRAM CHANGES
ATTAXCHT0003PREN1T0002
ATTAXCHT0004EENDT021381
ATTAXCHT0004EMAN 0000100
ATTAXCHT0004ESTDT021081
ATTAXCHT0004MGRIDM0002
TRANS-REC
ATTAXCHT0004NAME TEST CHANGES
ATTAXCHT0004PREN1T0003
ATTAXCHT0005EENDT021481
ATTAXCHT0005EMAN 0000080
ATTAXCHT0005ESTDT021481
ATTAXCHT0005MGRIDM0002
ATTAXCHT0005NAME PUT IN PRODUCTION
ATTAXCHT0005PREN1T0004
PROJECT TASK
NUMBER NUMBER CHANGE-MSG FIELD-ID FIELD-DATA TALLY
PROJECT TASK
NUMBER NUMBER CHANGE-MSG FIELD-ID FIELD-DATA TALLY
INVSM 32
PROJECT TASK
NUMBER NUMBER CHANGE-MSG FIELD-ID FIELD-DATA TALLY
ONLST 24
PROJECT TASK
NUMBER NUMBER CHANGE-MSG FIELD-ID FIELD-DATA TALLY
TAXCH 33
TRANS-REC
CTINVSMT0001AENDT030281
CTINVSMT0001PCTCP100
ITINVSMT0001AMAN 0000070
CTINVSMT0002AENDT030481
CTINVSMT0002ASTDT030381
CTINVSMT0002PCTCP100
ITINVSMT0002AMAN 0000072
CTINVSMT0003ASTDT030581
CTINVSMT0003PCTCP090
ITINVSMT0003AMAN 0000042
CTONLSTT0001ASTDT060181
CTONLSTT0001PCTCP030
ITONLSTT0001AMAN 0000100
APRJE EENDT031082
APRJE ESTDT010482
APRJE MGRIDM0004
APRJE NAME ESTABLISH RJE SITE
ATRJE T0001EENDT011582
ATRJE T0001EMAN 0000700
ATRJE T0001ESTDT010482
ATRJE T0001MGRIDM0001
ATRJE T0001NAME DETERMINE USER NEEDS
ATRJE T0002EENDT011582
ATRJE T0002EMAN 0000700
ATRJE T0002ESTDT010482
ATRJE T0002MGRIDM0002
ATRJE T0002NAME DETERMINE EQUIP NEEDS
ATRJE T0003EENDT012082
ATRJE T0003EMAN 0000100
ATRJE T0003ESTDT011882
ATRJE T0003MGRIDM0002
ATRJE T0003NAME GET TECHNICAL INFO
ATRJE T0004EENDT012082
ATRJE T0004EMAN 0000060
ATRJE T0004ESTDT012082
ATRJE T0004MGRIDM0002
ATRJE T0004NAME GET COMM. LINE INFO
ATRJE T0005EENDT012982
TRANS-REC
ATRJE T0005EMAN 0000500
ATRJE T0005ESTDT012182
ATRJE T0005MGRIDM0003
ATRJE T0005NAME MATCH EQUIP TO NEEDS
ATRJE T0006EENDT020182
ATRJE T0006EMAN 0000060
ATRJE T0006ESTDT020182
ATRJE T0006MGRIDM0002
ATRJE T0006NAME ORDER COMMUNICATIONS LINE
ATRJE T0007EENDT020182
ATRJE T0007EMAN 0000020
ATRJE T0007ESTDT020182
ATRJE T0007MGRIDM0002
ATRJE T0007NAME SCHEDULE LINE INSTALL
ATRJE T0008EENDT020282
ATRJE T0008EMAN 0000060
ATRJE T0008ESTDT020282
ATRJE T0008MGRIDM0002
ATRJE T0008NAME ORDER COMPUTER EQUIPMENT
ATRJE T0009EENDT020282
ATRJE T0009EMAN 0000020
ATRJE T0009ESTDT020282
ATRJE T0009MGRIDM0002
ATRJE T0009NAME SCHEDULE COMPUTER INSTALL
ATRJE T0010EENDT021282
ATRJE T0010EMAN 0000500
ATRJE T0010ESTDT020382
ATRJE T0010MGRIDM0001
ATRJE T0010NAME PREPARE TRAINING PLAN
ATRJE T0011EENDT021282
ATRJE T0011EMAN 0000040
ATRJE T0011ESTDT021282
ATRJE T0011MGRIDM0001
ATRJE T0011NAME SCHEDULE USER TRAINING
ATRJE T0012EENDT021782
ATRJE T0012EMAN 0000200
ATRJE T0012ESTDT021582
ATRJE T0012MGRIDM0003
TRANS-REC
ATRJE T0012NAME PREPARE TEST PLAN
ATRJE T0013EENDT021882
ATRJE T0013EMAN 0000040
ATRJE T0013ESTDT021882
ATRJE T0013MGRIDM0001
ATRJE T0013NAME ESTABLISH USER ID'S
ATRJE T0014EENDT030182
ATRJE T0014EMAN 0000080
ATRJE T0014ESTDT030182
ATRJE T0014MGRIDM0002
ATRJE T0014NAME SUPERVISE EQUIP. DELIVERY
ATRJE T0015EENDT030382
ATRJE T0015EMAN 0000080
ATRJE T0015ESTDT030382
ATRJE T0015MGRIDM0003
ATRJE T0015NAME PERFORM STAND-ALONE TESTS
ATRJE T0016EENDT030682
ATRJE T0016EMAN 0000200
ATRJE T0016ESTDT030482
ATRJE T0016MGRIDM0003
ATRJE T0016NAME PERFORM RJE-HOST TESTS
ATRJE T0017EENDT031082
ATRJE T0017EMAN 0000240
ATRJE T0017ESTDT030882
ATRJE T0017MGRIDM0001
ATRJE T0017NAME CONDUCT USER TRAINING
CPTAXCH AENDT021381
CPTAXCH ASTDT020281
CPTAXCH PCTCP100
CTTAXCHT0001AENDT020481
CTTAXCHT0001ASTDT020281
CTTAXCHT0001PCTCP100
ITTAXCHT0001AMAN 0000100
CTTAXCHT0002ASTDT020481
CTTAXCHT0002ASTDT020681
CTTAXCHT0002PCTCP100
ITTAXCHT0002AMAN 0000120
CTTAXCHT0003AENDT020981
CTTAXCHT0003ASTDT020681
CTTAXCHT0003PCTCP100
ITTAXCHT0003AMAN 0000180
CTTAXCHT0004AENDT021181
TRANS-REC
CTTAXCHT0004ASTDT021081
CTTAXCHT0004PCTCP100
ITTAXCHT0004AMAN 0000100
CTTAXCHT0005ASTDT021281
CTTAXCHT0005PCTCP090
ITTAXCHT0005AMAN 0000100
0 ERRORS FOUND
TRANS-REC
CTTAXCHT0002ASTDT020681
DUPLICATE TRANSACTION DROPPED
PROJECT TASK
NUMBER NUMBER CHANGE-MSG FIELD-ID FIELD-DATA TALLY
INVSM 10
ONLST T0001 CHANGED ASTDT 060181
CHANGED PCTCP 030
INCREMENTED AMAN 0000100
ONLST T0001 3
ONLST 3
PROJECT TASK
NUMBER NUMBER CHANGE-MSG FIELD-ID FIELD-DATA TALLY
PROJECT TASK
NUMBER NUMBER CHANGE-MSG FIELD-ID FIELD-DATA TALLY
PROJECT TASK
NUMBER NUMBER CHANGE-MSG FIELD-ID FIELD-DATA TALLY
PROJECT TASK
NUMBER NUMBER CHANGE-MSG FIELD-ID FIELD-DATA TALLY
RJE 89
PROJECT TASK
NUMBER NUMBER CHANGE-MSG FIELD-ID FIELD-DATA TALLY
TAXCH 21
Report Generation
As shown in the report output (shown later), three report programs illustrated in
Examples 17.3, 17.4, and 17.5, are provided to give you an idea of what is
possible using the Project Management System Master File. The function and
operation of each program is documented within the example.
EST EST
PROJECT TASK MANAGER START END EST ACTUAL
NUMBER NUMBER ID DATE DATE HOURS HOURS
EST EST
PROJECT TASK MANAGER START END EST ACTUAL
NUMBER NUMBER ID DATE DATE HOURS HOURS
MANAGER ID:M0001
EST EST
PROJECT TASK START END EST
NUMBER NUMBER DATE DATE HOURS
MANAGER ID:M0002
EST EST
PROJECT TASK START END EST
NUMBER NUMBER DATE DATE HOURS
MANAGER ID:M0003
EST EST
PROJECT TASK START END EST
NUMBER NUMBER DATE DATE HOURS
598.0
Project Summary
1 *
2 * PROJECT MANAGEMENT SYSTEM - EXAMPLE 18.4
3 *
4 %PROJLIB
47 PCT PCT-COMPLETE 2 P 0 . * REDEFINE PCT COMPLETE TO TOTAL
49 *
50 * THIS EXAMPLE IS A SIMPLE SUMMARY REPORT OF ALL PROJECTS
51 *
52 JOB
53 *
54 IF TASK-NO NOT SPACES . * ONLY GET TASK RECORDS
56 PRINT PROJECT-SUMMARY
57 END-IF
58 *
59 REPORT PROJECT-SUMMARY LINESIZE 80 SPACE 1 SUMMARY
60 CONTROL PROJ-NO
61 TITLE 'SUMMARY LISTING OF PROJECTS AND MAN HOURS'
62 HEADING TALLY ('NUMBER' 'OF' 'TASKS')
63 LINE 1 PROJ-NO ACT-MAN-HRS-SO-FAR EST-MAN-HRS PCT TALLY
64 *
65 BEFORE-BREAK. PROC
67 PCT = PCT / TALLY . * COMPUTE AVE PCT COMPLETE
69 END-PROC
--------------------------------------------------------------------------------
NUMBER
PROJECT ACTUAL EST OF
NUMBER HOURS HOURS PCT TASKS
TAXCH .0
2.0
--------------------------------------------------------------------------------
Table of Statements
A
Functions
This appendix contains an alphabetical list and brief description of the subset of
CA-Easytrieve Plus statements covered in this Application Guide.
Statement Function
Assignment Establishes the value of a field.
CONTROL Identifies control fields used for a control report.
DEFINE Specifies data fields within a file or within working storage.
DISPLAY Prints data from specified fields to the system printer file or a
named printer file.
DO Controls repetitive program logic based on the truth value of
associated conditional expressions.
ELSE Identifies the statement(s) to be executed when the condition in
an IF statement tests false.
END-DO Identifies the end of the statements associated with a DO
statement.
END-IF Identifies the end of the statements associated with an IF
statement.
END-PROC Identifies the end of a procedure.
FILE Describes a file used by your program.
GET Reads the next sequential record of a file into storage.
GOTO Passes control to the specified location in the program.
HEADING Specifies an alternate column heading for a field on a report.
IF Controls the execution of associated statements depending on
the truth value of conditional expressions.
Statement Function
JOB Defines an activity that retrieves input files, examines and
manipulates data, initiates printed reports, or produces output
files.
LINE Defines the contents of a report line.
PARM Establishes program-level environment parameters.
PERFORM Transfers control to a procedure and returns control to the next
executable statement after the procedure is executed.
POINT Locates the position of a specified record in a file.
PRINT Outputs data to a file for inclusion in a report.
PROC Identifies the beginning of a procedure.
PUT Outputs a record to a file.
READ Provides random access to keyed and relative-record files.
RECORD Identifies IMS/DLI database segments available for processing.
REPORT Establishes the type and characteristics of a report.
RETRIEVE Specifies the segments to be automatically input from an
IMS/DLI database.
SEARCH Provides access to table information.
SELECT Used in a sort procedure to select individual records for the
sort output.
SEQUENCE Specifies the order of a report.
SORT Inputs a sequential file and outputs the result of the sort
operation onto an output file.
STOP Terminates an activity.
TITLE Defines report title items and their position on the title line.
WRITE Updates or deletes existing records and adds new records in
the processing of keyed and relative-record files.
Cross-References
B
Cross-Reference of Statement
This appendix presents a cross-reference listing of CA-Easytrieve Plus statements
to the specific examples in the following chapters:
■ Basic Examples
■ Advanced Techniques
■ Bank System
■ Project Management System
Within these two larger groupings, the statements and facilities are grouped by
program section; that is, Library, JOB/SORT Activity, REPORT Activity, and so
forth. Within the subgroups, the statements and facilities are presented
alphabetically.
The examples are numbered by a two-part designator which includes the chapter
number. That is, Example 15.10 is the 10th example presented in Chapter 15,
Example 16.14 is the 14th example in Chapter 16, and so on. Please refer to the
Table of Contents to determine the exact page number on which to locate a
specific example.
Cross-References B–1
Cross-Reference of Statement
Cross-References B–3
Cross-Reference of Statement
STATEMENT/ EXAMPLE
FACILITY NUMBER
SELECT 16.04
SORT 16.04
16.05
16.07
18.01
STOP 16.08
16.10
16.12
16.14
17.01
WRITE 16.08
16.10
16.11
17.02
Cross-References B–5
Cross-Reference of Statement
Cross-References B–7
Cross-Reference of Statement
TITLE
15.01
15.02
15.05
15.06
15.07
15.09
15.10
15.11
15.12
15.14
15.15
15.16
15.17
16.01
16.02
16.03
16.04
16.05
16.06
16.08
16.09
16.10
16.11
17.03
17.05
18.01
18.03
18.04
18.05
KEYWORD POSITIONAL
SUBSTITUTION 17.00 SUBSTITUTION 16.12
16.14
MACRO 18.00
DEFINITION
16.12
16.14
17.00
18.00
Cross-References B–9
Cross-Reference of Statement
Cross-References B–11
Cross-Reference of Statement
Cross-References B–13
Cross-Reference of Statement
PERCENT SUMMARY
CALCULATION 15.02 REPORT 15.02
15.05 15.05
15.07 15.07
15.09 15.09
15.12 15.10
18.04 15.12
16.01
PRINTER FILE 17.04 16.02
18.01 16.04
17.05
PROCEDURE 15.02 18.04
15.05
15.07 TALLY 15.02
15.09 15.05
15.11 15.07
15.12 15.09
15.17 15.10
16.01 16.01
16.03 16.02
18.04 17.03
18.05 18.04
18.05
RATIO
CALCULATION 15.09 TERMINATION 16.03
ROUNDING 15.02
15.05
15.07
15.09
15.12
A C
D
B
Database, 11-1
Batch processing, 17-22 Default value, 8-8
BEFORE-BREAK procedure, 8-18 DEFINE statement, 3-8
BEFORE-LINE procedure, 8-18, 8-20 Delimiters, end of statement area, 2-11
Blank when zero (BWZ), 3-12 DESC, description field, 10-1
Block Descriptor Word (BDW), 3-6 DISPLAY statement, 7-2
report annotations, 8-17
BWZ, (blank when zero), 3-12
DO and END-DO statements, 6-11
Documentation conventions, 1-4
Index–1
E GETDATE macro, 16-25
GN (get next) call, 11-6
ELSE statement, 6-10 GNP calls, 11-6
Employee letters, 15-5 GO TO statement, 6-10
Employees in Region 1, 15-2 GOTO statement, 6-12
END-IF statement, 6-10
ENDPAGE procedure, 8-18 H
Equivalence
assignment statement, 5-1
Hash, report termination, 8-19
Error correction, 15-30
HEADING statement, 8-13
Expanded inventory report, 15-27
Hexadecimal, DISPLAY HEX, 8-16
External tables, 3-7, 10-2
EZTPX01, passed parameters, 16-28
I
F IF statement, 6-9
IF, ELSE, and END-IF Statements, 6-9
Field, 3-1
Indexed Sequential Access Method (ISAM), 9-6
Field class condition, 6-6
Instream tables, 10-2
Field definitions
S storage fields, 8-18 INSTREAM tables, 3-7
Keyword PERSUPD
statement area, 2-10 CARD file, 12-5, 13-6
N Q
O R
Index–3
Reading data files, 15-1 S
Record, 3-1
Record addition, 9-10 S working storage fields, 8-18
Record deletion, 9-10 Salary tally report, 15-18
Record Descriptor Word (RDW), 3-6 SAM Files, 9-4
Record number, 17-2 SEARCH statement, 10-3
Record relational condition, 6-9, 9-16 Segments, 11-1
RECORD statement, 11-3 SELECT statement, 8-20
Record update, 9-11 Selected control break processing, 16-2
Reformat printed output from IDCAMS, 16-12 SEQUENCE statement, 8-11
Reorder notification report, 15-35 Sequential Access Method (SAM), 9-4
Report activities Short report output program, sample, 12-2, 13-2
report procedures, 8-18
SORT activities, 4-1
REPORT activities
SORT activity, 2-9
report procedures, 8-16
REPORT-INPUT procedure, 8-20 SORT statement, 4-6
Report declaratives, 4-1, 8-1, 8-14 Sorting input files, 16-8
Report generation, 18-30 SORTPER
sort output file, 12-5
Report procedures, 8-16
sort output file (VSE), 13-6
REPORT statement, 8-5
Special report processing exits, 16-5
LEVEL, 8-17
special-name procedures, 8-18 Statement area
SUMFILE, 8-17 keyword, 2-10
Report subactivity, 2-9 Statement labels, 6-13
Report types, 8-3 STOP statement, 6-15
report proc warning, 8-16
REPORT-INPUT procedure, 8-18, 8-20
Structure, 2-7
reports
annotations, 8-20 subprograms
modifying data, 8-20 EZTPX01, 16-28
Reports Summary file processing, 16-3
annotations, 8-17
control breaks, 8-17, 8-18 Synchronized file facility, file update, 16-10
Index–5