You are on page 1of 131

EASYTRIEVE PLUS

PRODUCT INFORMATION.................................................................................................5

Description.............................................................................................................................5
Capabilities.............................................................................................................................6

PROGRAM STRUCTURE.....................................................................................................7

ENVIRONMENT Section........................................................................................................7
LIBRARY Section....................................................................................................................7
ACTVITY Section....................................................................................................................7
Example - Primer 1................................................................................................................9
Example - Primer 2..............................................................................................................10
Example - Primer 3..............................................................................................................11
Example - Primer 4..............................................................................................................12
Example - Primer 5..............................................................................................................13
Example - Primer 6..............................................................................................................14
Example - Primer 7..............................................................................................................15
LIBRARY...............................................................................................................................16
FILE Statement.....................................................................................................................16
Field Definition Statement....................................................................................................16
Field- name...........................................................................................................................17
Start- location.......................................................................................................................17
Field- length..........................................................................................................................17
HEADING Parameter..........................................................................................................18
MASK....................................................................................................................................18
Defining Edit Masks.............................................................................................................19
System Default Masks...........................................................................................................20
Redefining a Field................................................................................................................20
Working Storage...................................................................................................................20
VALUE 'literal'.....................................................................................................................21
RESET...................................................................................................................................21
Library Exercise...................................................................................................................21
JOB statement.......................................................................................................................24
IF / ELSE..............................................................................................................................26
Special Ifs.............................................................................................................................26
Combining Conditional Expressions....................................................................................27
Assignment Statement...........................................................................................................27

-1-
EASYTRIEVE PLUS

Calculations..........................................................................................................................28
Parentheses in Calculations.................................................................................................28
Rounding in Calculations.....................................................................................................28
Rounding Example................................................................................................................29
PRINT...................................................................................................................................29
REPORT...............................................................................................................................30
REPORT Statement..............................................................................................................30
Spacing Control Parameters................................................................................................32
Testing Aid Parameters........................................................................................................32
Format Determination Parameters......................................................................................33
Report Definition Statements................................................................................................33
SEQUENCE..........................................................................................................................33
CONTROL............................................................................................................................34
SUM......................................................................................................................................35
TITLE Statement...................................................................................................................35
HEADING Statement............................................................................................................36
LINE statement.....................................................................................................................36
Multiple Reports...................................................................................................................37
TALLY...................................................................................................................................38
S Working Storage................................................................................................................41
Relative Start-Location.........................................................................................................41
Relative Redefinition............................................................................................................42
JOB ACTIVITY.....................................................................................................................42
STOP Statement....................................................................................................................42
DISPLAY Statement..............................................................................................................43
NEWPAGE...........................................................................................................................43
SKIP number........................................................................................................................43
Integer...................................................................................................................................44

Report......................................................................................................................................45

REPORT Statement..............................................................................................................45
Format Determination Parameters......................................................................................46
SUMMARY...........................................................................................................................55
SUMSPACE..........................................................................................................................55
TALLYSIZE...........................................................................................................................55

-2-
EASYTRIEVE PLUS

SUMFILE.............................................................................................................................55
FILE Directing Parameters..................................................................................................58
Report Procedures (PROCs)................................................................................................59
REPORT-INPUT. PROC......................................................................................................60
BEFORE-BREAK. PROC.....................................................................................................62
AFTER-BREAK. PROC........................................................................................................64
BEFORE-LINE. PROC.........................................................................................................64
ENDPAGE. PROC...............................................................................................................64
TERMINATION. PROC........................................................................................................64
EXERCISE............................................................................................................................65

LIBRARY...............................................................................................................................67

FILE Statement.....................................................................................................................67
Virtual File Manager (VFM)................................................................................................69
COPY Statement...................................................................................................................70
EXIT Parameter....................................................................................................................70
ACTIVITY.............................................................................................................................71
CALL Statement....................................................................................................................71
MOVE Statement..................................................................................................................71
MOVE LIKE.........................................................................................................................73
User-Procedures (PROCs)...................................................................................................73
END-PROC..........................................................................................................................74
Nesting PROCs.....................................................................................................................75
START/FINISH Parameters.................................................................................................75
GOTO Statement..................................................................................................................76
Label.....................................................................................................................................76
JOB.......................................................................................................................................76
DO WHILE/END-DO Statements.........................................................................................77
Nesting Example...................................................................................................................77
SORT.....................................................................................................................................78
SORT Procedure...................................................................................................................79
FILE PROCESSING.............................................................................................................81
GET Statement......................................................................................................................81
PUT Statement......................................................................................................................82

VSAM......................................................................................................................................84

-3-
EASYTRIEVE PLUS

VSAM File Statement............................................................................................................84


PASSWORD literal...............................................................................................................84
VSAM File Creation (Loading)............................................................................................85
STATUS................................................................................................................................85
VSAM Input..........................................................................................................................86
POINT Statement..................................................................................................................88
READ Statement...................................................................................................................89
WRITE..................................................................................................................................90
Synchronized File Processing..............................................................................................91
Representation of Synchronized Input Flow.........................................................................93
Special Tests for Synchronized Files....................................................................................94
MATCHED...........................................................................................................................94
Checking for Duplicate Records..........................................................................................95
File Presence Test and End of File Test (EOF)...................................................................95
Possible Tests for Record Pairs...........................................................................................96
Example 1 - Output to Two Files..........................................................................................97
Code......................................................................................................................................97
Record Presentation for Processing.....................................................................................98
Representation of Output Files.............................................................................................98
Multiple Job Activities Exercise.........................................................................................101
TABLES/INDEXING/ARRAYS...........................................................................................101
SEARCH Statement............................................................................................................103
Exercise..............................................................................................................................104
Indexing..............................................................................................................................105
Arrays.................................................................................................................................105
Subscripts...........................................................................................................................110
EXCERCISES.....................................................................................................................113

MACROS..............................................................................................................................114

OVERVIEW........................................................................................................................114
Objective.............................................................................................................................114
GENERAL INFORMATION...............................................................................................114
Macro Applications............................................................................................................114
CREATING MACROS........................................................................................................115
Testing Macros Within a Program.....................................................................................118

-4-
EASYTRIEVE PLUS

Data Dictionary..................................................................................................................120
Logic Templating................................................................................................................121

CODING TECHNIQUES....................................................................................................123

OVERVIEW........................................................................................................................123
Objectives...........................................................................................................................123
SYSTEM-DEFINED FIELDS.............................................................................................124
General Purpose Fields......................................................................................................124
File Processing Fields........................................................................................................125
Report Processing Fields...................................................................................................125
ENVIRONMENT.................................................................................................................127
Debugging..........................................................................................................................128
BIT TESTING.....................................................................................................................129
SUMMARY.........................................................................................................................130

-5-
EASYTRIEVE PLUS

PRODUCT INFORMATION
Description
EASYTRIEVE PLUS is an information retrieval and data management system that
offers expanded capabilities for both business and data processing professionals.

The information retrieval capabilities allow non-data processing personnel to generate


reports that meet the information requirements of their organization.

Automatic report composition features built into EASYTRIEVE PLUS allow for
immediate productivity by even the most inexperienced computer users. As user
experience increases more sophisticated procedures are available to provide reports of
greater complexity without sacrificing simplicity.

The data management features of EASYTRIEVE PLUS make it an effective


application development tool. You can use this powerful, fourth-generation language
to :

 Prototype applications

 Assist in the design and quick development of production programs

 Perform file maintenance on a variety of file types

Capabilities
EASYTRIEVE PLUS provides :

 Automatic report formatting without sacrificing flexibility


 Production of unlimited reports from a single pass of the data
 Edit masks, such as floating money symbols, check protection, and blank when
zero
 Capability for special forms
 Complete conditional logic
 Powerful calculation capabilities
 User-friendly data base interfaces to a variety of common data bases complete
with standard call capabilities
 Extracts of all types of data from any combination of files - sequential, ISAM,
VSAM, or data bases
 Access of data fixed, variable , undefined or spanned record formats.
 Random access of ISAM and VSAM files and databases.
 Access of variable length fields.
 Matches and merges of any number of files; any number of keys.
 Before and after control break logic.

-6-
EASYTRIEVE PLUS

EASYTRIEVE PLUS allows:

 User-defined reports
 An unlimited number of input files.
 Array processing

EASYTRIEVE PLUS performs:

 Extensive table lookups (file and instream)


 Special tests (alphabetic, numeric, blanks, bit testing)
 Calls of user programs and subroutines by use of standard linkage conventions.

-7-
EASYTRIEVE PLUS

PROGRAM STRUCTURE
There are three basic sections to every EASYTRIEVE PLUS program. They are:

 An Environment Section (optional)

 A Library Section

 One or More Activity Sections.

ENVIRONMENT Section
You use the ENVIRONMENT section to change EASYTRIEVE PLUS 'system
defaults. It is an optional and infrequently used section of an EASYTRIEVE PLUS
program. The examples in this Student Guide do not include an environment.
Environment parameters are discussed in Section 6 of the Student Guide.

LIBRARY Section
The LIBRARY section of the program is used to define all input, output, and working
storage fields used in the program.

ACTVITY Section
An ACTIVITY section can be one of two types: JOB or SORT.

 A JOB activity is where program logic is coded. It can also contain a REPORT
sub activity which generates a formatted report. Pro gram logic can be structured
into components called PROCs (short for procedures)

 The SORT activity is simply used to sort your data before doing other processing.

-8-
EASYTRIEVE PLUS

The following diagram shows basic program structure excluding the Environment
section.

LIBRARY

JOB SORT

LOGIC PROC

PROC

REPORT

PROC

Figure 1:- Basic Program Structure

-9-
EASYTRIEVE PLUS

Example - Primer 1
This example shows a very basic report program. It takes the input data and
automatically formats it into a report. Filed names are used as column headings and
the page number and date are automatically generated.

FILE PERSBL FB ( 150 1800)


NAME 17 8 A
EMP# 9 5 N
DEPARTMENT 98 3 N
NET 90 4 P 2
GROSS 94 4 P 2
JOB INPUT PERSNL NAME PRIMER-ONE
PRINT PAY-RPT
REPORT PAY-RPT LINESIZE 70
TILTLE 01 'PERSONNEL REPORT PRIMER ONE'
LINE 01 NAME DEPARTMENT EMP# GROSS NET

Primer 1 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONE


NAME DEPARTMENT EMP# GROSS NET
WIMN 903 12267 373.60 251.65
BERG 943 11473 759.20 547.88
CORNING 915 02688 146.16 103.43
NAGLE 935 00370 554.40 340.59
ARNOLD 911 01963 445.50 356.87
MANHART 914 11602 344.80 250.89
TALL 917 11931 492.26 355.19
BRANDOW 918 02200 804.64 554.31
LARSON 911 11357 283.92 215.47
BYER 932 11467 396.98 259.80
HUSS 921 11376 360.80 223.71
POWELL 911 11710 243.20 167.96
MCMOHAN 943 00370 386.40 283.19
FORREST 931 03416 13.80 13.19
POST 911 00445 292.00 206.60
PETRIK 921 00577 220.80 154.70
VETTER 914 01895 279.36 189.06
KRUSE 911 03571 242.40 182.09
LOYAL 912 04225 292.20 230.50
DENNING 919 02765 135.85 109.60
WEST 940 04132 736.00 429.62
THOMPSON 923 01743 250.40 187.40
SMOTH 911 01730 315.20 202.43
NORIDGE 944 03936 324.00 242.25

- 10 -
EASYTRIEVE PLUS

Example - Primer 2
This program adds a simple arithmetic expression to compute employee deductions.
Note that the field name DEDUCTIONS has been added to the LINE statement.

FILE PERSBL FB ( 150 1800)


NAME 17 8 A
EMP# 9 5 N
DEPARTMENT 98 3 N
NET 90 4 P 2
GROSS 94 4 P 2
DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME PRIMER-TWO


PRINT PAY-RPT
REPORT PAY-RPT LINESIZE 70
TILTLE 01 'PERSONNEL REPORT PRIMER TWO'
LINE 01 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

Primer 2 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONE


NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS
WIMN 903 12267 373.60 251.65 121.95
BERG 943 11473 759.20 547.88 211.32
CORNING 915 02688 146.16 103.43 42.73
NAGLE 935 00370 554.40 340.59 213.81
ARNOLD 911 01963 445.50 356.87 88.63
MANHART 914 11602 344.80 250.89 93.91
TALL 917 11931 492.26 355.19 137.07
BRANDOW 918 02200 804.64 554.31 250.33
LARSON 911 11357 283.92 215.47 68.45
BYER 932 11467 396.98 259.80 136.88
HUSS 921 11376 360.80 223.71 137.09
POWELL 911 11710 243.20 167.96 75.24
MCMOHAN 943 00370 386.40 283.19 103.21
FORREST 931 03416 13.80 13.19 0.61
POST 911 00445 292.00 206.60 85.40
PETRIK 921 00577 220.80 154.70 66.10
VETTER 914 01895 279.36 189.06 90.30
KRUSE 911 03571 242.40 182.09 60.31
LOYAL 912 04225 292.20 230.50 64.70
DENNING 919 02765 135.85 109.60 26.25
WEST 940 04132 736.00 429.62 306.38
THOMPSON 923 01743 250.40 187.40 63.00
SMOTH 911 01730 315.20 202.43 112.77
NORIDGE 944 03936 324.00 242.25 81.75

- 11 -
EASYTRIEVE PLUS

Example - Primer 3
This program adds some elementary logic to assure that employee deductions are
computed only when DEPARTMENT = 911.

FILE PERSBL FB ( 150 1800)


NAME 17 8 A
EMP# 9 5 N
DEPARTMENT 98 3 N
NET 90 4 P 2
GROSS 94 4 P 2
DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME PRIMER-THREE


IF DEPARTMENT = 911
DEDUCTIONS = GROSS - NET
PRINT PAY-RPT
END-IF

REPORT PAY-RPT LINESIZE 70


TITLE 01 'PERSONNEL REPORT PRIMER THREE'
LINE 01 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

Primer 3 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONE


NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS
ARNOLD 911 01963 445.50 356.87 88.63
LARSON 911 11357 283.92 215.47 68.45
POWELL 911 11710 243.20 167.96 75.24
POST 911 00445 292.00 206.60 85.40
KRUSE 911 03571 242.40 182.09 60.31
SMOTH 911 01730 315.20 202.43 112.77

- 12 -
EASYTRIEVE PLUS

Example - Primer 4
This program builds on the logic of the previous example. The THRU parameter has
been added to enable the calculation of deductions for departments 911, 912, 913,
914, 921.

FILE PERSBL FB ( 150 1800)


NAME 17 8 A
EMP# 9 5 N
DEPARTMENT 98 3 N
NET 90 4 P 2
GROSS 94 4 P 2
DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME PRIMER-FOUR


IF DEPARTMENT = 911 THRU 914 921
DEDUCTIONS = GROSS - NET
PRINT PAY-RPT
END-IF

REPORT PAY-RPT LINESIZE 70


TILTLE 01 'PERSONNEL REPORT PRIMER FOUR'
LINE 01 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

Primer 4 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONE


NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS
ARNOLD 911 01963 445.50 356.87 88.63
MANHART 914 11602 344.80 250.89 93.91
LARSON 911 11357 283.92 215.47 68.45
HUSS 921 11376 360.80 223.71 137.09
POWELL 911 11710 243.20 167.96 75.24
POST 911 00445 292.00 206.60 85.40
PETRIK 921 00577 220.80 154.70 66.10
VETTER 914 01895 279.36 189.06 90.30
KRUSE 911 03571 242.40 182.09 60.31
LOYAL 912 04225 292.20 230.50 64.70
SMOTH 911 01730 315.20 202.43 112.77

- 13 -
EASYTRIEVE PLUS

Example - Primer 5
This program adds a SEQUENCE statement to the REPORT activity which sorts
employees alphabetically by NAME under DEPARTMENT.

FILE PERSBL FB ( 150 1800)


NAME 17 8 A
EMP# 9 5 N
DEPARTMENT 98 3 N
NET 90 4 P 2
GROSS 94 4 P 2
DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME PRIMER-FIVE


IF DEPARTMENT = 911 THRU 914 921
DEDUCTIONS = GROSS - NET
PRINT PAY-RPT
END-IF

REPORT PAY-RPT LINESIZE 70


TILTLE 01 'PERSONNEL REPORT PRIMER FIVE'
LINE 01 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

Primer 5 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONE


NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS
ARNOLD 911 01963 445.50 356.87 88.63
KRUSE 911 03571 242.40 182.09 60.31
LARSON 911 11357 283.92 215.47 68.45
POWELL 911 11710 243.20 167.96 75.24
POST 911 00445 292.00 206.60 85.40
SMOTH 911 01730 315.20 202.43 112.77
LOYAL 912 04225 292.20 230.50 64.70
MANHART 914 11602 344.80 250.89 93.91
VETTER 914 01895 279.36 189.06 90.30
HUSS 921 11376 360.80 223.71 137.09
PETRIK 921 00577 220.80 154.70 66.10

- 14 -
EASYTRIEVE PLUS

Example - Primer 6
This program adds a CONTROL statement to the REPORT activity which causes
totals to be printed for all packed decimal field types.

FILE PERSBL FB ( 150 1800)


NAME 17 8 A
EMP# 9 5 N
DEPARTMENT 98 3 N
NET 90 4 P 2
GROSS 94 4 P 2
DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME PRIMER-SIX


IF DEPARTMENT = 911 THRU 914 921
DEDUCTIONS = GROSS - NET
PRINT PAY-RPT
END-IF

REPORT PAY-RPT LINESIZE 77


TILTLE 01 'PERSONNEL REPORT PRIMER SIX'
LINE 01 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

Primer 6 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONE


NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS
ARNOLD 911 01963 445.50 356.87 88.63
KRUSE 911 03571 242.40 182.09 60.31
LARSON 911 11357 283.92 215.47 68.45
POWELL 911 11710 243.20 167.96 75.24
POST 911 00445 292.00 206.60 85.40
SMOTH 911 01730 315.20 202.43 112.77
LOYAL 912 04225 292.20 230.50 64.70
MANHART 914 11602 344.80 250.89 93.91
VETTER 914 01895 279.36 189.06 90.30
HUSS 921 11376 360.80 223.71 137.09
PETRIK 921 00577 220.80 154.70 66.10
3320.18 2380.28 942.9

- 15 -
EASYTRIEVE PLUS

Example - Primer 7
This program builds upon the previous program by adding the field name
DEPARTMENT to the CONTROL statement. This causes totals to be printed for
each department.. (Called a "control break" on department) Also, a less cryptic
heading name has been added for the EMP# field (EMPLOYEE NUMBER)

FILE PERSBL FB ( 150 1800)


NAME 17 8 A
EMP# 9 5 N
DEPARTMENT 98 3 N
NET 90 4 P 2
GROSS 94 4 P 2
DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME PRIMER-SEVEN


IF DEPARTMENT = 911 THRU 914 921
DEDUCTIONS = GROSS - NET
PRINT PAY-RPT
END-IF

REPORT PAY-RPT LINESIZE 80


TITLE 01 'PERSONNEL REPORT PRIMER SEVEN'
TITLE 02 'NOTICE THE ALTERNATE COLUMN HEADING AND
SUBTOTAL'
HEADING EMP# ('EMPLOYEE' 'NUMBER')
LINE 01 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

Primer 7 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONE


NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS
ARNOLD 911 01963 445.50 356.87 88.63
KRUSE 911 03571 242.40 182.09 60.31
LARSON 911 11357 283.92 215.47 68.45
POWELL 911 11710 243.20 167.96 75.24
POST 911 00445 292.00 206.60 85.40
SMOTH 911 01730 315.20 202.43 112.77
911 1822.22 1331.42 490.8
LOYAL 912 04225 292.20 230.50 64.70
912 292.20 230.50 64.70
MANHART 914 11602 344.80 250.89 93.91
VETTER 914 01895 279.36 189.06 90.30
914 624.16 439.95 184.21
HUSS 921 11376 360.80 223.71 137.09
PETRIK 921 00577 220.80 154.70 66.10
581.60 378.41 203.19

- 16 -
EASYTRIEVE PLUS

LIBRARY
The first task in coding an EASYTRIEVE PLUS program is to code the LIBRARY
section. This section describes the file or files and fields you are using as input to your
program. The library has two parts: the FILE statement and the field definition
statements.

FILE Statement
The FILE statement describes the file you are using as input to your program. You
code it at the beginning of the library section.

Syntax
FILE file-name [file attributes]

where FILE is the keyword and file-name and file attributes are supplied by your data
processing department.

Field Definition Statement


A filed definition specifies data fields within a record on a file.

 Four parameters are always required : field-name, start-location, field-length, and


data-type.
 Additional parameters include the number of decimal positions for quantitative
fields, HEADING and MASK.

Syntax

field-name start-location field-length data-type +

[decimal-positions] [HEADING ‘literal’ ] +

[MASK ({[letter] [BWZ] [‘literal’] })]


+

[VALUE literal] [RESET]

- 17 -
EASYTRIEVE PLUS

Field-name
You create a field-name or adapt the field name in a record layout for your
EASYTRIEVE PLUS program.
 Field-names must be unique within a file.
 The name can be 1 to 40 alphanumeric characters.
 Special characters can be used, but not delimiters.

Start-location
The start location of a field is the position of its first character of data relative to the
position of the first, character of data in the record.

 Start location can be explicitly defined based on the number of positions it is from the
first position (position 1) in the record:
NAME 17 16 A

The start position for the field NAME is 17. The first character of data in this field
begins in position 17, which is the 17th character of data in the record.

Field-length
You specify the length of a field in bytes (characters and/or spaces).

Data-type

You describe the type of data a field contains by coding the letter for that type after
the field-length. There are five data-types.

Type Max. Length


(Bytes)
A Alphanumeric 32,767
N Numeric 18
P Packed 10
U Unsigned Packed 9
B Binary 4

Decimal-positions

By specifying decimal-positions, you:

 Identify a filed to EASYTRIEVE PLUS as being quantitative


 Identify the Filed(s) to be automatically totaled when specified in a CONTROL
report.
 Allow for proper placement of commas and decimals with leading zeros suppressed
when the field is printed

- 18 -
EASYTRIEVE PLUS

Four types of data can have decimal positions:

N Numeric
P Packed
B Binary
U Unsigned Packed

Specify the decimal-positions by coding an integer (0 through 18) after the data-type.
For example,

AMOUNT 40 5 N 2

is a five-byte numeric field with two decimal positions.

HEADING Parameter
You use the HEADING parameter to specify an alternative column heading for a
field. (The default column heading is the field-name.)

Place the alternate column heading within single quotation marks. For example,

CL-NAME 5 20 A HEADING 'CLIENT NAME'

produces the column heading


CLIENT NAME

MASK
An edit mask is a pattern of characters specifying how non-alphanumeric data is to be
printed. Alphanumeric fields cannot be edited. An edit mask is created using
combinations of the following characters:

9 Formats digits.
Z suppresses Leading zeroes
* Replaces leading zeroes With an asterisk
- Prints a minus sign prior to the first non-zero digit of a negative number
$ Prints a currency symbol prior to the first non-zero digit.

Each digit in the field must be designated in the mask. Any character which follows
the last character of the edit mask is printed if the field is negative.

Example

MASK FIELD RESULT


-------- -------- ------------
$$,$$9 01234 $1,234
$$,$$9 93142 $93,142

- 19 -
EASYTRIEVE PLUS

Defining Edit Masks


You can define standard edit masks when your system is installed.

Examples MASK USE

'(999) 999-9999' Telephone Number


'999-99-9999' Social Security Number
'z9/99/99' Date
'$$,$$$,$$9.00 CREDIT Money (with floating $)
'*,***,***,999.99-' Protected Check Amount
'-,---,--9.99' Negative Number

Syntax

[MASK ([letter] [BWZ] ['literal'])]

 MASK is the EASYTRIEVE PLUS keyword


 Letter is used to name the edit mask that follows it. If you name a mask, you can
reuse it on other field definitions just by specifying the name. A name can be any
letter from A through Y. This means that once you have defined a mask, you
don't have to define a mask, you don't have to define it again.
 BWZ (blank when zero) specifies that a field should not be printed if the entire
field contains zeros. BWZ must be coded whenever needed
 Literal is the format of the mask using the characters indicated on the previous
page.

Examples

If the data is 012345678


And code is ……. The result is……

SSN 1 9 N MASK (A BWZ '999-99-9999')


012-34-5678
SSN1 61 9 N MASK (A BWZ)

PAY 10 5 N 0 MASK '$$$,$$$,$$9-' $12,345,678

- 20 -
EASYTRIEVE PLUS

System Default Masks

System Default Masks

Code Mask
PAY 10 5 N O 'zz,zzz-'

PAY 10 5 N 2 'zzz.99-'

PAY 10 5 N '99999'

Redefining a Field
Sometimes it is necessary to break a field into several parts in order to get the exact
information for your report. A birth date, for example, may have been originally entered as
one field in a record. Now you want to access this information by either the month, day, or
year. With EASYTRIEVE PLUS you can redefine that field in the following manner:

DATE-OF-BIRTH 103 6 N
MONTH 103 2 N
DAY 105 2 N
YEAR 107 2 N

DATE-OF-BIRTH

|_|_|_|_|_|_|0|2|1|0|5|5|_|_|_|_|
position 103 105 107

In this exhibit the MONTH (02) starts in position 103 and occupies position 103 and
104. The DAY starts 105 and occupies positions 105 and 106. Finally, YEAR starts in
107 and occupies 107 and 108.

Working Storage
Working storage involves setting aside an area of storage as a place to keep calculations
or other information that is to be created during the running of an EASYTRIEVE PLUS
program.

 Define working storage by specifying W' as the start location.


 The values stared in this field are associated with each individual record.

- 21 -
EASYTRIEVE PLUS

Example

GROSS 30 4 N 2
NET 34 4 N 2
WORK-DEDUCT W 4 N 2 HEADING 'DEDUCTIONS'

VALUE 'literal'
You can use the VALUE option in the field definition statement to initialize the
contents of a working storage field. Zeroes (for numeric fields) or blanks (for
alphanumeric fields) are the defaults if no value is specified. The data can be any
valid literal whose type matches that of the field being initialized.

Example
CURR-MON W 10 A VALUE 'JANUARY'

RESET
When coded on the field definition for a W working storage field, RESET restores the
field to its initial value whenever JOB or SORT is executed. The initial value is
whatever you specify via a VALUE parameter or the default: zeroes far numeric
fields, blanks for alphanumeric fields. RESET is useful when you need to ensure that
a working storage field always has the same initial value each time you loop through
an activity.

Example
CURR-MON W 10 A VALUE 'JANUARY' RESET

Library Exercise
Using the following file layout and instructions, code the entire library section of an
EASYTRIEV PLUS program, including the FILE statement.

File layout for file named PERSNL

Descriptive Start
Field content Location Length Type Comments
Region 1 1 N Displacement is relative to one
Employee 9 5 N
Number
Employee Name 17 20 A
Net Pay 90 4 P Two decimals
Gross Pay 94 4 P Two decimals
Department 98 3 N
Date of Hire 136 6 N Month day year

- 22 -
EASYTRIEVE PLUS

 Redefine Date of Hire into month, day, and year.


 Code descriptive column headings for one field.
 Code masks for pay fields
 Add work fields for:

NEW-PAY (two decimal positions)


DEDUCTIONS (two decimal positions)
PERCENT-DEDUCTIONS (one decimal position)

- 23 -
EASYTRIEVE PLUS

JOB ACTIVITY

You will now learn how to code the processing activities to be done on the files that were
defined in the library section. EASYTRIEVE PLUS executes these activities one at a
time, in top-to-bottom order.

 There are three parts of an activity : the JOB statement and two subactivities - logic
and report.

LIBRARY

JOB SORT

LOGIC PROC

PROC

REPORT

PROC

- 24 -
EASYTRIEVE PLUS

** Library **
*
ACTIVITY  JOB INPUT PERSNL NAME PRIMER
LOGIC  IF DEPARTMENT = 911 THRU 914 921
EDUCTIONS = GROSS - NET
RINT EXAMPLE
END-IF
*
REPORT  REPORT EXAMPLE
SEQUENCE DEPARTMENT NAME
TITLE 1 'PRIMER EXAMPLE REPORT'
LINE 1 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

This exhibit shows the location of the JOB statement and the subactivity in an
EASYTRIEVE PLUS program.

You can use the logic subactivity to examine and manipulate data, initiate printed
reports, and write data to a file.

You can use the report subactivity to format the desired report.

JOB statement
The JOB statement defines and initiates processing activity. It also identifies the name
of the automatic input file.

Syntax

JOB INPUT [file-name] [NAME job-name]

[ INPUT ]

The optional INPUT parameter identifies the automatic input to the activity.

When you do not specify INPUT, EASYTRIEVE PLUS automatically provides an


input file. If a SORT activity immediately preceded the current JOB activity, the
default input is the output file from that SORT activity. Otherwise, the default input is
the first file named in the library section

file-name

File-name identifies the automatic input file(s). File-name identifies any file defined
in the library section of the program eligible for sequential input processing.

- 25 -
EASYTRIEVE PLUS

[ NAME job-name ]

The optional NAME parameter names the JOB activity. Job-name can be up to 40
characters long, can contain any character other than a delimiter, and begin with A-Z
or 0-9; it cannot consist of all numeric characters. This parameter is used only for
documentation purposes.

Logic

Data selection and manipulation takes place in the logic section of an EASYTRIEVE
PLUS program. Logic is coded immediately after the JOB statement.

If Statement

Processing within a JOB activity is dependent on the conditional (IF) statements


present in the program.

 When an IF statement is present, each record read from the input file is processed
against the condition.

 Every IF statement must end with END-IF

Syntax

{EQ =}
{NE =} {field-two }
IF field-one {GT > } {literal }
{GE >=} {arithmetic expression }
{LT < }
{LE <=}
[ statements executed for true IF ]
[ ELSE ]
[ statements executed for false IF ]
END-IF

Examples
A literal : IF DEPT = 910
IF NAME = 'SMITH'
IF AMT GE 500
The value in another field : IF DIV = HOLD-DIV

A series of literals : IF STATE = 'GA' , 'SC', 'TN'


IF CLASS = 'A' THRU 'E'
IF AMT NE 100 THRU 500
IF DEPT = 900 940 THRU 950 960
THRU 980

- 26 -
EASYTRIEVE PLUS

IF / ELSE
ELSE specifies alternative processing when the condition established by the IF
statement is not met.

 For true IF's, all commands up to the ELSE (or END-IF if no ELSE is present) are
executed.

 For false IF's, commands between ELSE and END-IF are executed.

 Following END-IF, processing continues regardless of the result of the IF.

Example

IF DIV = 'A' THRU 'L'


DEDUCTIONS = GROSS * 15
ELSE
DEDUCTIONS = GROSS * 18
END-IF

Records with the DIV in the A through L range are processed according to the
statements) between the IF and ELSE. For all records with DIV not in the range A
through L, the statement(s) following ELSE is executed until END-IF is reached.

Special Ifs
You use Special Ifs to check the integrity of the data in your files

Syntax
{ALPHABETIC}
{NUMERIC}
{SPACE}
IF field-name [NOT] { SPACES}
{ZERO}
{ ZEROS}
{ ZEROES}

Examples
IF AMT NOT NUMERIC
IF NAME SPACES
IF STATE ALPHABETIC
IF AMT-DUE ZERO

- 27 -
EASYTRIEVE PLUS

Combining Conditional Expressions


You can combine conditional expressions

 All conditional expressions are considered one statement


 AND statements are evaluated before Ors
 Parentheses may alter the normal order of evaluation.

Examples

IF DIV = 'A' AND AMT GE 500 AND STATE = 'GA'

The IF statement is true when all three conditions are true for that record.

IF DIV = 'A' OR STATE = 'GA' AND AMT GE 500

The IF statement is true when (DIV is equal to A) or (STATE is equal to GA and


AMT is greater than or equal to 500)

Assignment Statement
The assignment statement establishes a value in a field. The value can be a copy of a
value in another field, or it can be the result derived from an arithmetic or logical
expression.

The assignment statement also accomplishes data conversion, such as packing or


unpacking data.

Syntax

field-name-1 [INTEGER] [ROUNDED TRUNCATED] {= EQ} field-name-2


literal-1
arithmetic expression

Examples

HOLD-DIV = DIV
DEPT-NAME = 'ACCOUNTING DEPT'
FACTOR = 1.1
PAY = RATE * HOURS
TAX = SALE * .06

- 28 -
EASYTRIEVE PLUS

Calculations
There are four arithmetic operations in EASYTRIEVE PLUS :
* multiplication
/ division
+ addition
- subtraction

Multiplication and division are performed before addition and subtraction in order
from left to right. There must be a space before and after the arithmetic operators.

Syntax

field-name {=EQ} value-1 {* / + -} value-2

Parentheses in Calculations
Parentheses can be used to override the normal order of operation. When parentheses
are used, operation proceeds from the innermost level to the outermost. Any level of
parentheses nesting is allowed.

RESULTS = GROSS - AMT * 1.3


is the same as :
RESULT = GROSS - (AMT * 1.3)
but different from
RESULT = (GROSS - AMT) * 1.3

Rounding in Calculations
To round the results of calculations, use the INTEGER and/or
ROUNDED/TRUNCATED options.

Use the INTEGER option when you want to ignore the fractional portion of a value.
INTEGER indicates that only the digits to the left of the decimal point should be
transferred during the assignment.

Use ROUNDED or TRUNCATED when the receiving field is too small to hold the
fractional result of the assignment. TRUNCATED is the default.

Use the ROUNDED option to round a fractional result of the assignment statement.
Rounding takes place in the commonly accepted manner. That is, the least significant
digit of the result (receiving field) has its value increased by one when the most
significant digit of the excess decimal digits is greater than or equal to five. For
example, if 10.75 is the value of the sending field and the receiving field has one
decimal place, ROUNDED causes the receiving field to receive 10.8.

- 29 -
EASYTRIEVE PLUS

Use the TRUNCATED option to truncate the result of the assignment statement. Low
order digits are truncated on the right as necessary when the result is moved to the
receiving field.

If INTEGER is used with ROUNDED, the result is rounded to the nearest integer
before the INTEGER function is performed. If INTEGER is used with
TRUNCATED, then only the INTEGER function is performed.

INTEGER, ROUNDED, and TRUNCATED are valid only with numeric fields.

Rounding Example
Assume

SENDFLD W 5 N 2 VALUE ( 10.75 )


RCVFLD W 5 N 1

Then :

Assignment Statement RCVFLD Result


RCVFLD INTEGER ROUNDED = SENDFLD 11.0
RCVFLD INTEGER TRUNCATED = SENDFLD 10.0
RCVFLD INTEGER = SENDFLD 10.0
RCVFLD ROUNDED = SENDFLD 10.8
RCVFLD TRUNCATED = SENDFLD 10.7
RCVFLD = SENDFLD 10.7

PRINT
The PRINT statement makes data available for output to a report.

Syntax

PRINT report-name

Example

IF REG = 25
PRINT RPT1
END-IF
Only records with a 25 in the REG field are output to the report.

- 30 -
EASYTRIEVE PLUS

Logic Example

JOB INPUT MSTRFL NAME SAMPLE


INCOME = WEEKLY-GROSS * 52
IF REG = 10
TAX = INCOME * .05
ELSE
TAX = INCOME * .03 '
PRINT RPT1
END-IF
TOTAL-TAX = TOTAL-TAX + TAX
IF DEPT = 45
PRINT RPT2
END-IF
PRINT RPT3
REPORT RPT1
** Report Statements **
REPORT RPT2
** Report Statements **
REPORT RPT3
** Report Statements **

REPORT
The PRINT statement discussed previously identifies records for output. It does not
cause the printing of the report. This is done by the report subactivity.

There are two parts to every report subactivity :

1. REPORT Statement - which specifies the type and physical characteristics of the
report.
2. Report Definition Statements - which define the content of the report.

REPORT Statement
You code the REPORT statement first m a report subactivity. The report
statement includes the keyword REPORT and report parameters.

Parameters are keywords that allow you to assign values that alter the physical
characteristics of the final report. Although you can specify a large number of report
parameters, you can produce most reports using default (EASYTRIEVE PLUS
defined) parameter values.

Report statement parameters provide a simple way to define tailored reports. The
parameters discussed in this section can be divided into three categories :

- 31 -
EASYTRIEVE PLUS

 Spacing control parameters


 Testing aid parameters
 Format determination parameters

Syntax

REPORT report-name +
[PAGESIZE nn] +
[LINESIZE nn] +
[SKIP nn] +
[SPACE nn] +
[TITLE SKIP nn] +
Spacing
Control [SPREAD] +
Parameters [NOSPREAD] +

[NOADJUST] +

[NODATE] +
[NOPAGE] +
[NOHEADING] +
Testing
Aid [LIMIT nn] +
Parameters [EVERY nn] +

Format [LABELS] +
Determination ([ACROSS nn]
Parameters [DOWN nn]
[SIZE nn]

- 32 -
EASYTRIEVE PLUS

Spacing Control Parameters


The following parameters control spacing on a standard format report.

 PAGESIZE - lines per page (default is 58).

 LINESIZE-length of each line (default ~s 132 print positions).

 SKIP - number of blank lines to be inserted between ime groups (default is 0).

 SPACE - number of blanks inserted between field columns and between fields and
Burials in title and detail lines (default is 3).

 TITLESKIP - number of blank lines inserted after last title line before first
heading or detail line (default is 3).

 SPREAD - requests that the columns of data be spread evenly over the entire line,
overrides the SPACE parameter (default is NOSPREAD).

 NOADJUST -requests that the title lines and report be left-justified on the page.
The default is for the report to be centered on the page, SPREAD and
NOADJUST are mutually exclusive.

 NODATE - inhibits printing the date in positions one through eight of the first
title line.

 NOPAGE - inhibits the printing of a page number.

 NO HEADING - inhibits the printing of column headings

Testing Aid Parameters


The following parameters control the amount of data output to a report.

 LIMIT - limits the number of records printed on the report

 EVERY - specifies that only every nth line is printed in the report.

- 33 -
EASYTRIEVE PLUS

Format Determination Parameters


The LABELS option specifies that the report will be in label format rather than the
standard report format. The following sub-parameters are used with LABELS.

 ACROSS specifies the number of labels printed across the print line(default is 4).

 DOWN specifies the number of lines down from the first line of the first label to
the first line of the second label (default is 6).

 SIZE specifies the number of print positions from the first position on the first
label to the first position on the second label (default is 30).

The LABELS option automatically inhibits the printing of the date, page, headings
and titles.

Report Definition Statements


The second part of a report subactivity is the report definition statements. These
statements define the content of your report. When you use report definition
statements, you must code them immediately after the REPORT statement, in the
following order:

SEQUENCE
CONTROL
SUM
TITLE
HEADING
LINE

SEQUENCE
This statement allows you to specify the order of the data in the report.

 You can sequence on any field from any input file or any W working storage field.

 You can sequence on as many fields as your system sort allows.

 Sequence fields are stated in major to minor order.

 The sequence order is ascending. Coding D after a field-name reverses the order
for that field only.

Syntax

SEQUENCE field-name-1 [D] . . . field-name-n [D]

- 34 -
EASYTRIEVE PLUS

Examples

SEQUENCE CO DIV DEPT GROSS-PAY D


SEQUENCE GROUP AMT D CODE

CONTROL
A CONTROL statement specifies that a report should automatically accumulate and
print totals. A control break occurs whenever the value of any control field changes or
end-of-report is reached. CONTROL can be any non-quantitative field from any input
file or any W working storage field. At each control break, the totals are printed for
the quantitative fields specified in the report.

 You can specify an unlimited number of control fields

 Fields are coded on the CONTROL statement in a major to minor order.

Syntax

CONTROL [field-name] [NEW PAGE] [NO PRINT]


[FINAL] [RENUM]

 Final totals are automatically provided. You can alter the default by coding
FINAL NOPRINT.

 NOPRINT following any field-name or FINAL supresses the printing of totals


(which have been accumulated) at that control break.

 NEWPAGE following any field or FINAL causes a new page after the printing of
the control

 break totals (or, in the case of FINAL, before the printing of the final totals). Page
numbers continue.

 RENUM following any field or FINAL causes a new page with page numbers
beginning at one after the printing of the control break totals (or, in the case of
FINAL, before the printing of the final totals).

Examples

CONTROL CO RENUM DIV DEPT NOPRINT


CONTROL FINAL NOPRINT CO NEWPAGE DIV

- 35 -
EASYTRIEVE PLUS

SUM
The SUM statement specifies the quantitative fields to be totaled far a control report.
Normally, EASYTRIEVE PLUS totals all quantitative fields specified on the LINE
statement (to be discussed later). The SUM statement overrides this process; only the
fields specified on the SUM statement are totalled.

 You can use SUM only in control reports

 You can SUM any quantitative field from any active file or any W field

Syntax
SUM quant-field-1 . . . quant-field-n

Examples

SUM GROSS NET

TITLE Statement

The TITLE statement allows you to define a title for your report. Up to 99 titles are
permitted. You can specify literals and/or field names on the TITLE statement.

Syntax

TITLE [nn] [± nn ] [field-name]


[COL nn] [literal]

 You use ±nn to alter the normal spacing between literals or fields on the title lines.
nn spaces are added to or subtracted from the SPACE parameter (default of 3).

 COL nn specifies the print column number where the next title item is to begin. If
you specify COL nn, you must also specify NOADJUST on the REPORT
statement.

 If no TITLEs are coded, the date and page number are not printed.

Examples

TITLE 1 'REPORT ONE'


TITLE 3 'THIS PAGE FOR DIV' -2 DIV-NO
TITLE 4 'ABC COMPANY'

- 36 -
EASYTRIEVE PLUS

prints

12/10/85 REPORT ONE PAGE 1


THIS PAGE FOR DIV 15
ABC COMPANY

HEADING Statement
As in the Library section, you can define an alternate column heading fur a field in the
Report subactivity- The HEADING statement overrides a HEADING parameter
coded in the Library section of the program.

 Use one HEADING statement per field.

 Words in a heading may be stacked to save space in the column.

Syntax

HEADING field-name ('literal'…..)

Example 1

HEADING EMP-NO, 'EMP NO'


prints a column heading on the report that looks like
EMP NO

Example 2
Heading SSN ('SOCIAL' 'SECURITY' 'NUMBER')
prints the stacked column heading
SOCIAL
SECURITY
NUMBER

LINE statement
The LINE statement defines the content of a report line. Use LINE 1 to designate
headings for the report columns.

 You can specify up to 99 lines per record.

 You can specify any field in an input file or in W working storage

Syntax

LINE nn [± nn] [field-name]


[POS nn] [literal]
[COL nn]
- 37 -
EASYTRIEVE PLUS

 Literals print on all lines but not as headings.

 ±nn is used to alter the normal spacing between line items. nn is added to or
subtracted from the SPACE parameter (default of 3).

 POS provides for aligning fields under the corresponding column heading positions
indicated on the LINE 1 statement.

 COL nn species the print column number where the next field is to begin. If you
specify COL nn, you must also specify NOAAJUST on the REPORT statement.

Example

LINE 1 DEPT DIV NAME


LINE 2 POS 2 CODE POS 3 ADDRESS
LINE 3 POS 3 CITY-STATE

prints the field's contents in the following format:


DEPT DIV NAME
911 02 MATT JONES
2232 HILL
ANYWHERE IL

Multiple Reports
Several reports can he produced simultaneously with one pass of the input file. No
special coding is needed for multiple reports on the same printer.

FILE PERSBL FB ( 150 1800)


NAME 17 8 A
EMP# 9 5 N
DEPARTMENT 98 3 N
NET 90 4 P 2
GROSS 94 4 P 2
DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME MULTRPTS


PRINT RPT1
DEDUCTIONS = GROSS - NET
PRINT RPT2
IF DEPARTMENT = 911
PRINT RPT3
END-IF

-----------> REPORT RPT1


TITLE 1 'REPORT ONE'
LINE 1 NAME DEPARTMENT GROSS NET

- 38 -
EASYTRIEVE PLUS

-----------> REPORT RPT2


SEQUENCE DEPARTMENT
TITLE 1 'REPORT TWO'
LINE 1 DEPARTMENT NAME GROSS NET DEDUCTIONS
-----------> REPORT RPT3
CONTROL
TITLE 1 'REPORT THREE - DEPT 911'
LINE 1 NAME GROSS NET DEDUCTIONS

REPORT ONE (RPT1) produces a very simple listing of all employees.

REPORT TWO (RPT2) gives the same information as REPORT ONE but includes
an additional column with the deductions printed.
REPORT THREE (RPT3) produces a report that contains only information from
department 911.

TALLY
TALLY is a system-defined field for control reports. IL contains the number of detail
records printed within each control break and can be printed on the report. TALLY
can only be used in control reports. The value of TALLY only appears on summary
lines.

Example

INPUT
FILE PERSBL FB ( 150 1800)
NAME 17 8 A
EMP# 9 5 N
DEPARTMENT 98 3 N
NET 90 4 P 2
GROSS 94 4 P 2
DEDUCTIONS W 4 P 2
JOB INPUT PERSNL NAME JOB1
IF DEPT = 911 THRU 914
PRINT RPT1
END-IF
REPORT RPT1
SEQUENCE DEPT NAME
CONTROL DEPT
TITLE 1 'NUMBER OF EMPLOYEES BY DEPARTMENT'
HEADING TALLY ('NUMBER' 'OF' 'PEOPLE')
LINE 1 DEPT NAME TALLY

- 39 -
EASYTRIEVE PLUS

OUTPUT
7/28/85 NUMBER OF EMPLOYEES BY DEPARTMENT PAGE 1
DEPT NAME NO. OF PEOPLE
911 ARNOLD
GREEN
HAFER
ISAAC
KRUSE
LARSON
POST
POWELL
REYNOLDS
SMOTH
STRIDE
YOUNG
911 12
912 LOYAL
912 1
914 CROCI
GRECO
MANHART
RYAN
VETTER
914 5
18

Report Exercise

Using the library and job activity sections shown below, code a report subactivity that
produces the following report.

FILE PERSBL FB ( 150 1800)


NAME 17 8 A
EMP# 9 5 N
DEPARTMENT 98 3 N
NET 90 4 P 2
GROSS 94 4 P 2
DEDUCTIONS W 4 P 2
JOB INPUT PERSNL NAME JOB1
DEDUCTIONS = GROSS - NET
IF DEPT = 924 THRU 940
PRINT RPT1
END-IF

- 40 -
EASYTRIEVE PLUS

2/15/89 EXERCISE ONE REPORT PAGE 1


TOTALS FOR DEPARTMENT: 940
NAME EMP# GROSS PAY NET PAY DEDUCTIONS
JONES 10949 804.80 560.63 244.17
KELLY 12403 197.60 145.51 52.09
PHILIPS 05807 253.26 213.76 39.50
WEST 04132 736.00 429.62 306.38
1991.66 1349.52 642.14

2/15/89 EXERCISE ONE REPORT PAGE 2


TOTALS FOR DEPARTMENT: 935
NAME EMP# GROSS PAY NET PAY DEDUCTIONS
NAGLE 00370 554.40 340.59 213.81
OSMON 09481 628.00 411.05 216.95
1182.4 751.64 430.76

2/15/89 EXERCISE ONE REPORT PAGE 3


TOTALS FOR DEPARTMENT: 932
NAME EMP# GROSS PAY NET PAY DEDUCTIONS
BYER 11467 396.68 259.80 136.88
396.68 259.80 136.88

2/15/89 EXERCISE ONE REPORT PAGE 4


TOTALS FOR DEPARTMENT: 931
NAME EMP# GROSS PAY NET PAY DEDUCTIONS
FORREST 03416 13.80 13.19 .61
13.80 13.19 .61

2/15/89 EXERCISE ONE REPORT PAGE 5


TOTALS FOR DEPARTMENT: 924
NAME EMP# GROSS PAY NET PAY DEDUCTIONS
ROGERS 01549 329.00 230.17 98.83
ZOLTAN 04935 125.00 25.00 100.00
454.00 255.17 198.83

- 41 -
EASYTRIEVE PLUS

S Working Storage
You can use S to designate working storage. S fields are fields used mainly for
totaling and percentages. You can not send an S working storage field to a
SEQUENCEd report. You use S working storage for a field that is not associated with
a record (i.e. totals or counters).

Examples
TOTAL-GROSS S6P2
TOTAL-EMPLOYEE S3P0

The value in TOTAL-GROSS can be used for a total of gross salaries for all records
selected for the report. The value in TOTAL-EMPLOYEE can be added to for a total
number of employees selected for the report.

JOB INPUT PAYFILE


TOTAL-GROSS = TOTAL-GROSS + GROSS-PAY
TOTAL-EMPLOYEE = TOTAL-EMPLOYEE + 1

Relative Start-Location
You can define the start-location of a field relative to a previously defined position in
the record. Relatively defining a start-location eliminates the need to identify the
actual start-location of a field. Relative start-locations are most useful when you are
creating output files.

Use an asterisk in place of the number for a start-location when defining a field as
relative to the previous field. When you use an asterisk, every field in the file should
use the asterisk and every field must be defined.

Examples

EMP# * 5 N
NAME * 16 A
FILLER1 * 10 N
ADDRESS * 39 A

The ADDRESS field would then start in position 32 in the record.

- 42 -
EASYTRIEVE PLUS

Relative Redefinition
You can relatively redefine a field by designating the original field-name as the
starting location for all subsequent fields in the redefinition.

Example

DATE OF BIRTH W 6 N
MONTH DATE OF BIRTH 2 N
DAY DATE OF BIRTH +2 2 N
YEAR DATE OF BIRTH +4 2 N

The starting position of the redefined field is designated by using the original field
name plus the sum of the lengths of all previous fields used in the redefinition.

JOB ACTIVITY
Logic

STOP Statement
A STOP statement allows you to terminate an activity

Syntax STOP [EXECUTE]

 STOP ends the current activity and goes on to the next activity if additional
activities are coded

 STOP EXECUTE immediately terminates all EASYTRIEVE PLUS execution

Example

IF AMT NOT NUMERIC


STOP
END-IF

- 43 -
EASYTRIEVE PLUS

DISPLAY Statement
A DISPLAY statement sends data to a specified output file or output device.
DISPLAY is commonly used:

 For error messages

 For highlighting reports.

 For hex display of selected information.

If DISPLAY is used in the JOB activity, the lines to be DISPLAYed are interspersed
throughout the report in an unSEQUENCEd report. The lines to be DISPLAYed are
printed at the beginning of a SEQUENCEd report.

Syntax

The DISPLAY statement has three different syntax formats. The next two pages show
two formats with explanations and examples of the use of each of the formats.

Format 1
DISPLAY [file-name] [NEWPAGE] [+ integer]
[SKIP NUMBER] [ COL integer]
[POS integer]

[literal-1] [literal-n]
[field-name-1] ……… [field-name-n]

file-name

When you specify file-name, EASYTRIEVE PLUS prints data to the named file. If
you do not specify file-name, the default is SYSPRINT/SYSLST (EASYTRIEVE
PLUS output files).

NEWPAGE
The NEWPAGE option specifies that a skip to a new page occurs before the data is
printed.

SKIP number
The SKIP option specifies that the designated number of lines are skipped before the
data is printed.

- 44 -
EASYTRIEVE PLUS

Integer
Coding an integer modifies the horizontal spacing between display items

COL Integer

The COL integer option specifies the print column- number where EASYTRIEVE
PLUS places the next display item.

POS Integer

The POS integer option on DISPLAY statements within report procedures causes the
next display item to be positioned under the corresponding position on LINE 1
statement.

Literals or field-name
Code literals or field-names in the order you want them to appear on the printed line.

Example of Format 1

DISPLAY SKIP 2 '** RECORD NOT FOUND FOR KEY' +2 SSN

DISPLAY ERRFILE 'THIS REPORT IS FOR ERRORS +


THAT WERE FOUND IN THE EDIT PHASE.'

Format II

DISPLAY [filename] NEWPAGE HEX [field-name]


SKIP NUMBER [file-
name]

In this format, EASYTRIEVE PLUS produces a hexadecimal and character dump of


the current record or the specified field-name. The parameters, other than HEX,
operate the same as in Format 1

Example of Format II

DISPLAY HEX NAME

produces :

CHAR WIMN
ZONE ECDD44444444444444

- 45 -
EASYTRIEVE PLUS

NUMR 6945000000000000000
1..…5..…10..…15..…20

Report
REPORT Statement
In addition to the REPORT statement parameters , the following can be used ;

REPORT report-name

DTLCT FIRST
EVERY +
NONE

Format
Determination SUMCTL HIAR
Parameters NONE [DTLCOPY] ) +
TAG

[SUMMARY] +
[SUMSPACE n] +
[TALLYSIZE n] +
[SUMFILE file-name] +

File
Directing [PRINTER file-name]
Parameters

- 46 -
EASYTRIEVE PLUS

Format Determination Parameters


DTLCTL

DTLCTL determines when control field values are printed on detail lines :

 FIRST detail line (the default)


 EVERY detail line
 NONE of the detail lines

SUMCTL

SUMCTL determines when control field values are printed on total summary lines

HIAR

HIAR prints all fields from major control to minor control as far as the breaking field.
HIAR is the default

NONE

NONE inhibits printing of control field values on total lines

TAG

TAG prints the control field name and the literal TOTAL on the left side of the
subtotals and total lines of the report

DTLCOPY

DTLCOPY prints all values from detail lines onto summary lines

The following examples illustrates what effect these format determination parameters
have on the final output in a control report.

- 47 -
EASYTRIEVE PLUS

Report: Control Example 1

 Control breaks on MARITAL-STAT and REGION with totals and final totals
 Tags on total lines

INPUT

FILE PERSNL +
FB ( 150 1800 )
REGION 1 1 N
BRANCH 2 2 N
EMP # 9 5 N HEADING ('EMPLOYEE' 'NUMBER')
PAY - NET 90 4 P 2 HEADING ('NET' 'PAY')
PAY - GROSS 94 4 P 2 HEADING ('GROSS' 'PAY')
MARITAL-STAT 128 1 A HEADING ('MARITAL' 'STATUS')
* M - MARRIED
* S - SINGLE
DEDUCTIONS W 4 P 2
*
JOB INPUT PERSNL NAME CONTROL-1
DEDUCTIONS = PAY-GROSS - PAY-NET
PRINT CTLRPT1
REPORT CTLRPT1 SPACE 1 LINESIZE 72 SUMCTL TAG
SEQUENCE REGION MARITAL-STAT BRANCH EMP#
CONTROL REGION MARITAL-STAT
TITLE 1 'EASYTRIEVE PLUS CONTROL EXAMPLE ONE'
TITLES 3 'NOTICE THE CONTROL BREAK FIELDS
TITLE 4 'AND CONTROL BREAK LINES'
LINE 1 REGION BRANCH MARITAL-STAT EMP# PAY-GROSS PAY-NET
DEDUCTIONS

- 48 -
EASYTRIEVE PLUS

OUTPUT

10/23/87 EASYTRIEVE PLUS CONTROL EXAMPLE ONE


NOTICE THE CONTROL BREAK FIELDS
AND CONTROL BREAK LINES

MARITAL EMPLOYEE GROSS NET


REGION BRANCH STATUS NUMBER PAY PAY DEDUCTIONS
1 02 M 11473 759.20 547.88 211.32
04 11467 396.68 259.80 136.88
MARITAL-STAT TOTAL 1155.88 807.68 348.20

1 01 S 12267 373.60 251.65 121.95


01 02200 804.64 554.31 250.33
02 00370 554.40 340.59 213.81
03 11602 344.80 250.89 93.91
03 02688 146.16 103.43 42.73
04 11931 492.26 355.19 137.07
04 11357 283.92 215.47 68.45
04 01963 445.50 356.87 88.63
MARITAL-STAT-TOTAL 3445.28 2428.40 1016.88

REGION TOTAL 4601.16 3236.08 1365.08

2 01 M 11376 360.80 223.71 137.09


02 03571 242.40 182.09 60.31
03 04234 386.40 283.19 103.21
03 03416 13.80 13.19 .61
05 04225 295.20 230.50 64.70
05 01895 279.36 189.06 90.30
MARITAL-STAT-TOTAL 1577.96 11121.74 456.22

2 02 S 11710 243.20 167.96 75.24


03 02765 135.85 109.60 26.25
03 00577 220.80 154.70 66.10
04 00445 292.00 206.60 85.40
MARITAL-STAT-TOTAL 891.85 638.86 252.99

REGION TOTAL 2469.81 1760.60 709.21

CONTD…..

- 49 -
EASYTRIEVE PLUS

3 01 M 04589 313.60 229.69 83.91


02 01730 315.20 202.43 112.77
03 09481 628.00 411.05 216.95
03 05914 313.60 222.61 90.99
03 01549 329.00 230.17 98.33
04 12829 365.60 238.04 127.56
MARITAL-STAT-TOTAL 2265.00 1533.99 731.01

3 01 S 12403 197.60 145.51 52.09


01 05807 253.26 213.76 39.50
01 04132 736.00 429.62 306.38
02 12641 313.60 219.91 93.69
02 09609 310.40 215.91 94.49
02 07231 1004.00 685.23 318.77
02 05805 174.15 134.03 40.12
02 01743 250.40 187.40 63.00

- 50 -
EASYTRIEVE PLUS

10/23/87 EASYTRIEVE PLUS CONTROL EXAMPLE ONE


NOTICE THE CONTROL BREAK FIELDS
AND CONTROL BREAK LINES

MARITAL EMPLOYEE GROSS NET


REGION BRANCH STATUS NUMBER PAY PAY DEDUCTIONS
3 03 S 07781 310.40 224.36 86.04
03 03936 324.00 242.25 81.75
03 03890 386.40 272.53 113.87
04 12318 282.40 195.13 87.27
04 08262 376.00 215.95 160.05
MARITAL-STAT-TOTAL 4918.61 3381.59 11537.02

REGIONAL TOTAL 7183.61 4915.58 2268.03

4 01 M 05482 183.75 141.47 42.28


02 09764 121.95 96.64 25.31
03 11211 424.00 282.45 141.55
04 10260 591.20 459.57 131.63
MARITAL-STAT-TOTAL 11320.90 980.13 340.77

4 01 S 10961 329.20 291.70 107.50


01 05525 460.80 279.56 181.24
02 06239 712.80 451.92 260.88
03 10949 804.80 560.63 244.17
03 04935 125.00 25.00 100.00
MARITAL-STAT-TOTAL 2502.60 1608.81 893.79

REGIONAL TOTAL 3823.50 2588.94 1234.56

FINAL TOTAL 18078.08 12501.20 5576.88

- 51 -
EASYTRIEVE PLUS

Report : Control Example 2

 Control breaks on REGION and MARITAL STATUS


 Each REGION starts on a new page and REGION values are in the titles
 Totals for each region are printed but no final totals are printed

INPUT

FILE PERSNL +
FB ( 150 1800 )
REGION 1N 1
BRANCH 2N 2
EMP # 9 5
N HEADING ('EMPLOYEE' 'NUMBER')
PAY - NET 90 4
P 2 HEADING ('NET' 'PAY')
PAY - GROSS 94 4
P 2 HEADING ('GROSS' 'PAY')
MARITAL-STAT 128 1
A HEADING ('MARITAL' 'STATUS')
* M - MARRIED
* S - SINGLE
DEDUCTIONS W 4 P 2
JOB INPUT PERSNL NAME CONTROL-2
DEDUCTIONS = PAY-GROSS - PAY-NET
PRINT CTLRPT2
REPORT CTLRPT2 SPACE 1 LINESIZE 72 SUMCTL TAG
SEQUENCE REGION MARITAL-STAT BRANCH EMP#
CONTROL FINAL NOPRINT REGION RENUM ,ARITAL-STAT
TITLE 01 'EASYTRIEVE PLUS CONTROL EXAMPLE TWO
TITLES 03 'NOTICE THE FOLLOWING VARIABLE TITLE INFORMATION'
TITLE 05 'THIS PAGE CONTAINS INFORMATION ABOUT'
TITLE 06 'REGION : ' REGION
LINE 1 MARITAL-STAT BRANCH EMP# PAY-GROSS PAY-NET DEDUCTIONS

- 52 -
EASYTRIEVE PLUS

10/23/87 EASYTRIEVE PLUS CONTROL EXAMPLE TWO


NOTICE THE FOLLOWING VARIABLE TITLE INFORMATION
THIS PAGE CONTAINS INFORMATION ABOUT
REGION : 1

MARITAL EMPLOYEE GROSS NET


STATUS BRANCH NUMBER PAY PAY DEDUCTIONS
02 11473 759.20 547.88 211.32
04 11467 396.68 259.80 136.88
M 1155.88 807.68 348.20

01 12267 373.60 251.65 121.95


01 02200 804.64 554.31 250.33
02 00370 554.40 340.59 213.81
03 11602 344.80 250.89 93.91
03 02688 146.16 103.43 42.73
04 11931 492.26 355.19 137.07
04 11357 283.92 215.47 68.45
04 01963 445.50 356.87 88.63
S 3445.28 2428.40 1016.88

4601.16 3236.08 1365.08

- 53 -
EASYTRIEVE PLUS

10/23/87 EASYTRIEVE PLUS CONTROL EXAMPLE TWO


NOTICE THE FOLLOWING VARIABLE TITLE INFORMATION
THIS PAGE CONTAINS INFORMATION ABOUT
REGION : 2

MARITAL EMPLOYEE GROSS NET


STATUS BRANCH NUMBER PAY PAY DEDUCTIONS
M 01 11376 360.80 223.71 137.09
02 03571 242.40 182.09 60.31
03 04234 386.40 283.19 103.21
03 03416 13.80 13.19 .61
05 04225 295.20 230.50 64.70
05 01895 279.36 189.06 90.30
M 1577.96 11121.74 456.22

S 02 11710 243.20 167.96 75.24


03 02765 135.85 109.60 26.25
03 00577 220.80 154.70 66.10
04 00445 292.00 206.60 85.40
891.85 638.86 252.99

2469.81 1760.60 709.21

10/23/87 EASYTRIEVE PLUS CONTROL EXAMPLE TWO


NOTICE THE FOLLOWING VARIABLE TITLE INFORMATION
THIS PAGE CONTAINS INFORMATION ABOUT
REGION : 3

MARITAL EMPLOYEE GROSS NET


STATUS BRANCH NUMBER PAY PAY DEDUCTIONS
01 04589 313.60 229.69 83.91
02 01730 315.20 202.43 112.77
03 09481 628.00 411.05 216.95
03 05914 313.60 222.61 90.99
03 01549 329.00 230.17 98.33
04 12829 365.60 238.04 127.56
M 2265.00 1533.99 731.01

01 12403 197.60 145.51 52.09


01 05807 253.26 213.76 39.50
01 04132 736.00 429.62 306.38
02 12641 313.60 219.91 93.69
02 09609 310.40 215.91 94.49
02 07231 1004.00 685.23 318.77
02 05805 174.15 134.03 40.12
02 01743 250.40 187.40 63.00
03 07781 310.40 224.36 86.04
03 03936 324.00 242.25 81.75
03 03890 386.40 272.53 113.87
04 12318 282.40 195.13 87.27

- 54 -
EASYTRIEVE PLUS

04 08262 376.00 215.95 160.05


S 4918.61 3381.59 11537.02

7183.61 4915.58 2268.03

10/23/87 EASYTRIEVE PLUS CONTROL EXAMPLE TWO


NOTICE THE FOLLOWING VARIABLE TITLE INFORMATION
THIS PAGE CONTAINS INFORMATION ABOUT
REGION : 3

MARITAL EMPLOYEE GROSS NET


STATUS BRANCH NUMBER PAY PAY DEDUCTIONS
01 05482 183.75 141.47 42.28
02 09764 121.95 96.64 25.31
03 11211 424.00 282.45 141.55
04 10260 591.20 459.57 131.63
M 11320.90 980.13 340.77

01 10961 329.20 291.70 107.50


01 05525 460.80 279.56 181.24
02 06239 712.80 451.92 260.88
03 10949 804.80 560.63 244.17
03 04935 125.00 25.00 100.00
S 2502.60 1608.81 893.79

3823.50 2588.94 1234.56

- 55 -
EASYTRIEVE PLUS

SUMMARY
SUMMARY produces a summary report that contains only total lines.

SUMSPACE
SUMSPACE increases the print size of the fields on the total line to accommodate a
total value which may be larger than the individual field size. SUMSPACE is added
to the length of the field (in digits) to give the print size for total fields (default of 3).
It is not necessary to account for additional commas in SUMSPACE

TALLYSIZE
TALLYSIZE sets the print size for the field TALLY on a line. The total of
TALLYSIZE and SUMSPACE is the sizer for TALLY on a summary line. The
default for TALLYSIZE is 2.

SUMFILE
SUMFILE generates a summary file. A summary file is a file that contains the values
for all control and summed fields at each minor break. You can request the summary
file by defining the file in the library and then creating it via the REPORT SUMFILE
parameter.

The summary file can be processed by subsequent JOB activities.

The summary file example on the next page demonstrates the use of SUMFILE in an
EASYTRIEVE PLUS program.

SUMFILE Example 1

The summary file has three parts :

1. Control Fields - the fields which appear on the CONTROL statement. i.e.
COMPANY, DIVISION. The control fields must have the same attributes as the input
file.
2. The value TALLY is defined as 10 P 0
3. Summed Fields - the fields on which totals are calculated. All total fields must have
attributes of 10 P

- 56 -
EASYTRIEVE PLUS

SUMFILE data :

---CONTROL FIELDS ----------------------------------------ACCUMULATORS-------------


CONTROL CONTROL SUM SUM
FIELD-1 … FIELD-N TALLY FIELD-1 … FIELD-N

FILE PAYROLL
NAME 17 16 A
ADDRESS 57 20 A
STREET 37 20 A
DEPT 98 3 A
COMPANY 1 1 N
NET 90 4 P 2
DIVISION 2 2 N
GROSS 94 4 P 2
*
FILE SUMMED F ( 33 )
*
JOB INPUT PAYROLL NAME CREATE-SUMFILE
PRINT REPORT 1
REPORT REPORT1 SUMFILE SUMMED
SEQUENCE DEPT COMPANY DIVISION
CONTROL COMPANY DIVISION
TITLE 'THIS IS A SUMMARY REPORT'
LINE COMPANY DIVISION NAME ADDRESS GROSS NET
*
* THE RECORD LAYOUT FOR SUMMED WOULD BE AS FOLLOWS :
* COMPANY 1 1 N < ------ 1
* DIVISION 2 2 N
* TALLY 4 10 P O < ------ 2
* GROSS 14 10 P 2 < ------ 3
* NET 24 10 P 2

- 57 -
EASYTRIEVE PLUS

Example 2

FILE PERSNL FB ( 150, 1800)


REGION 1 1 N
BRANCH 2 2 N
GROSS 94 4 P 2
*
FILE SUMMED F (23)
S-REGION * 1 N
S-BRANCH * 2 N
S-TALLY * 10 P 0
S-GROSS * 10 P 2
*
JOB INPUT PERSNL NAME GEN-SUMFILE
IF REGION = 3 4
PRINT REGION-LISTING
END-IF
REPORT REGION-LISTING LINESIZE 80 SUMFILE SUMMED
SEQUENCE REGION BRANCH
CONTROL REGION BRANCH
TITLE 1 'TOTAL YTD REPORT'
LINE 1 REGION BRANCH GROSS
*
JOB INPUT SUMMED NAME SUM0JOB
PRINT SUM-REPORT
*
REPORT SUM-REPORT LINESIZE 80
TITLE 1 'INTERMEDIATE TOTALS'
LINE S-REGION S-BRANCH S-GROSS S-TALLY

The first report in this program produces a listing of gross salaries with totals at each
REGION and BRANCH control break. The second report is a summary of this report
and is reproduced below :

6/06/88 INTERMEDIATE TOTALS PAGE 1

S-REGION S-BRANCH S-GROSS S-TALLY


3 01 1500.46 4
3 02 2367.75 6
3 03 2291.40 6
3 04 1024.00 3
4 01 1043.75 3
4 02 834.75 2
4 03 1353.80 3
4 04 591.20 1

- 58 -
EASYTRIEVE PLUS

FILE Directing Parameters


PRINTER Parameter

The PRINTER parameter directs the report's printed to a different file.

 Default is SYSPRINT/SYSLST

Multiple Reports

Several reports can be produced simultaneously with one pass of the input file.
Multiple reports in the same run can be directed to the same printer or different
printers.

Same Printer

You need not use special coding for multiple reports on the same printer. Reports are
spooled (sent) to a work file (temporary storage area) when the printer is busy.
 Spooling is automatic
 Any field, with the exception of S working storage, referenced in a REPORT
subactivity will be spooled

Separate Printers

When using separate printers, you must define printer files in the library section with
FILE statements containing the PRINTER parameter.

 The REPORT statement must identify the file-name with the PRINTER parameter
FILE PAYFILE
NAME 17 16 A
ADDRESS 57 20 A
STREET 37 20 A
EMP-NUMBER 9 5 N
*
FILE SPFORM PRINTER
*
JOB INPUT PAYFILE NAME MULT-PRINTERS
IF EMP-NUMBER LE 12345
PRINT ALBEL-REPORT
PRINT NORM-REPORT
END-IF
*
1 ------- > REPORT LABEL-REPORT LABELS PRINTER SPFORM
SEQUENCE EMP-NUMBER
LINE 1 NAME
LINE 3 STREET
LINE 5 ADDRESS

- 59 -
EASYTRIEVE PLUS

2 -------- > REPORT NORM-REPORT


LINE 1 NAME ADRESS EMP-NUMBER
This exhibit shows an EASYTRIEVE PLUS program that produces the following reports.

1. The first report subactivity produces a label report on the printer designated SPFORM
in the second file statement
2. The second report subactivity produces a standard report. It will be output to the
printer you normally use with other EASYTRIEVE PLUS programs

Report Procedures (PROCs)


Report Procedures (PROCs) are routines that are automatically invoked within a
report subactivity to perform special data manipulation not included in the Logic
subactivity. There are seven report PROCs in EASYTRIEVE PLUS.

You code report procedures immediately after the last LINE statement of each report
in your program

Syntax

REPORT statement
LINE statement

REPORT-INPUT. PROC
BEFORE-BREAK PROC
AFTER-BREAK PROC
BEFORE-LINE PROC
AFTER-LINE PROC
ENDPAGE PROC
TERMINATION PROC

** procedure logic **
END-PROC

 You must code END-PROC at the end of each procedure


 You code the logic to be executed in a report PROC the same way you code
logic in a JOB activity
 No I/O is permitted
 Although you may code these procs in any order, each proc may only be used
once per report

- 60 -
EASYTRIEVE PLUS

REPORT-INPUT. PROC
The REPORT-INPUT. PROC allows for final screening and modification of report
input data. It is performed for each record selected for the report that contains the
PROC

 You must execute a SELECT statement in the PROC to cause data to continue to
the report
 If a report has been SEQUENCEd, this procedure is invoked after each record is
output from the sort

Example

FILE PERSNL
** field definition **
TOT-NET S 5 P 2
PCT-NET-TO-TOT W 3 P 1
*
JOB INPUT PERSNL NAME RPTINPT
TOT-NET = TOT-NET + PAY-NET
PRINT PCT-RPT
*
REPORT PCT-RPT LIMIT 20
SEQUENCE BRANCH EMP#
CONTROL FINAL NOPRINT BRANCH NOPRINT
TITLE 1 'EXAMPLE OF REPORT-INPUT PROC'
LINE 1 BRANCH NAME EP# PAY-NET PCT-NET-TO-TOT
*
------- > REPORT-INPUT. PROC
PCT-NET-TO-TOT = PAY-NET / TOT-NET * 100 + .05
SELECT
END-PROC

- 61 -
EASYTRIEVE PLUS

OUTPUT

9/06/85 EXAMPLE OF REPORT-INPUT PROC PAGE 1

EMPLOYEE NET
BRANCH EMPLOYEE NAME NUMBER PAY PCT-NET-TO-TOT
1 BRANDOW LYDIA 02200 554.31 4.4
HUSS PATTI 11376 223.71 1.8
WIMN GLORIA 12267 251.65 2.0

2 NAGLE MARY 00370 340.59 2.7


KRUSE MAX 03571 182.09 1.5
BERG NANCY 11473 547.88 4.4
POWELL CAROL 11710 167.96 1.3

3 PETRIK KATHY 00577 154.70 1.2


CORNING GEORGE 02688 103.43 .8
DENNING RALPH 02765 109.60 .9
FORREST BILL 03416 13.19 .1
MCMOHAN BARBARA 04234 283.19 2.3
MANHART VIRGINIA 11602 250.89 2.0

4 POST JEAN 00445 206.60 1.7


ARNOLD LINDA 01963 356.87 2.9
LARSON RODNEY 11357 215.47 1.7
BYER JULIE 11467 259.80 2.1
TALL ELAINE 11931 355.19 2.8

5 VETTER DENISE 01895 189.06 1.5


LOYAL NED 04225 230.50 1.8

- 62 -
EASYTRIEVE PLUS

BEFORE-BREAK. PROC
The BEFORE-BREAK. PROC allows for modification of totals and special annotation
before total line printing caused by the CONTROL statement.

 LEVEL is a system-defined field and can be used to determine the appropriate break :

LEVEL = 1 for minor break


= 2 for next break
= N + 1 for final totals
(N is the number of control fields)

Example

FILE PAYROLL
EMP# 9 5 N HEADING ('EMPLOYEE' 'NUMBER')
NET 90 4 P 2 HEADING ('NET' 'PAY')
DEPT 98 3 N
GROSS 94 4 P 2 HEADING ('GROSS' 'PAY')
DED W 3 P 2
PCT W 4 N 2
JOB INPUT PAYROLLL NAME CORRECT-PCT
IF DEPT = 911 914 921
DED = GROSS - NET
PCT = DED / GROSS * 100
PRINT PCT-REPORT
END-IF
REPORT PCT-REPORT LINESIZE 73
SEQUENCE DEPT
CONTROL DEPT NOPRINT
TITLE 1 'THIS REPORT WILL ILLUSTRATE USE OF'
TITLE 2 'BEFORE-BREAK PROCEDURE'
LINE DEPT EMP# GROSS NET DED PCT
BEFORE-BREAK. PROC
PCT = DED / GROSS * 100
IF LEVEL = 1
DISPLAY SKIP 1 'DEPARTMENT' DEPT POS 3 GROSS POS 4
NET + POS 5 DED POS 6 PCT
DISPLAY SKIP 1
END-IF
END-PROC

- 63 -
EASYTRIEVE PLUS

OUTPUT

8/20/85 THIS REPORT WILL ILLUSTRATE USE OF PAGE 1


BEFORE-BREAK PROCEDEURE

EMPLOYEE GROSS NET


DEPT NUMBER PAY PAY DED PCT

911 00445 292.00 206.60 85.40 29.24


11710 243.24 167.96 75.24 30.93
11357 283.92 215.47 68.45 24.10
01963 445.50 356.87 88.63 19.89
09764 121.95 96.64 25.31 20.75
04589 313.60 229.69 83.91 26.75
05805 174.15 134.03 40.12 23.03
03890 386.40 272.53 113.87 29.46
12461 313.60 219.91 93.69 29.87
12829 365.60 238.04 127.56 34.89
01730 315.20 202.43 112.77 35.77
03571 242.40 182.09 60.31 24.88

DEPARTMENT 911 3497.52 2522.26 975.26 27.88 < ---

914 07231 1004.00 685.23 318.77 31.75


08262 376.00 215.95 160.05 42.56
10961 399.20 291.70 107.50 26.92
11602 344.80 250.89 93.91 27.23
00185 279.36 189.06 90.30 32.32

DEPARTMENT 914 2403.36 1632.83 770.53 32.06 < ---

921 00577 220.80 154.70 66.10 29.93


11376 360.80 223.71 137.09 37.99
05482 183.75 141.47 42.28 23.00

DEPARTMENT 921 765.35 519.88 245.47 32.07 < ---

6666.23 4674.97 1991.26 29.87

The BEFORE-BREAK. PROC caused the DEPARTMENT annotation at each of the


breaks and modified the total in PCT to be the percent based on total amounts.

- 64 -
EASYTRIEVE PLUS

AFTER-BREAK. PROC
The AFTER-BREAK. PROC allows for specified annotation after control break lines are
printed.

 LEVEL can be tested here also.

BEFORE-LINE. PROC
The BEFORE-LINE. PROC allows for special annotation before each detail line is
printed.

ENDPAGE. PROC
The ENDPAGE. PROC is invoked whenever end of page is detected. It allows for
page totals or footer information on the bottom of each page.

TERMINATION. PROC
The TERMINATION. PROC is invoked at the end of the report. It allows for report
footer information only on the last page of the report.

- 65 -
EASYTRIEVE PLUS

EXERCISE
Using the necessary fields from the PERSNL file layout, code an EASYTRIEVE
PLUS program, with one JOB activity, to produce the reports found on this page and
the next page.

4/24/86 SUMMARY EXAMPLE REPORT

NET GROSS NUMBER OF


DEPT PAY PAY EMPLOYEES

911 2522.26 3497.52 12


912 230.50 295.20 1
914 1632.83 2403.36 5
915 103.43 146.16 1
917 355.19 492.26 1
918 778.67 1115.04 2
919 109.60 135.85 1
920 222.61 313.60 1
921 519.88 765.35 3
923 403.31 560.80 2
924 255.17 454.00 2
931 13.19 13.80 1
932 259.80 396.68 1
935 751.64 1182.40 2
940 1349.64 1991.66 4
942 647.05 995.20 2
943 1290.64 1736.80 3
944 521.81 784.80 2
11967.10 17280.48 46

- 66 -
EASYTRIEVE PLUS

4/24/86 REPORT PROCS EXAMPLE REPORT

SOCIAL
EMPLOYEE EMPLOYEE SECURITY GROSS
DEPT NAME NUMBER NUMBER PAY

911 ARNOLD LINDA 01963 281-36-2873 445.50


GREEN BRENDA 12820 208-28-2315 365.60
HAFER ARTHUR 09764 104-20-0956 121.95
ISAAC RUTH 12641 418-46-1872 313.60
KRUSE MAX 03571 284-36-5652 242.40
LAROSN RODNEY 11357 554-70-3189 283.92
POST JEAN 00445 190-32-2101 292.00
POWELL CAROL 11710 579-50-4818 243.20
REYNOLDS WILLIAM 05805 051-30-8680 174.15
SMOTH CINDY 01730 578-38-7587 315.20
STRIDE ANN 03890 467-56-4149 386.40
YOUNG JANE 04589 118-34-8805 313.60

DEPT 911 TOTAL 3497.52

914 CROCI JUDY 08262 577-16-2985 376.00


GRECO LESLIE 07231 388-18-6119 1004.00
MANHART VIRGINIA 11602 298-34-4755 344.80
RYAN PAMELA 10961 558-44-7609 399.20
VETTER DENISE 01895 235-72-1049 279.36

DEPT 914 TOTAL 2403.36

FINAL TOTALS 5900.88

- 67 -
EASYTRIEVE PLUS

LIBRARY
FILE Statement
The FILE statement describes an input or output file and is coded in the Library
section of an EASYTRIEVE PLUS program. The syntax of the FILE statement is
determined by the types of system you are using to run EASYTRIEVE PLUS
programs.

OS FILE Statement Syntax

FILE ddname +

file IS
type VS ( [ES] [F] [PASSWORD] 'literal' ] )

device [CARD] +
type

F lrecl
V maxlrecl + 4
record U blksize
format FB (lrecl) blksize )
FULLTRK

VB (maxlrecl + 4 maxblksize + 4 )

FULLTRK

VBS (maxlrecl + 4 maxblksize + 4 )

FULLTRK

- 68 -
EASYTRIEVE PLUS

DOS FILE Statement Syntax

FILE dlblname
Tlblname +

[SYSxxx] +

file IS
type VS ( [ES] [F] [PASSWORD] 'literal'] )

device DISK [device-type]


type REWIND
TAPE ( [NL [ # reels ] ] UNLOAD )
NORWD

CARD

F lrecl
V maxlrecl + 4
record U blksize
format FB (lrecl) blksize )
FULLTRK

VB (maxlrecl + 4 maxblksize + 4 )

FULLTRK

VBS (maxlrecl + 4 maxblksize + 4 )

FULLTRK

- 69 -
EASYTRIEVE PLUS

Virtual File Manager (VFM)


VFM provides an easy method for establishing temporary work files without special
job control or file allocation statements. VFM is a sequential access method for
program work files. It dynamically allocates space in memory for work files when
sequencing a report or when producing multiple reports

 When a virtual file is read back into the program, space is released and becomes
available for reuse unless you code RETAIN on the statement
 If the area in memory (default is 64K) is exhausted, VFM writes the excess data to
a single spill area on disk

Syntax

FILE file-name F (lrecl) VIRTUAL [RETAIN]

F (lrecl)

F (lrecl) designates the record length

VIRTUAL

VIRTUAL causes the file to be created and maintained by the VFM

RETAIN

RETAIN causes VFM files to be retained for the duration of the EASYTRIEVE
PLUS program execution

- 70 -
EASYTRIEVE PLUS

COPY Statement
The COPY statement duplicates the field definitions of a named file. You can code an
unlimited number of COPY statements for any one file

Syntax

COPY (file-name)

When the same field-name is used in more than one file in the same activity, you must
qualify duplicate field-name by adding the file-name as a prefix separated by a colon.
Example : OUTFILE:NAME

Example

FILE INONE
FLD-ONE 10 1 A
FLD-TWO 11 3 N
FILE INTWO
----- > COPY INONE
JOB INPUT INTOW NAME COPY-EXAMPLE
IF INTWO : FLD-ONE
** Logic **

EXIT Parameter
The EXIT parameter on the FILE statement invokes a user routine for every input or
output operation for that file.

 You use EXIT to access a routine that converts non-standard data files that
EASYTRIEVE PLUS does not process directly.
 EXIT is not valid for VFM, IMS/DLI or IDMS

Syntax

FILE file-name [EXIT (program-name [NR] +

USING ( field-name …) [MODIFY] ) ]


'literal'

NR

NR has meaning only in DOS; NR indicates that the program is non-relocatable

- 71 -
EASYTRIEVE PLUS

USING

USING specifies the parameters to be passed. It is limited to working storage system,


defined fields, and card literals

MODIFY

MODIFY specifies that the exit can inspect and modify each record after input or
before output

ACTIVITY

CALL Statement
The CALL statement invokes an external subprogram. Usually, the CALLed program
is an existing program in another language that performs a function otherwise
unsupported by EASYTRIEVE PLUS

Syntax

CALL program-name [NR] USING ( field-name-1


…) +
'literal'

[RETURNS field-name-2

MOVE Statement
You use the MOVE statement to transfer data from one location to another. MOVE is
useful for moving data without conversion and for moving character strings with
variable lengths.

 You can move a field or literal to a field or move a file to a file


 A sending field longer than a receiving field is truncated on the right
 A longer receiving field is padded on the right with spaces or an alternate
fill character
 Spaces or zeroes can be moved to one or many fields

- 72 -
EASYTRIEVE PLUS

Syntax

The MOVE statement syntax has two formats

Format I

MOVE file-name-1 [send-length] TO file-name-2


field-name-1 field-name-2
literal

[receive-length] [FILL literal ]

When you specify Format 1, data moves from one field to another filling on the right.
The FILL parameter allows you to place characters in the unused spaces of the new
field (the default is space)

Example

MOVE NAME 20 TO HOLS-NAME


MOVE NAME CTR TO HOLD-NAME FILL '*'

Format 2

SPACE
SPACES
MOVE ZERO TO fiels-name-1 field-name-n
ZEROS
ZEROES

You can use Format 2 to initialize the receiving field.

Example

MOVE SPACES TO NAME, HOLD-NAME, HOLD-DIV

- 73 -
EASYTRIEVE PLUS

MOVE LIKE
MOVE LIKE moves the value of fields with identical names from one file to another
while converting numeric data-types from one format to another

 The rules for the assignment statement also apply to MOVE LIKE
 Because the same field-name can be used in more than one file, you must qualify
duplicate field-name by prefixing the field-name with the file-name and a colon

Syntax

MOVE LIKE file-name-1 to file-name-2

Example

FILE INFILE
NAME 17 20 A
DEPT 98 3 N
AMT 90 4 P 2
FILE OUTFIL1
AMT 1 7 N 2
NAME 8 20 A
JOB INPUT INFILE1 NAME MOVE-LIKE-EXAMPLE
[logic]
*
---- > MOVE LIKE INFILE1 TO OUTFIL1
** Logic **

User-Procedures (PROCs)
A user PROC is a group of user-written EASYTRIEVE PLUS statements designed to
accomplish a task. You use a user PROC when identical logic is needed in several
places in the activity

A user PROC must be invoked in the activity with a PERFORM statement

PERFORM Syntax

PERFORM proc-name

The proc-name may be one to forty characters long and must begin with a letter

You code the procedure at the end of the activity in which it is PERFORMed

- 74 -
EASYTRIEVE PLUS

PROC Syntax

proc-name
** Logic **
END-PROC

Proc-name

Proc-name is the same name as in the PERFORM statement and is followed by a


period, a space, and the keyword PROC

END-PROC
Every PROC must have an END-PROC. At END-PROC, control is returned to the
statement following the PERFORM statement that invoked the PROC

Example

IF CODE = 1
---- > PERFORM CODE1-RTN
ELSE
PERFORM CODE2-RTN
END-IF
** Logic **
----- > CODE1-RTN PROC
ORDER = 'NO'
END-PROC
CODE2-RTN PROC
ORDER = 'YES'
END-PROC

- 75 -
EASYTRIEVE PLUS

Nesting PROCs
A PERFORM statement within a procedure can invoke another procedure

Example

IF DEPT = 911
PERFORM PROCA
END-IF

** Logic **
PROCA PROC
IF ST = 'NY'
PERFORM PROCB
ELSE
---------- > TAX = GROSS * .05
END-IF
END-PROC
PROCB PROC
TAX = GROSS * .1
END-PROC

START/FINISH Parameters
You use the optional START and FINISH parameters of the JOB statements to
automatically incorporate procedures into processing activities

Syntax

JOB INPUT file-name [NAME job-name]


[ START proc-name ] [FINISH proc-name ]

START Parameter

You use START to identify a procedure to be executed during initiation of the JOB
activity

 The procedure is invoked automatically after the file is opened but prior to
reading the first input record
 A typical START procedure might initialize working storage fields or
establish a position in a keyed sequenced file

- 76 -
EASYTRIEVE PLUS

FINISH Parameter

You use FINISH to identify a procedure to be executed during the normal termination
of the JOB activity

 The procedure is invoked after the last input record is processed but before
any files are closed
 A typical FINISH procedure displays control information accumulated
during execution of the JOB activity.
 A FINISH proc is invoked if a STOP is encountered but it is not invoked if
a STOP EXECUTE is encountered

GOTO Statement
You use the GOTO statement to modify the natural top-to-bottom logic flow in a
program.

Syntax

GOTO label
GO TO JOB

GOTO

EASYTRIVE PLUS accepts either GOTO or GO TO

Label
Label refers to statement labels. A label can be up to 40 characters long. The first
character must be alphabetic. GOTO label transfers control immediately to the first
statement following the named label statement. (The label statement must be in the
same activity or procedure)

JOB
GOTO JOB transfers control to the top of current JOB activity

Example
JOB INPUT PERSNL NAME DIV-LIST
IF DIV = 'A'
------------ > GOTO JOB
END-IF

- 77 -
EASYTRIEVE PLUS

IF DIV = 'B'
------------ > GOTO CHECK-REG-ROUTINE
END-IF
** Logic **
CHECK-REG-ROUTINE

DO WHILE/END-DO Statements
You use the DO WHILE and END-DO statements to provide a controlled loop for
repetitive program logic

 The logic between DO WHILE and END-DO is executed until the


conditional expression on the DO WHILE statement is false
 Conditional expressions follow the rules of IF statements

Syntax

DO WHILE conditional-expression

** Logic **
END-DO

Example

JOB INPUT PERSNL NAME DO-EX-1


CTR = 0
---- > DO WHILE CTR LT 10
CTR = CTR + 1

** Logic **

END-DO
IF …

Nesting Example
You can nest DO WHILE statements. (The inner logic loop must be completely
within the outer logic loop)

JOB INPUT PAYROLL NAME DO-EX-2


CTR1 = 0
DO WHILE CTR1 LT 10
CTR2 = 0
DO WHILE CTR2 LT 5
CTR2 = CTR2 + 1

** Logic **

END-DO

- 78 -
EASYTRIEVE PLUS

CTR1 = CTR1 + 1

** Logic **

END-DO

SORT
SORT is an activity that sequences an input file on fields specified as keys. SORT
uses the interface to your system sort. You can sort on as many fields as your system
allows.

Syntax

SORT file-name-1 TO file-name-2 +

USING (field-name [D] … ) +

NAME sort-name

File-name-1

File-name-1 is the input file to be sorted

File-name-2

File-name-2 is the output file

USING

USING field-name identifies those fields from file-name-1 that you use as sort keys.
Specify sort keys in major to minor order

D optionally sorts the field contents in descending order (default = ascending order)

NAME sort-name

NAME sort-name identifies the sort activity for documentation purposes

Example

FILE PERSNL FB ( 150 1800 )


NAME 1 10 A
DEPT 11 5 N
GROSS-PAY 16 4 P 2
FILE PAYSORT FB( 150 1800 )

- 79 -
EASYTRIEVE PLUS

--- > SORT PERSNL TO PAYSORT


USING (DEPT GROSS-PAY) +
NAME SORT-EXAMPLE-1

SORT Procedure
You use SORT procedure to select only certain records for sorting and/or to modify
the contents of records before a sort

 A SORT procedure immediately follows the SORT statement


 You invoke a SORT procedure with the BEFORE parameter
 The SORT procedure executes for each record from file-name-1 prior to passing
the record to the sort

Syntax

SORT file-name-1 TO file-name-2 +


USING (field-name [D] … ) +
NAME sort-name +
[BEFORE proc-name]

BEFORE
BEFORE proc-name identifies the procedure

 When you use BEFORE, you must execute a SELECT statement for each record
that you want to sort to the output file
 A SELECTed record outputs only once, even if SELECTed more than once in the
procedure
 Any record not SELECTed does not go to the sorted file

- 80 -
EASYTRIEVE PLUS

Example

This example illustrates the use of the SORT activity and SORT procedures

FILE PERSNL FB( 150 1800)


NAME 1 10 A
DEPT 11 5 N
GROSS-PAY 16 4 P 2
FILE PAYSORT F ( 19 ) VIRTUAL
SORT-NAME 1 10 A
SORT-DEPT 11 5 N
SORT-GROSS-PAY 16 4 P 2
JOB INPUT PERSNL NAME ACT-1
PRINT RPT1
REPORT RPT1
LINE 1 NAME DEPT GROSS-PAY
-------- > SORT PERSNL TO PAYSORT USING (DEPT + GROSS-PAY D)
BEFORE SELECT-REC NAME SORT-ACTIVITY
SELECT-REC. PROC
IF GROSS-PAY GE 500
SELECT
END-IF
END-PROC
JOB INPUT PAYSORT NAME PROCESS-SORTED-FILE
** Logic **

- 81 -
EASYTRIEVE PLUS

FILE PROCESSING
EASYTRIEVE PLUS can process files or data bases 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 data bases

You can let EASYTRIEVE PLUS do all your file processing automatically, or you
can control some or all of the operations yourself

 Automatic I/O (under system control) includes the files specified for input
on the JOB and SORT statements, and the files specified for output on the
SUMMARY parameter of the REPORT statement
 Programmer controlled I/O includes the GET, POINT, and READ
statements for input, and the PUT, WRITE, PRINT, DISPLAY, and SORT
statements for output
 You can not have automatic file access and programmer controlled file
access to the same file within the same activity except when using the
POINT command

This Student Guide discusses all file types except ISAM. If you need information
about ISAM files, ask your instructor.

GET Statement
The GET statement retrieves the next record of the named file into the file input area.

Syntax

GET file-name

file-name - identifies the input file

(EOF) - Test for end-of-file (EOF) when using the GET command

- 82 -
EASYTRIEVE PLUS

Example

FILE MASTER FB ( 150 1800 )


EMP# 9 5 N
NAME 17 16 A
GROSS 94 4 P 2
JOB INPUT NULL NAME READ-SEQ-MAN
------- > GET MASTER
IF EOF MASTER
STOP
END-IF
IF GROSS > 500
PRINT RPT1
END-IF
REPORT RPT1
LINE 1 EMP# NAME GROSS

You use NULL in the JOB statement to inhibit automatic input

PUT Statement
The PUT statement outputs a file sequentially

Syntax

PUT outfile [FROM file-name]

Example 1

FILE PERSNL FB ( 150 1800 )


EMP# 9 5 N
NAME 17 16 A
GROSS 94 4 P 2
FILE NEWPAY2 F (20) VIRTUAL RETAIN
NAME 1 16 A
GROSS 17 4 P 2
JOB INPUT PERSNL NAME PUT-EXAMPLE
** Logic **
MOVE LIKE PERSNL TO NEWPAY2
------------- > PUT NEWPAY2

- 83 -
EASYTRIEVE PLUS

Example 2

FILE MASTER FB ( 150 1800 )


EMP# 9 5 N
NAME 17 16 A
GROSS 94 4 P 2
FILE OUTMAST FB ( 150 1800 )
JOB INPUT MASTER NAME CREATE-SEQ
IF GROSS > 500
*
---------- > PUT OUTMAST FROM MASTER
*
END-IF

- 84 -
EASYTRIEVE PLUS

VSAM
VSAM File Statement
You use the following parameters when working with VSAM files

Syntax

FILE {file-name} VS ( [ES] [F] [PASSWORD] 'literals' ] +


[CREATE RESEST ] [UPDATE] )

VS

VS designates a VSAM file. Default parameters for VSAM file processing are Key
Sequenced Data Sets (KSDS) or Relative Record Data Set (RRDS) with records of
undefined length

ES

Code ES to indicate an Entry Sequenced Data Set (ESDS)

Code F if all records in the file are of the same length. This improves the efficiency of
SORT activities and SEQUENCE statement

PASSWORD literal
Literal is the optional one to eight character password for the VSAM file. You can
specify the password as either an alphabetic literal or a hexadecimal literal. Enclose
these literals in apostrophes

CREATE

Use the CREATE option to load a VSAM file.

RESET

You can reload an existing VSAM file by coding the RESET option with CREATE.
RESET assumes that the file was defined by IDCAMS with the VSAM attributes
REUSE

- 85 -
EASYTRIEVE PLUS

UPDATE

Code the UPDATE option if you wish to update the file with the WRITE or PUT
statement

VSAM File Creation (Loading)


The FILE statement and the PUT statement are used to create (load) VSAM files. The
PUT statement provides for sequential file output to VSAM files

Example

FILE MASTER FB ( 150 1800 )


EMP# 9 5 N
NAME 17 16 A
GROSS 94 4 P 2
-------------- > FILE OUTMAST VS (CREATE RESET)
JOB INPUT MASTER NAME CREATE-VSAM
-------------- > PUT OUTMAST FROM MASTER STATUS
IF OUTMAST : FILE-STATUS NOT ZERO
DISPLAY 'LOAD ERROR STATUS IS : ' +
OUTMAST : FILE-STATUS
STOP
END-IF
PRINT RPT1
REPORT RPT1
LINE 1 EMP# NAME GROSS

STATUS
When you specify STATUS, VSAM return codes are returned to the system defined
field FILE-STATUS.

FILE-STATUS

FILE-STATUS is a system defined field which you can test to identify the result of a
VSAM input/output operation

- 86 -
EASYTRIEVE PLUS

VSAM Input
VSAM input can be sequential or random. Sequential input can be automatic or

FILE-STATUS MEANING
Value
0 Operation performed
Successfully
4 End-of-file during
GET
8 (a) Duplicate key for
a record being output
with PUT or WRITE
(b) Additional records with
the same key exist
alternate index during
a GET operation.
12 Keys not 1n sequence during
PUT operation
16 Record not found during
READ operation

programmer-controlled

Example - Automatic Sequential

FILE MASTER VS
EMP# 9 5 N
NAME 17 16 A
GROSS 94 4 P 2
---------- > JOB INPUT MASTER NAME READ-VSAM-AUTO
IF GROSS > 500
PRINT VSAM-REPORT
END-IF
REPORT VSAM-REPORT
LINE 1 EMP# NAME GROSS

- 87 -
EASYTRIEVE PLUS

Example - Programmer Controlled Sequential

You use the GET statement for programmer controlled input

FILE MASTER VS
EMP# 9 5 N
NAME 17 16 A
GROSS 94 4 P 2
JOB INPUT NULL NAME READ-VSAM-MAN
---------- > GET MASTER STATUS
IF EOF MASTER OR FILE-STATUS NOT ZERO
STOP
END-IF
IF GROSS > 500
PRINT VSAM-REPORT
END-IF
REPORT VSAM-REPORT
LINE 1 EMP# NAME GROSS

- 88 -
EASYTRIEVE PLUS

POINT Statement
You use the POINT statement to establish a position in a keyed file. (Key is the key
defined to VSAM and not necessarily to EASYTRIEVE PLUS)

 Data becomes available only after the next successful sequential retrieval either by
an automatic file input or a GET statement

Syntax

EQ
POINT file-name = field-name STATUS

GE literal
>=

File-name

File-name must be the same as on a FILE statement that describes an indexed, keyed,
or relative-record file

Field-name or Literal

Any valid field-name or literal can be used as a key value for the POINT statement

Example

FILE VSIN VS
DEPT 9 5 N
JOB INPUT VSIN START POINT-PROC NAME POINT-EX

** Logic **

POINT-PROC. PROC
---------- > POINT VSIN GE 300 STATUS
IF EOF VSIN OR FILE-STATUS NOT ZERO
STOP
END-IF
END-PROC

- 89 -
EASYTRIEVE PLUS

READ Statement
The READ statement provides random access to keyed VSAM and to relative-record
VSAM files.

Syntax

field-name
READ file-name KEY 'literal' STATUS

File-name

File-name is the VSAM file-name

Field-name / Literal

Field-name contains the value of the VSAM key to be found. This key value can also
be expressed as a literal

Example : Programmer Controlled Random

FILE PAYROLL
EMP-NO 1 3 N
FILE DNAME VS
EMP-NAME 40 10 A
*
JOB INPUT PAYROLL NAME READ-EXAMPLE
------- > READ DNAME KEY EMP-NO STATUS
IF DNAME : FILE-STATUS NOT ZERO
DISPLAY ERRRPT 'ERROR READING VSAM +
FILE WITH KEY : EMP-NO +
FILE-STATUS IS DNAME : FILE-STATUS
GOTO JOB
END-IF

- 90 -
EASYTRIEVE PLUS

WRITE
You use the WRITE statement to add a new record, update an existing record, or
delete a record from a VSAM file

 When you use WRITE you must specify the UPDATE parameter on the FILE
statement
 Before you can issue a WRITE to delete or update, you must have the record in
the buffer area

Syntax - Format 1

You use Format 1 when adding or updating a VSAM record

WRITE file-name-1 UPDATE [ FROM file-name-2 ] STATUS


ADD

Example

FILE TRANS
DEPT 12 3 N
GROSS 15 4 P 2
*
FILE PAYVS VS (UPDATE)
GROSS 15 4 P 2
*
JOB INPUT TRANS NAME UPDATE-PGM
READ PAYVS KEY DEPT STATUS
IF PAYVS : FILE-STATUS = 16 * RECORD NOT FOUND
--------- > WRITE PAYVS ADD FROM TRANS STATUS
PERFORM ADD-STATUS-CHK
GOTO JOB
END-IF
IF PAYVS : FILE-STATUS = 0 * RECORD NOT FOUND
MOVE LIKE TRANS TO PAYVS
--------- > WRITE PAYVS UPDATE STATUS
PERFORM UPDATE-STATUS-CHK
GOTO JOB
END-IF

- 91 -
EASYTRIEVE PLUS

Syntax - Format 2

You use Format 2 for deleting a VSAM record

WRITE file-name-1 DELETE STATUS

Example

FILE TRANS
TRANS-KEY 14 3 A
TRANS-CODE 17 1 A * TRANS-CODE value of
means Delete
*
FILE PAYVS VS (UPDATE)
JOB INPUT TRANS NAME VSAM-DELETE
IF TRANS-CODE = 'D'
READ PAYVS KEY TRANS-KEY STATUS
IF FILE-STATUS = 0
---------- > WRITE PAYVS DELETE STATUS
PERFORM WRITE-STAT-CHECK
ELSE
DISPLAY 'ERROR IN STATUS CHECK'
END-IF

Synchronized File Processing


The Synchronized File Processing (SFP) facility can be used with one file or multiple
files.

 Single-File Keyed Processing - one file


 Synchronized File Input - multiple files

Single-File Keyed Processing

Using Synchronized File Processing on a single file allows you to compare the
contents of a key field or fields from one record to the next and to use IF tests to
group records according to keys. The file name is coded on the JOB INPUT statement
as follows :

JOB INPUT (filename KEY (keyfield…) )

- 92 -
EASYTRIEVE PLUS

Single-file keyed processing lets you use IF tests to determine where a current key
ends and a new key starts. For example :

IF FIRST-DUP filename OR NOT DUPLICATE filename.

The above IF statement determines the start of a new key.

IF LAST-DUP filename OR NOT DUPLICATE filename

The above IF statement determines the end of the current key

Note that the file must be in ascending order by its key value(s)

Synchronized File Input

Synchronized file input is a method of coordinating the input of multiple fields.


EASYTRIEVE PLUS automatic input includes a universally adaptable match/merge
algorithm. Special conditional expressions help to determine simple, yet precise file
relationships.

The match/merge algorithm is based on the following assumptions and rules :

 Any number of files are capable of being processed


 Keys may be any defined field in the library section of an EASYTRIEVE PLUS
program as long as they are of like data types. Each file must have the same
number of keys
 Keys and files are major to minor
 Duplicate records are exhausted from the most minor to the major file
 START, FINISH, and NAME parameters can be included on the JOB statement
 Processing continues until end-of-file is encountered on all files

Syntax

The JOB statement now looks like this.

JOB INPUT (file-1 KEY (field-1-a field-1-n … ) +


file-2 KEY (field-2-a field-2-n … ) +
file-n KEY (field-n-a field-n-n … ) )
NAME jobname

The INPUT parameter designates files and their keys for synchronized file input.

- 93 -
EASYTRIEVE PLUS

Representation of Synchronized Input Flow


The following discussion illustrates how EASYTRIVE PLUS presents records for
processing.

Three Data Files (in order by key)

The JayMat Corporation has a chain of three stores and each store maintains its credit
card purchases on a separate file. The following chart shows the data in these files.
The data is arranged in this format :

Account # / Account ID / Purchase Amount

Store 1 Store 2 Store 3

1020 P 23.50 1023 P 103.45 1020 P 45.68


1023 P 127.89 1027 M 12.90 1027 P 11.68
1027 M 38.83 1027 S 9.35 1029 P 129.46
1027 S 323.92 1029 M 138.44 1031 P 4.88
1075 M 22.88 1029 S 3.00 1053 P 64.33
1075 S 221.79 1052 P 29.89 1075 M 30.64
1077 P 57.84 1053 P 18.99 1075 S 388.03

Example

This example shows the coding required to synchronize these files

FILE STORE1 FB ( 150 1800 )


ACCT# 1 4 N
FILE STORE2 VS
ACCT# 21 4 N
FILE STORE3 F (220)
ACCT# 16 4 N
*
JOB INPUT (STORE1 KEY ACCT# +
STORE2 KEY ACCT# +
STORE3 KEY ACCT# +
NAME THREE-FILE-MATCH

- 94 -
EASYTRIEVE PLUS

Record Presentation

STORE1 STORE2 STORE3

ACCT# ID ACCT# ID ACCT# ID


1 1020 P -- 1020 P
2 1023 P 1023 P --
3 1027 M 1027 M 1027 P
4 1027 M 1027 S --
5 1027 S -- --
6 -- 1029 M 1029 P
7 -- 1029 S --
8 -- -- 1031 P
9 -- 1052 P --
10 -- 1053 P 1053 P
11 1075 M -- 1075 S
12 1075 M -- 1075 S
13 1075 S -- --
14 1077 P -- --
15 -- 1080 P --

This chart shows how EASYTRIEVE PLUS presents the records from STORE1,
STORE2, and STORE3 for processing. The -- (dashes) indicate that no records from
that store are presented for processing at that time.

Special Tests for Synchronized Files


These conditional statements allow you to determine the relationships between the
current records.

MATCHED
MATCHED tests to see if keys on all current records are matched

Syntax

IF [NOT] MATCHED [ (file-name-1 file-name-2 … file-name-n) ]

Examples

IF MATCHED ( STORE1 STORE2 )

IF MATCHED

- 95 -
EASYTRIEVE PLUS

Checking for Duplicate Records


Syntax

IF [NOT] DUPLICATE file-name


FIRST-DUP
LAST-DUP

DUPLICATE

DUPLICATE tests to see if a duplicate record exists on the same file

FIRST-DUP

FIRST-DUP tests to see if the record is the first in a series of duplicates

LAST-DUP

LAST-DUP tests to see if the record is the last in a series of duplicates

File Presence Test and End of File Test (EOF)


File presence tests to see if there is a record available for processing from a named file
or if end-of-file (EOF) has been reached.

Syntax

IF [NOT] [EOF] file-name

- 96 -
EASYTRIEVE PLUS

Possible Tests for Record Pairs


MASTER TRANS TESTS

ACCT# ID ACCT# ID

4741 TLN 4741 CCR IF MATCHED


IF NOT DUPLICATE TRANS
4742 DSD 4742 MGG IF MATCHED
IF DUPLICATE TRANS
IF FIRST-DUP TRANS
4742 DSD 4742 MES IF DUPLICATE TRANS
4742 DSD 4742 CM IF LAST-DUP TRANS
4743 DV 4743 DAP IF MATCHED (MASTER TRANS)
4744 JPF 4744 NAM IF DUPLICATE MASTER
4744 JPF 4744 TBG IF LAST-DUP TRANS
4744 SHG -- IF NOT TRANS
4745 TMW -- IF MASTER
-- 4747 PSI IF TRANS
4749 JKB -- IF MASTER
4749 JKJ -- IF NOT TRANS
-- 4750 EZT IF EOF MASTER

NOTE : When an ID is repeated, it shows that EASYTRIEVE PLUS is holding that


record for processing while it brings in duplicate records from the second file. ACCT#
is the key in this example.

- 97 -
EASYTRIEVE PLUS

Example 1 - Output to Two Files


Input Files

In this example the MASTER file contains one record for each valid account number.
The STORE1 file contains one record for every transaction made within a certain
time.

1023 MASTER 1025 P 83.21


1027 MASTER 1027 S 14.83
1029 MASTER 1027 S 83.23
1075 MASTER 1027 S 143.21

Code
The following coding produces two new files from MASTER and STORE1.

FILE STORE1 FB ( 45 900 )


ACCT-NO-1 1 3 P
ACCT-ID 4 1 A
ACCT-NAME 5 30 A
PURCHASE AMT 35 3 P 2
FILE MASTER FB ( 30 600 )
ACCT-NO-MAST 1 3 P
FILE INVALID FB ( 45 900 )
FILE MERGED FB ( 45 900 )
JOB INPUT (MASTER KEY ACCT-NO-MAST +
STORE1 KEY ACCT-NO-1) +
NAME TWO-FILE-MERGE
IF NOT STORE1
GOTO JOB
END-IF
IF NOT MASTER
PUT INVALID FROM STORE1
GOTO JOB
END-IF
IF NOT DUPLICATE STORE1 OR +
LAST-DUP STORE1
PUT MERGED FROM STORE1
PUT MERGED FROM MASTER
ELSE
PUT MERGED FROM STORE1
END-IF

- 98 -
EASYTRIEVE PLUS

Record Presentation for Processing


MASTER STORE1

1020 MASTER 1020 P 53.23


1021 MASTER --
1023 MASTER 1023 M 15.87
-- 1025 P 83.21
1027 MASTER 1027 S 14.83
1027 MASTER 1027 S 83.23
1027 MASTER 1027 S 143.21
1029 MASTER --
1075 MASTER --

Representation of Output Files


For a single transactions on an account number EASYTRIEVE PLUS writes a record
from the transaction file, then the matching record from the master file. For multiple
transactions on a single account number EASYTRIEVE PLUS writes all transactions
to the merged file first then the matching record from the master file.

 MERGED contains records from both input files for each transaction
 INVALID contains a record for each invalid transaction from STORE1 file

MERGED INVALID

1020 P 53.23 1025 P 83.21


1020 MASTER
1023 M 15.87
1023 MASTER
1027 S 14.83
1027 S 83.23
1027 S 143.21
1027 MASTER

- 99 -
EASYTRIEVE PLUS

Example 2 - Updating a Master File

 Synchronized multifile input and special tests simplify the update.


 The following example assumes at most one transaction record per master record

FILE PLDMSTR VS
MASTER-KEY 1 10 A
*
FILE TRANS VS
TRANS-KEY 1 10 A
*
FILE NEWMSTR FB ( 150 1800 )
*
IF DUPLICATE TRANS
PRINT DUPLICATE-TRANS-RPT
GOTO JOB
END-IF
*
IF MATCHED
PERFORM MASTER-UPDATE
PERFORM WRITE-NEW-MASTER
GOTO JOB
END-IF
*
IF OLDMSTR
PERFORM WRITE-NEW-MASTER
GOTO JOB
END-IF
*
IF TRANS
PERFORM MASTER-CREATE
PERFORM WRITE-NEW-MASTER
GOTO JOB
END-IF
** User PROCs **

- 100 -
EASYTRIEVE PLUS

Example 3 - Testing for Duplicates on One File

FILE PERSNL FB ( 150 1800 )


NAME 17 16 A
EMP# 9 5 N
FILE ATTEND F (5) CARD
MAX-VALUE 1 5 N
FILE PERSSORT F ( 150 ) VIRTUAL
COPY PERSNL
SORT PERSNL TO PERSSORT USING (EMP#)
JOB INPUT (PERSSORT KEY EMP# +
ATTEN KEY MAX-VALUE +
NAME DUP-ON-ONE-FILE
IF DUPLICATE PERSSORT
PRINT DUP-EMP#
END-IF
REPORT DUP-EMP#
LINE 1 EMP# NAME
END
99999

- 101 -
EASYTRIEVE PLUS

Multiple Job Activities Exercise


Code all required activity statements to match three files by employee number. Create
file and field-names where needed. Two files must be sorted first. The following rules
apply :

 Select the information for a report if all three files match


 If only the primary and secondary files match print a message to another printer
 If there are duplicate on the third file use only the first of the duplicates

TABLES/INDEXING/ARRAYS
Tables

A table is a collection of uniform data records in a form suitable for quick reference.
Each table entry has :

 A search argument (keyword ARG) that uniquely identifies that entry


 A description (keyword DESC) is the data associated with the argument

The user's objective is to obtain the description from a table of values based on the
search argument.

 A table file must be arranged in ascending order by argument


 No duplicate arguments can be placed in the file
 You can use any number of tables in a job
 A minimum of three entries is required in a table

ARG DESC
____ _____

1 ALABAMA
2 ALASKA
3 ARIZONA

47 WASHINGTON
48 WEST VIRGINIA
49 WISCONSIN
50 WYOMING

- 102 -
EASYTRIEVE PLUS

Syntax

FILE file-name TABLE INSTREAM


Literal

TABLE

The TABLE parameter is specified on the FILE statement. external table files must be
sequentially accessible

INSTREAM

INSTREAM denotes that the table file immediately follows the file description. Data
for an INSTREAM table immediately follows the ARG and DESC field definitions

Literal

Literal specifies the number of entries in an external table. Specify a value here only if
the number of entries is greater than 256

ENDTABLE must be the last entry in the instream table data and must be coded in
column 1 through 8

Instream Example

FILE SATTBL TABLE INSTREAM


ARG 1 2 N
DESC 4 15 A
1 ALABAMA
2 ALASKA
3 ARIZONA

47 WASHINGTON
48 WEST VIRGINIA
49 WISCONSIN
50 WYOMING
END TABLE

- 103 -
EASYTRIEVE PLUS

SEARCH Statement
You use the SEARCH statement to perform an in-core binary search of a table. This is
a very efficient access method. SEARCH can be :

 Coded any place within a JOB activity


 Issued any number of times against any number of tables

Syntax

SEARCH file-name WITH field-name-1 GIVING field-name-2

 File-name is the table name.


 Field-name-1 is the name of a field which contains a value that is compared to the
search argument. It must be the same length and type as the argument
 Field-name-2 is the name of a field into which the description is placed if a match
exists between field-name-1 and the search argument. It must be the same length
and type as the description

Example - Searching an External Table

FILE PERSNL
NAME 17 8 A
STATE 69 2 A
ZIP 71 5 N
GROSS-PAY 94 4 P 2
POST-OFFICE-DESC W 20 A
FILE ZIPTABLE TABLE 5000
ARG 1 5 N
DESC 7 20 A
JOB INPUT PERSNL NAME TABLE-SEARCH
IF STATE = 'DC' 'IL'
SEARCH ZIPTABLE WITH ZIP GIVING POST-OFFICE-DESC
IF NOT ZIPTABLE
POST-OFFICE-DESC = 'BAD ZIP CODE FOUND'
END-IF
PRINT STATE-REPORT
END-IF
REPORT STATE-REPORT
SEQUENCE STATE
CONTROL STATE
TITLE 1 'REPORT OF EMPLOYEE SALARIES BY STATE'
LINE 1 STATE NAME GROSS-PAY ZIP POST-OFFICE-DESC

- 104 -
EASYTRIEVE PLUS

Exercise
Code an EASYTRIEVE PLUS program to accomplish the following :

 Read the Personnel sample file and create a report listing the BRANCH-DESC,
NAME, and PAY-GROSS fields on each line
 Use an instream table of branch name with the following table data : for 01 use
NORTH, for 02 use SOUTH and so on through branch 04
 Select all records for the report

- 105 -
EASYTRIEVE PLUS

Indexing
Indexing is a technique that you use to maintain control over the relative position of a
pointer in an array

Syntax

field-name start-location length type +


[decimal-position] OCCURS nn INDEX index-name

OCCURS nn

OCCURS is the number of elements (occurrences of field-name) in the array

INDEX index-name

INDEX index-name is the field containing the displacement for the pointer in an
array. The value of index-name controls access to the desired data occurrence. This
field is automatically defined and set to zero. You should reset the index to zero
before processing each subsequent record.

Arrays
Arrays can be processed sequentially or randomly

Sequential

index-name = index-name + element length

Random

index-name = (occurrence - 1) * element length

- 106 -
EASYTRIEVE PLUS

Examples

If a file contains an array, then you use this method of accessing the information in
the array.

Index value
|O |3 |6 |9 |12
_|_|_|J|A|N|F|E|B|M|A|R|A|P|R|M|A|Y|_|_|_
| | | | |
101 104 107 110 113
Position

The field definition for the array would be :


MO-NAME 101 3 A OCCURS 12 INDEX MO-INDEX

MO-NAME is the data to be accessed. The first element in the array starts in location
101 and has a length of 3 bytes.

To process the MO-NAME sequentially use :

MO-INDEX = MO-INDEX + 3

To process the MO-NAME randomly and access the 4th MO-NAME use :

MO-INDEX = ( 4 - 1 ) * 3
Or
MO-INDEX = 9

An array can be created in working storage and accessed in this manner.

FILE PERSNL FB(150 1800)


REGION 1 1 N
DATE-OF-HIRE 103 6 N HEADING ('DATE OF' 'HIRE') MASK '99/99/99
MONTH-OF-HIRE DATE-OF-HIRE 2 N HEADING ('NUMERIC' 'MONT')
DAY-OF-HIRE DATE-OF-HIRE + 2 2 N
YEAR-OF-HIRE DATE-OF-HIRE + 4 2 N
*
NAME-LIST W 36 A VALUE 'JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'
*
MO-NAME NAME-LIST 3 A OCCURS 12 INDEX MO-INDEX +
HEADING ('ALPHA' 'NAME')
*
JOB INPUT PERSNL NAME ARRAY-SEARCH
IF REGION = 5
MO-INDEX = (MONTH-OF-HIRE - 1) * 3
PRINT NEWREPT
END-IF
*
REPORT NEWREPT LINESIZE 80
LINE MO-INDEX MONTH-OF-HIRE MO-NAME

- 107 -
EASYTRIEVE PLUS

OUTPUT

NUMERIC ALPHA
MO-INDEX MONTH NAME

18 07 JUL
9 04 APR
15 06 JUN
6 03 MAR
12 05 MAY
30 11 NOV
33 12 DEC
18 07 JUL
01 JAN
27 10 OCT
3 02 FEB
24 09 SEP
21 08 AUG
30 11 NOV
21 08 AUG
27 10 OCT
01 JAN
33 12 DEC

- 108 -
EASYTRIEVE PLUS

Examples

Refer to the following input in examining the examples presented.

REGION A … REGION B

R SLS YTD NO OF SLS YTD NO OF … R SLS YTD NO OF …


C E MAN SALES $ CUSTS MAN SALES $ CUSTS … E MAN SALES $ CUSTS …
O G # # … G #

1 SALES 1 SALES 2 SALES 1

4 REGIONS
6 SALESMEN PER REGION

Report 1 - One-dimension Array Processing

1/19/84 YTD SALES TOTALS PAGE 1


ONLY REGION A

CO YTD-TOTAL-$

1 43,691.72
2 37,812.40
(Assumes 4 regions A-D and 6 salesmen per region. )

- 109 -
EASYTRIEVE PLUS

Code for Report 1

FILE SLSMAST
*
CO 1 1 A
REGION 2 1 A
SLS-INFO 3 10 A OCCURS 6 INDEX SLS-INDEX
SALESMAN# SLS-INFO 2 A
YTD-SALES SLS-INFO + 2 5 P 2
NO-OF-CUSTS SLS-INFO + 7 3 N O
*
CTR W 2 P 0
YTD-TOTAL-$ W 6 P 2
JOB INPUT SLSMAST NAME INDEX-1
MOVE ZEROES TO CTR, YTD-TOTAL-$, SLS-INDEX
DO WHILE CTR LT 6
YTD-TOTAL-$ = YTD-TOTAL-$ + YTD-SALES
CTR = CTR + 1
SLS-INDEX = SLS-INDEX + 10
END-DO
PRINT RPT1
REPORT RPT1
TITLE 1 'YTD SALES TOTALS'
TITLE 2 'ONLY REGION A'
LINE 1 CO YTD-TOTAL-$

- 110 -
EASYTRIEVE PLUS

Subscripts
Subscripts are an alternate method available to select an individual element from an
array. The use of subscripts removes from you the requirement of computing the
index value, and places it on EASYTRIEVE PLUS.

Example With Subscripts

FILE PERSNL FB(150 1800)


REGION 1 1 N
DATE-OF-HIRE 103 6 N HEADING ('DATE OF' 'HIRE') MASK '99/99/99
MONTH-OF-HIRE DATE-OF-HIRE 2 N HEADING ('NUMERIC' 'MONT')
DAY-OF-HIRE DATE-OF-HIRE + 2 2 N
YEAR-OF-HIRE DATE-OF-HIRE + 4 2 N
*
NAME-LIST W 36 A VALUE 'JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'
*
MO-NAME NAME-LIST 3 A OCCURS 12 +
HEADING ('ALPHA' 'NAME')
*
JOB INPUT PERSNL NAME ARRAY-SEARCH
IF REGION = 5
PRINT NEWREPT
END-IF
*
REPORT NEWREPT LINESIZE 80
LINE MONTH-OF-HIRE MO-NAME (MONTH-OF-HIRE)

Output

NUMERIC ALPHA
MONTH NAME

07 JUL
04 APR
06 JUN
03 MAR
05 MAY
/-------------/-----------/-------------/
11 NOV
08 AUG
10 OCT
01 JAN
12 DEC

- 111 -
EASYTRIEVE PLUS

Report 2 - Two-dimension Processing

1/19/84 YTD SALES TOTALS PAGE 1


BY REGION

CO REGION YTD-TOTAL-$

1 A 43691.72
B 47668.79
C 45571.10
D 30618.75
1 167550.36

2 A 37812.40
B 41197.83
C 35617.14
D 29818.47
2 144445.84
….. …..

(Assumes 4 regions (A-D); 6 salesmen per region.)

- 112 -
EASYTRIEVE PLUS

Code for Report 2

FILE SLSMAST
CO 1 1 A
REG-GROUP 2 61 A OCCURS 4
REGION REG-GROUP 1 A
SLS-INFO REG-GROUP + 1 10 A OCCURS 6
SALESMAN# SLS-INFO 2 N
YTD-SALES SLS-INFO +2 5 P 2
NO-OF-CUSTS SLS-INFO +7 3 N O
YTD-TOTAL-$ W 6 P 2
REG-SUB W 3 P
SLS-SUB W 3 P
JOB INPUT SLSMAST NAME INDEX-2
REG-SUB = 1
DO WHILE REG-SUB LE 4
MOVE ZEROES TO YTD-TOTAL-$
SLS-SUB = 1
DO WHILE SLS-SUB LE 6
YTD-TOTAL-$ = YTD-TOTAL-$ + YTD-SALES(REG-SUB SLS-SUB)
SLS-SUB = SLS-SUB + 1
END-DO
PRINT SALES-BY-REGION
REG-SUB = REG-SUB + 1
END-DO
REPORT SALES-BY-REGION
CONTROL CO
TITLE 1 'YTD SALES TOTALS'
TITLE 2 'BY REGION'
LINE CO REGION YTD-TOTAL-$

- 113 -
EASYTRIEVE PLUS

EXCERCISES
SORT/PUT/READ Exercise

Code an activity to create a sorted file of only REGION 4, non-zero GROSS-PAY


records, in descending GROSS-PAY order. Taking the sorted records, obtain a job
description for the employee from a VSAM file using an employee number as a key.
Select records for a report only if a job description is found on the VSAM file. For the
missing job descriptions, output a work file containing the employee's NAME,
GROSS-PAY, and NUMBER.

FILE PAYFILE . . .
. . .
REGION 1 1 N
EMP-NO 9 5 N
EMP-NAME 17 20 A
GROSS-PAY 94 4 P 2
. . .
FILE EMPINFO VS
EMP-KEY 2 5 N
DESCRIPTION 30 10 A

Index Exercises

1. Code the same program as the previous SORT/PUT/READ exercise but use a table
look-up instead of a READ
2. Code the library and logic to access all 12 occurrences of the following example,
accumulating the amounts until one amount has zero or until all 12 have been
accessed. At that point, select the information for a report.

- 114 -
EASYTRIEVE PLUS

MACROS
OVERVIEW
In this section you will learn about macros; what they are and how they are used in an
EASYTRIEVE PLUS program. You will also see examples of macros. These
examples have been provided to simulate your thinking on ways you can use macros.
By using macros you can simplify end user programming and you own regular
routines.

Objective
Upon completion of this section you will be able to create, test, and invoke macros to
simplify routine tasks and meet end user needs.

GENERAL INFORMATION
Macros can be used for any or all places of an EASYTRIEVE PLUS program. You
can use macros to provide shortcuts for your end users in many ways. You can also
use macros to simplify some of your programming routines.

Macro Applications
The following list is provided to give you ideas on how to use macros :

 Data Dictionary - You can store file and field definitions for frequently requested
files in a macro. This eliminates the need to code field definitions every time a file
is used in an EASYTRIEVE PLUS program.
 Commonly Used Routines - If you find that you have certain routines that are
used regularly, they can be made into a macro and recoding of these routines can
be avoided.
 Report Templating - Regularly generated reports can be stored as a macro and
recalled as needed.
 Simulate Query - In this application an entire EASYTRIEVE PLUS program
would be stored in a macro and the end user would code only a single line to
produce a report
 Logic Templating - Frequently occurring logic patterns may be stored as macros
for use in a variety of programs
 Simple Presentation of Data - Data description and record presentation from any
file structure can be controlled. When this information is placed in a macro the
complexity of data structures is hidden from the user.
 Control Access to Data - You can limit the fields available for user processing by
coding only the fields you want them to have accessible in the macros in the data
dictionary.

- 115 -
EASYTRIEVE PLUS

CREATING MACROS
There are two parts to every macro; a prototype statement and the macro code.

Prototype Statement

A prototype statement identifies the code which follows as a macro and sets up
substitution parameters if they are to be used. You code the prototype statement first
in a macro.

MACRO [n] [positiona] [keyword]

 You use MACRO to identify the start of a macro


 Two types of parameter substitution are available - positional and keyword

Positional - Ordered

– No default substitution
– Must be supplied when invoking a macro or will be null (treated as
nonexistent)

Keyword - Unordered

– Must supply default values


– Useful when default values are needed or for infrequently used parameters
– May be supplied or allowed to default when invoking a macro

Note : Quotation marks can be used to delimit parameter values, but the quotes will
not be passed.

Macro Code

The second part of a macro consists of the EASYTRIEVE PLUS statements you wish
to execute as the macro.

Example

A macro called PAYLIB exists in your library containing :

MACRO
FILE PAYROLL
NAME 1 20 A
DEPT 21 2 A
GROSS 23 4 P 2
NET 27 4 P 2
DEDUCTIONS W 4 P 2

- 116 -
EASYTRIEVE PLUS

Macro Invocation

Once you have created and stored a macro you can use it in any program

Syntax

%macro-name macro-parameters

 The % (percent sign) directs EASYTRIEVE PLUS to retrieve a macro with the
designated name
 Macro-parameters are the parameters you want to be substituted in the macro
(positional or keyword)

How to Use in a Program

The PAYLIB macro on the previous page is used in a program in this manner.

%PAYLIB
JOB INPUT PAYROLL NAME DEDUCRPT
IF DEPT = 911 914 THRU 920
DEDUCTIONS = GROSS - NET
PRINT MACRO-EXAMPLE
REPORT MACRO-EXAMPLE
SEQUENCE DEPT NAME
TITLE 1 'EXAMPLE OF USING MACROS'
TITLE 2 'IN A PROGRAM'
LINE 1 DEPT NAME GROSS NET DEDUCTIONS

Parameter Substitution Examples

These examples show how to use the substitution parameters on the prototype
statement.

MACRO
(no substitution parameters)

MACRO POS1 POS2


(only positional parameters)

MACRO 0 KEY1 VALUE1 KEY2 VALUE2


(only keyword parameters)

MACRO 2 POS1 POS2 KEY1 VALUE1


(keyword and positional combined)

- 117 -
EASYTRIEVE PLUS

Macro Example with Parameter Substitution

A macro, called CNTLRPT, exists in your library, containing:

MACRO 2 CNTL-FLD VALUE RANGE ' ' HIGH-VALUE ' '


IF &CNTL-FLD = &VALUE &HIGH-VALUE
PRINT RPT1
END-IF
REPORT RPT1
SEQUENCE &CNTL-FLD NAME
CONTROL &CNTL-FLD NEWPAGE
TITLE 1 'CONTROL REPORT OF NAME WITHIN &CNTL-FLD' +
&CNTL-FLD
LINE 1 &CNTL-FLD NAME GROSS-PAY NET-PAY

The ampersand (&) tells EASYTRIEVE PLUS where to substitute parameter values
in the macro.

To use CNTLRPT, code:

%PAYLIB
JOB INPUT PAYFILE NAME REGPROG
%CNTLRPT REGION 516

or

%PAYLIB
JOB INPUT PAYFILE NAME REGPROG
%CNTLRPT REGION 516 RANGE THRU HIGH-VALUE 520

or

%PAYLIB
JOB INPUT PAYFILE NAME REGPROG
%CNTLRPT REGION '516 520 525 580'

- 118 -
EASYTRIEVE PLUS

Testing Macros Within a Program


You can use this method of testing a macro you have created before storing it in your
library. When this method is used, the macro is coded at the beginning of the
program.

Syntax

MSTART macro-name
MACRO [positional] [keyword]

* * Code to be used as macro * *

MEND

MSTART

You use MSTART to indicate the start of a macro to be tested in the program.

MEND

You use MEND to indicate the end of the macro you are testing.

Example

MSTART PAYLIB
MACRO O VS ' '
FILE PAYIN &VS
EMP# 9 5 N
EMP-NAME 17 20 A
SSN 4 5 P
NET-PAY 90 4 P 2
GROSS-PAY 94 4 P 2
MEND
%PAYLIB
JOB INPUT PAYIN
….
REPORT
….

- 119 -
EASYTRIEVE PLUS

MACRO EXAMPLES

The following examples illustrate some of the uses of macros.

Commonly Used Routines

This macro provides for using SYSDATE for comparison with any other date in a
file.

Example

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

The DEFINE Statement allows you to define data fields outside of the library.

- 120 -
EASYTRIEVE PLUS

Data Dictionary
This example illustrates a common data dictionary entry. It contains all the field
definitions for the test data base PERSNL.

Example

MACRO
*
* EASYTRIEVE PLUS TEST FILE FIELD DEFINITIONS
*
REGION 1 1 N
BRANCH 2 2 N
SSN 4 5 P MASK '999-99-9999' +
HEADING +
('SOCIAL' 'SECURITY' 'NUMBER')
EMP# 9 5 N HEADING ('EMPLOYEE' 'NUMBER')
NAME 17 16 A HEADING 'EMPLOYEE NAME'
NAME-LAST NAME 8 A HEADING ('LAST' 'NAME')
NAME-FIRST NAME +8 8 A HEADING ('FIRST' 'NAME')
ADDRESS 37 39 A
ADDR-STREET 37 20 A HEADING 'STREET'
ADDR-CITY 57 12 A HEADING 'CITY'
ADDR-STATE 69 2 A HEADING 'STATE'
ADDR-ZIP 71 5 N HEADING ('ZIP' 'CODE')
PAY-NET 90 4 P 2 HEADING ('NET' ' ' 'PAY')
PAY-GROSS 94 4 P 2 HEADING ('GROSS' 'PAY')
DEPT 98 3 N
DATE-OF-BIRTH 103 6 N MASK (Y 'Z9/99/99') +
HEADING ('DATE' 'OF' 'BIRTH')
TELEPHONE 117 10 N MASK '(999) 999-9999' +
HEADING ('TELEPHONE' 'NUMBER')
SEX 127 1 N HEADING ('SEX' 'CODE)
* 1 - FEMALE
* 2 - MALE
MARITAL-STAT 128 1 A HEADING ('MARITAL' 'STATUS')
* M - MARRIED
* S - SINGLE
JOB-CATEGORY 132 2 N HEADING ('JOB' 'CATEGORY')
SALARY-CODE 134 2 N HEADING ('SALARY' 'CODE')
DATE-OF-HIRE 136 6 N MASK Y +
HEADING ('DATE' 'OF' 'HIRE')

- 121 -
EASYTRIEVE PLUS

Logic Templating
The example on the next page shows complex logic that most end users would not
want to code but would find very useful during budget preparation time - calculating
raises. Note that this example illustrates how to test a macro using MSTART and
MEND around the macro and an EASYTRIEVE PLUS program after MEND

The advantage to this macro application is that the logic is fixed but the user
maintains full control over the final report.

- 122 -
EASYTRIEVE PLUS

Example

MSTART RAISSEL
MACRO 1 RAISE-PCT SELECT-YEARS-GT '1' REPORT 'UPD-RPT'
DEFINE DATE-OF-HIRE W 6 N
DEFINE HIRE-MM DATE-OF-HIRE 2 N
DEFINE HIRE-DD DATE OF-HIRE +2 2 N
DEFINE HIRE-YY DATE-OF-HIRE +4 2 N
DEFINE WEEKLY-PAY W 4 P 2
DEFINE NEW-SALARY W 4 P 2
DEFINE RAISE W P 5 VALUE &RAISE-PCT *MUST BE LT 1
DEFINE CURR-DATE W 6 N
DEFINE CURR-MM CURR-DATE 2 N
DEFINE CURR-DD CURR-DATE + 2 2 N
DEFINE CURR-YY CURR-DATE + 4 2 N
DEFINE SERVICE W 2 N *YEARS OF SERVICE
JOB NAME SELECT-RAISE-BY-YEARS-OF-SERVICE
%GETDATE CURR-DATE
PERFORM SERVICE-CALC
IF SERVICE LT &SELECT-YEARS-GT
GOTO JOB
END-IF
NEW-SALARY = PAY-GROSS *RAISE + PAY-GROSS + 0.005
PRINT &REPORT
*
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
MEND
%PERSNL
%RAISESEL 0.05 SELECT-YEARS-GT 20
REPORT UPD-RPT LINESIZE 80
LINE 1 NAME DATE-OF-HIRE PAY-GROSS NEW-SALARY

- 123 -
EASYTRIEVE PLUS

CODING TECHNIQUES
OVERVIEW
This section covers the following topics :

1. System-Defined Fields
2. Environment
3. Bit Testing.

Under system-defined fields you will learn about eight fields that EASYTRIEVE
PLUS supplies automatically. These fields fall into three categories:

 General Purpose Fields


 File Processing Fields
 Report Processing Fields

In the Environment section you will learn about the PARM statement and how you
can use it to alter the defaults of EASYTRIEVE PLUS

Finally, you will learn how to do bit testing on a field

Objectives
After completing this section you will;

1. Know the purpose and use of the following system-defined fields;

SYSDATE
SYSTIME
RETURN-CODE
TALLY
LEVEL
RECORD-COUNT
RECORD-LENGTH
FILE-STATUS
2. Understand how the PARM statement with the DEBUG parameter is used to
modify the ENVIRONMENT section of an EASYTRIEVE PLUS program.
3. See how you can perform bit testing with EASYTRIEVE PLUS.

- 124 -
EASYTRIEVE PLUS

SYSTEM-DEFINED FIELDS
EASYTRIEVE PLUS automatically provides three categories of system defined
fields.

1. General Purpose Fields


2. File Processing Fields
3. Report Processing Fields

General Purpose Fields


SYSDATE

SYSDATE is a read only eight-byte alphanumeric field which contains the system
date at the start of EASYTRIEVE PLUS execution. The DATE option of the Options
Table determines the format of the date. A / (slash) separates the month, day and year
components of the date (i.e. MM/DD/YY).

SYSTIME

SYSTIME is a read only eight-byte alphanumeric field which contains the system
time at the start of EASYTRIEVE PLUS execution. A. (slash) separates the data into
hours, minutes, and seconds (i.e. HH/MM/SS)

RETURN-CODE

RETURN-CODE is a four-byte binary field whose contents are returned to the


operating system in register 15 when EASYTRIEVE PLUS terminates. RETURN-
CODE is initialized to zero, but you can set it to any value. RETURN-CODE applies
only to OS systems.

- 125 -
EASYTRIEVE PLUS

File Processing Fields


When you use these fields you will find that each file has its own unique processing
fields.

RECORD-LENGTH

RECORD-LENGTH is a two-byte binary field with zero decimal places used for all
file types to determine or establish the length of the current data record. For variable-
length records, this field contains only the length of the record's data.

RECORD-COUNT

RECORD-COUNT is a read-only four-byte binary field with zero decimal places


which contains the number of logical I/O operations performed on a file.

FILE-STATUS

FILE-STATUS is a read-only field which contains the results of the most recent I/O
operation on a file.

Report Processing Fields


TALLY

TALLY contains the number of detail records that comprise a control break. You can
use TALLY on a LINE statement or you can use it in calculations within report
procedures. TALLY is commonly used to determine averages for a control level.

TALLY is a ten-byte packed decimal field with zero decimal places. This definition is
used for calculations contained within report procedures. The TALLYSIZE parameter
of the REPORT statement defines the number of digits which are printed for TALLY.
A TALLY accumulator is created for each control beak level.

LEVEL

LEVEL is a system-defined field provided for determining which control break is


currently active. 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 based on the number of field
names on the CONTROL statement of the associated report. LEVEL will contain the
logical position number of the controlling field name. This value also applies to
FINAL whether it is coded or not.

- 126 -
EASYTRIEVE PLUS

Example

LEVEL = 1 on TERRITORY breaks


LEVEL = 2 on REGION breaks
LEVEL = 3 on AREA breaks
LEVEL = 4 on FINAL break

CONTROL FINAL NOPRINT AREA REGION TERRITORY


4 3 2 1

CONTROL AREA REGION TERRITORY


4 3 2 1

- 127 -
EASYTRIEVE PLUS

ENVIRONMENT
The Environment section of an EASYTRIEVE PLUS program has only one statement
associated with it. It is the PARM statement. You use the PARM statement to alter
system defaults for the duration of the execution of your EASYTRIEVE PLUS
program.

If you use the PARM statement you must code it as the first statement in the program
unless MACROs are being tested.

Example

For syntax checking only:

PARM SYNTAX

For increasing VFM's space in memory:

PARM VFM 100

For omitting file statistics and parm values:

PARM LIST (NOFILE NOPARM)

Combination

PARM VFM 100 LIST (NOFILE NOPARM)

For link editing:

PARM LINK (TESTPGM)

- 128 -
EASYTRIEVE PLUS

Debugging
Use the DEBUG parameter of the PARM statement to generate output helpful in
analyzing programming errors.

DEBUG Subparameters

 DMAP - data definitions for all files and working storage


 FLDCHK - validates all file/field references
 FLOW - traces statement logic
 FLOWSIZ - identifies the number of statements to be kept in a trace table
 STATE - gives statement number of the current statement executed wen abnormal
termination occurs
 XREF - produces a cross-reference of field-names, file-names, procedure-names,
and statement-labels where used.

Examples

PARM DEBUG (DMAP FLDCHK NOXREF)


PARM DEBUG (DMAP FLOW FLOWSIZE (150) )
PARM VFM 200 LIST NOFILE DEBUG (FLDCHK STATE)

- 129 -
EASYTRIEVE PLUS

BIT TESTING
You can test individual bits in a field for an or off condition

Syntax

If field-name-1 [NOT] ON field-name-2


OFF literal

Field-name-2 or Literal

Field-name-2 or literal is used to determine the bit pattern which will be compared to
the pattern in field-name-1

 The length of field-name-1 must be the same length as field-name-2


 A bit with a value of 1 is considered to be on
 A bit with the value of 0 is considered to be off

Examples

IF CODE ON X'FFOO'

The bit pattern value of X'FF00' is compared to the pattern in CODE. If all the bits
that are on in X'FF00' are also on in CODE, the condition is true.

IF FLD-HOLD OFF FLD-WORK

The bit pattern created by FLD-WORK is compared to the pattern in FLD-HOLD. If


all the bits that are on in FLD-WORK are off in FLD-HOLD, the condition is true.

- 130 -
EASYTRIEVE PLUS

SUMMARY
This concludes Section 6 of the Student Guide. You should now know how to use the
following system-defined fields in your EASYTRIEVE PLUS programs.

SYSDATE
SYSTIME
RETURN-CODE
TALLY
LEVEL
RECORD-COUNT
RECORD-LENGTH
FILE-STATUS

You should understand how to code the PARM statement to modify the Environment
section of an EASYTRIEVE PLUS program.

Finally, you have been introduced to bit testing with EASYTRIEVE PLUS

- 131 -

You might also like