Professional Documents
Culture Documents
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
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.
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.
Prototype applications
Capabilities
EASYTRIEVE PLUS provides :
-6-
EASYTRIEVE PLUS
User-defined reports
An unlimited number of input files.
Array processing
-7-
EASYTRIEVE PLUS
PROGRAM STRUCTURE
There are three basic sections to every EASYTRIEVE PLUS program. They are:
A Library Section
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
-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.
Primer 1 Output
- 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.
Primer 2 Output
- 11 -
EASYTRIEVE PLUS
Example - Primer 3
This program adds some elementary logic to assure that employee deductions are
computed only when DEPARTMENT = 911.
Primer 3 Output
- 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.
Primer 4 Output
- 13 -
EASYTRIEVE PLUS
Example - Primer 5
This program adds a SEQUENCE statement to the REPORT activity which sorts
employees alphabetically by NAME under DEPARTMENT.
Primer 5 Output
- 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.
Primer 6 Output
- 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)
Primer 7 Output
- 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.
Syntax
- 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.
Decimal-positions
- 18 -
EASYTRIEVE PLUS
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
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,
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
- 19 -
EASYTRIEVE PLUS
Syntax
Examples
- 20 -
EASYTRIEVE PLUS
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.
- 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.
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
- 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
[ INPUT ]
The optional INPUT parameter identifies the automatic input to the activity.
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
When an IF statement is present, each record read from the input file is processed
against the condition.
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
- 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.
Example
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
Examples
The IF statement is true when all three conditions are true for that record.
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.
Syntax
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
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.
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
Then :
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
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.
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
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
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.
EVERY - specifies that only every nth line is printed in the report.
- 33 -
EASYTRIEVE PLUS
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.
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.
The sequence order is ascending. Coding D after a field-name reverses the order
for that field only.
Syntax
- 34 -
EASYTRIEVE PLUS
Examples
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.
Syntax
Final totals are automatically provided. You can alter the default by coding
FINAL NOPRINT.
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
- 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 SUM any quantitative field from any active file or any W field
Syntax
SUM quant-field-1 . . . quant-field-n
Examples
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
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
- 36 -
EASYTRIEVE PLUS
prints
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.
Syntax
Example 1
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.
Syntax
±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
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.
- 38 -
EASYTRIEVE PLUS
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.
- 40 -
EASYTRIEVE PLUS
- 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.
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
- 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
STOP ends the current activity and goes on to the next activity if additional
activities are coded
Example
- 43 -
EASYTRIEVE PLUS
DISPLAY Statement
A DISPLAY statement sends data to a specified output file or output device.
DISPLAY is commonly used:
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
Format II
Example of Format II
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
DTLCTL determines when control field values are printed on 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
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
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
CONTD…..
- 49 -
EASYTRIEVE PLUS
- 50 -
EASYTRIEVE PLUS
- 51 -
EASYTRIEVE PLUS
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
- 53 -
EASYTRIEVE PLUS
- 54 -
EASYTRIEVE PLUS
- 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 example on the next page demonstrates the use of SUMFILE in an
EASYTRIEVE PLUS program.
SUMFILE Example 1
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 :
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
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 :
- 58 -
EASYTRIEVE PLUS
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
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
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
- 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
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
- 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 :
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
- 64 -
EASYTRIEVE PLUS
AFTER-BREAK. PROC
The AFTER-BREAK. PROC allows for specified annotation after control break lines are
printed.
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.
- 66 -
EASYTRIEVE PLUS
SOCIAL
EMPLOYEE EMPLOYEE SECURITY GROSS
DEPT NAME NUMBER NUMBER PAY
- 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.
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
FULLTRK
- 68 -
EASYTRIEVE PLUS
FILE dlblname
Tlblname +
[SYSxxx] +
file IS
type VS ( [ES] [F] [PASSWORD] 'literal'] )
CARD
F lrecl
V maxlrecl + 4
record U blksize
format FB (lrecl) blksize )
FULLTRK
VB (maxlrecl + 4 maxblksize + 4 )
FULLTRK
FULLTRK
- 69 -
EASYTRIEVE PLUS
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
F (lrecl)
VIRTUAL
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
NR
- 71 -
EASYTRIEVE PLUS
USING
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
[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.
- 72 -
EASYTRIEVE PLUS
Syntax
Format I
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
Format 2
SPACE
SPACES
MOVE ZERO TO fiels-name-1 field-name-n
ZEROS
ZEROES
Example
- 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
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
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
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
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
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
Syntax
DO WHILE conditional-expression
** Logic **
END-DO
Example
** Logic **
END-DO
IF …
Nesting Example
You can nest DO WHILE statements. (The inner logic loop must be completely
within the outer logic loop)
** 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
NAME sort-name
File-name-1
File-name-2
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
Example
- 79 -
EASYTRIEVE PLUS
SORT Procedure
You use SORT procedure to select only certain records for sorting and/or to modify
the contents of records before a sort
Syntax
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
- 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
(EOF) - Test for end-of-file (EOF) when using the GET command
- 82 -
EASYTRIEVE PLUS
Example
PUT Statement
The PUT statement outputs a file sequentially
Syntax
Example 1
- 83 -
EASYTRIEVE PLUS
Example 2
- 84 -
EASYTRIEVE PLUS
VSAM
VSAM File Statement
You use the following parameters when working with VSAM files
Syntax
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 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
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
Example
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
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
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
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
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
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
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
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 :
- 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 :
Note that the file must be in ascending order by its key value(s)
Syntax
The INPUT parameter designates files and their keys for synchronized file input.
- 93 -
EASYTRIEVE PLUS
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 :
Example
- 94 -
EASYTRIEVE PLUS
Record Presentation
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.
MATCHED
MATCHED tests to see if keys on all current records are matched
Syntax
Examples
IF MATCHED
- 95 -
EASYTRIEVE PLUS
DUPLICATE
FIRST-DUP
LAST-DUP
Syntax
- 96 -
EASYTRIEVE PLUS
ACCT# ID ACCT# ID
- 97 -
EASYTRIEVE PLUS
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.
Code
The following coding produces two new files from MASTER and STORE1.
- 98 -
EASYTRIEVE PLUS
MERGED contains records from both input files for each transaction
INVALID contains a record for each invalid transaction from STORE1 file
MERGED INVALID
- 99 -
EASYTRIEVE PLUS
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
- 101 -
EASYTRIEVE PLUS
TABLES/INDEXING/ARRAYS
Tables
A table is a collection of uniform data records in a form suitable for quick reference.
Each table entry has :
The user's objective is to obtain the description from a table of values based on the
search argument.
ARG DESC
____ _____
1 ALABAMA
2 ALASKA
3 ARIZONA
…
47 WASHINGTON
48 WEST VIRGINIA
49 WISCONSIN
50 WYOMING
- 102 -
EASYTRIEVE PLUS
Syntax
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
- 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 :
Syntax
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
OCCURS nn
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
Random
- 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
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.
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
- 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
REGION A … REGION B
…
4 REGIONS
6 SALESMEN PER REGION
CO YTD-TOTAL-$
1 43,691.72
2 37,812.40
(Assumes 4 regions A-D and 6 salesmen per region. )
- 109 -
EASYTRIEVE PLUS
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.
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
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
….. …..
- 112 -
EASYTRIEVE PLUS
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
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.
Positional - Ordered
– No default substitution
– Must be supplied when invoking a macro or will be null (treated as
nonexistent)
Keyword - Unordered
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
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)
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
These examples show how to use the substitution parameters on the prototype
statement.
MACRO
(no substitution parameters)
- 117 -
EASYTRIEVE PLUS
The ampersand (&) tells EASYTRIEVE PLUS where to substitute parameter values
in the macro.
%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
Syntax
MSTART macro-name
MACRO [positional] [keyword]
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
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:
In the Environment section you will learn about the PARM statement and how you
can use it to alter the defaults of EASYTRIEVE PLUS
Objectives
After completing this section you will;
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.
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
- 125 -
EASYTRIEVE PLUS
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
FILE-STATUS
FILE-STATUS is a read-only field which contains the results of the most recent I/O
operation on a file.
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
- 126 -
EASYTRIEVE PLUS
Example
- 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
PARM SYNTAX
Combination
- 128 -
EASYTRIEVE PLUS
Debugging
Use the DEBUG parameter of the PARM statement to generate output helpful in
analyzing programming errors.
DEBUG Subparameters
Examples
- 129 -
EASYTRIEVE PLUS
BIT TESTING
You can test individual bits in a field for an or off condition
Syntax
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
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.
- 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 -