Professional Documents
Culture Documents
Introduction
IN OTHER TERMS
“ EASYTRIEVE PLUS is user-friendly, allowing you to
retrieve and manage data using simple, English-like
statements. It can both process data and create
formatted reports without resort to complicated
programming languages.”
Capabilities
Operations
• Environment Definition
• Library Section
• Activity Definition
Environment Section
• Optional
• If used, must be first section and includes only one statement (PARM)
• Describes data fields and usually necessary for file processing and
report generation
• JOB statement
• SORT statement
• PROC/END-PROC statements
• REPORT statements
Sample Program – A First Look
FILE INFILE VS
NAME 1 30 A
CITY 31 15 A
STATE 46 2 A
ZIP 48 5 N
JOB
PRINT RPT1
REPORT RPT1
TITLE ‘CSC FSG’
TITLE 2 ‘BASIC EZTRIEVE TRAINING’
TITLE 3 ‘SAMPLE REPORT TITLES’
LINE NAME CITY STATE ZIP
Syntax
Field Definition
Sample fieldname
FLDA
POLICY-NUMBER
POLICY-NUMBER-X
BENEFICIARY-1
BENEFICIARY1
Field Definition Contd.
• startpos is the actual position in the record where the field begins
• can use ‘*’ to specify that one field immediately follows another
Sample <startpos>
FIELD-A 1 10 A
FIELD-B 11 6 N
FIELD-C * 2 A
FIELD-D 45 4 P 2
Field Definition Contd.
Sample length
FIELD-A 1 10 A
FIELD-B 11 6 N
FIELD-C * 2 A
FIELD-D 45 4 P 2
Field Definition Contd.
• type determines the format of the field and what kind of data it can
hold
Sample type
FIELD-A 1 10 A
FIELD-B 11 6 N
FIELD-C * 2 A
FIELD-D 45 4 P 2
Field Definition Contd.
Field Types
• ‘A’ - Alphanumeric
• ‘N’ - Numeric, Zoned Decimal
– (x’F1F2F3F4F5’)
• ‘P’ - Numeric, Packed Decimal
– (x’12345F’)
• ‘U’ - Numeric, Unsigned Packed Decimal
– (x’012345’)
• ‘B’ - Numeric, Signed Binary
– (x’3039’)
Field Definition Contd.
Sample decimals
FIELD-A 1 10 A
FIELD-B 11 6 N 0
FIELD-C * 2 A
FIELD-D 45 4 P 2
Field Definition Contd.
Decimal Positions
OR.....
FILE INFILE
NAME 1 30 A
CITY 31 15 A
STATE 46 2 A
ZIP 48 5 N
Working Storage Fields
• Used for fields not on a file record (i.e. calculated fields, indicators,
etc.)
• Usually coded after all file and record definitions and before the JOB
statement
Example:
GROSS-PAY W 6 P 2
INDICATOR1 W 1 A
Redefining Fields
EXAMPLE 1:
FULL-NAME 1 19 A
LAST-NAME 1 10 A
FIRST-NAME 11 8 A
MIDDLE-INIT 19 1 A
Redefining Fields Contd..
EXAMPLE 1:
FULL-NAME W 19 A
LAST-NAME FULL-NAME 10 A
FIRST-NAME FULL-NAME +10 8 A
MIDDLE-INIT FULL-NAME +18 1 A
VALUE parameter
VALUE parameter-cont’d
EXAMPLE:
NAME W 20 A VALUE ‘SMITH’
AMOUNT W 8 N VALUE 1000
Assigning Values to Fields
ASSIGNMENTS
EXAMPLES
FIELD-A = FIELD-C
FIELD-A = ‘TRUCK’
WS-AMT = 123.45
NET-AMT = GROSS-AMT - PENALTIES
Assigning Values to Fields
• Alphabetic fields are left justified and padded with spaces, if necessary
• Numeric fields are decimal aligned and padded with zeroes on either
side of the decimal as appropriate
• The value ‘EQ’ can be substituted for the equal sign (‘=‘)
Assigning Values to Fields
MOVE Statement
Searching in TABLES.
Decision and Branching
Logic
Activity Definition
• Simple programs which read a file and print a report won’t have much
in the activity section. In fact, there could only be ONE statement
required!
DECISION and BRANCHING LOGIC
IF / END-IF
• Controls the execution of associated statements which occur between
the IF and the END-IF statements
• END-IF is required for each IF
IF conditional-expression
statement(s)
END-IF
DECISION and BRANCHING LOGIC
IF / ELSE / END-IF
• Allows for the different processing when the conditional statement is
FALSE
IF conditional-expression
statement(s)
ELSE
statement(s)
END-IF
DECISION and BRANCHING LOGIC
More on the IF
• IF statements can be nested
• Break up of the IF statement with “AND” “OR” with “EQ” “NE” for
multiple value checking.
DECISION and BRANCHING LOGIC
IF condition1
IF condition2
statement(s)
ELSE
statement(s)
END-IF
END-IF
DECISION and BRANCHING LOGIC
DO WHILE / END-DO
DO WHILE conditional-expression
statement(s)
END-DO
DECISION and BRANCHING LOGIC
Conditional Expressions
IF FIELD-A = FIELD-B
IF PAY-TYPE = ‘HOURLY’
IF HOURS-WORKED > 40
Operator Values
Equal = EQ
Not Equal ^= NE NQ
Less Than < LT LS
Less Than or Equal <= LE LQ ^<
Greater Than > GT GR
Greater Than or Equal >= GE GQ ^<
IF HOURS-WORKED = 1 THRU 40
IF HOURS-WORKED NUMERIC
• The field is tested for digits 0 through 9 in the correct format for the
field’s defined type (i.e. alphanumeric, numeric, packed, etc.)
• In the case of data types N and P, the low-order position is tested for
a valid sign
DECISION and BRANCHING LOGIC
IF HOURS-WORKED ZERO
• Field is tested for a zero character in the correct format for the field’s
definition (same as NUMERIC check)
DECISION and BRANCHING LOGIC
IF FIRST-NAME ALPHABETIC
• Each byte of the field is tested for the letters A through Z or a space.
DECISION and BRANCHING LOGIC
IF FIRST-NAME SPACES
FILE <filename>
• filename is 1 - 8 characters
• must begin with alphabetic character (A - Z)
• other positions can be alphabetic (A-Z), numeric (0-9) or national (@,
#, $)
• filename matches the DD name in the JCL
File Statement Contd.
• if VSAM file, must add the VS parameter to the end of the FILE
statement
File Processing
• EASYTRIEVE can take one or many input files and create reports.
• EASYTRIEVE can take one or many input files and create one or many
output files.
• EASYTRIEVE can take one or many input files and create reports as
well as input files.
• How can EASYTRIEVE identify whether a file is INPUT or OUTPUT ?
File Processing
• Controlled Processing is not allowed for a file that has already been
defined as an automatic input file.
Reading Files
JOB statement
• JOB INPUT < file name > NAME < job name>
GET statement
• One must test for end-of-file (EOF) and code the STOP statement , else the
program will execute forever.
– STOP / STOP < execute>
PUT statement
• This statement writes data onto an output file from an input file.
READ statement
• The KEY Parameter indicates the field name to be used while searching
for a corresponding record.
File Processing
POINT statement
• Used to set a position within a VSAM file from where sequential processing
can begin.
• Data can be retrieved either via Automatic File input or with a GET
statement.
• The relational operator can specify an exact match with an ‘equal operator ’
(EQ or = ) or can be a ‘ Greater than or equal to operator ’ (GE or >=).
File Processing
WRITE statement
Printing a Report
• If input fields are reported, there is no need to move fields from the
input record to a print line
PRINT rptname
• PRINT is a keyword
FILE INFILE
NAME 1 30 A
CITY 31 15 A
STATE 46 2 A
ZIP 48 5 N
JOB
PRINT RPT1
Reporting
REPORT Activity
• The REPORT statement has many parameters, but each has default
and none are required
• Multiple reports can be printed with a single pass of the file. Need
separate REPORT statements and must specify PRINT statement for
each.
Reporting
REPORT Statement
REPORT rptname
TOP MARGIN
REPORT BODY
BOTTOM MARGIN
Reporting
Report Titles
TITLE Statement
TITLE literal1
TITLE 2 literal2
TITLE 3 literal3
– literal1 (literal2, etc.) are user defined and can be as wide as the
report (up to 132 characters)
Reporting
Detail Lines
LINE Statement
LINE field/literal
LINE 2 field/literal
LINE 3 field/literal
LINE NAME
LINE 2 CITY ‘, ‘ STATE ZIP
LINE 3 ‘ ‘
Reporting
FILE INFILE
NAME 1 30 A
CITY 31 15 A
STATE 46 2 A
ZIP 48 5 N
JOB
PRINT RPT1
REPORT RPT1
TITLE ‘CSC FSG’
TITLE 2 ‘BASIC EZTRIEVE TRAINING’
TITLE 3 ‘SAMPLE REPORT TITLES’
LINE NAME CITY STATE ZIP
Reporting
JOB
PRINT DETAIL-RPT
PRINT SUMMARY-RPT
REPORT DETAIL-RPT
TITLE ‘CSC FSG’
TITLE 2 ‘DETAIL RPT’
LINE .........
REPORT SUMMARY-RPT SUMMARY
TITLE ‘CSC FSG’
TITLE 2 ‘SUMMARY RPT’
LINE .........
Advanced Reporting
Advanced Reporting
Column Headings
Sample HEADING - I
Sample HEADING – II
REPORT <rptname>
TITLE literal1
HEADING fieldname (‘literal’)
LINE fields/literals
More on HEADINGS
• If specified on the DEFINE statement and in the REPORT area, the
definition in the REPORT area overrides the one on the DEFINE
statement.
Advanced Reporting
REPORT ......
SEQUENCE PLAN-CODE POLICY-NUM
TITLE .....
LINE .......
More on SEQUENCE
REPORT ......
SEQUENCE PLAN-CODE POLICY-NUM D
TITLE .....
LINE .......
CONTROL Statement
• Use the CONTROL statement when you want to add the values in
columns or want to perform control breaks on a field(s)
CONTROL BREAKS
• Control breaks occur whenever the value of any control field changes
or when EOF occurs
• The CONTROL statement coded by itself will produce only final totals.
Add control fields to the CONTROL statement when you want
subtotals.
Advanced Reporting
REPORT ......
SEQUENCE PLAN-CODE POLICY-NUM
CONTROL
TITLE .....
LINE .......
• The format of the report will vary slightly when using control breaks.
The control field(s) is only printed on the first detail line of the group,
not on every line
REPORT ......
SEQUENCE COMPANY PLAN-CD POLICY
CONTROL COMPANY PLAN-CD
TITLE .....
LINE .......
Counting Records
REPORT RPT1
SEQUENCE PLAN-CODE POLICY-NUM
CONTROL
TITLE .....
LINE PLAN-CODE POLICY-NUM TALLY
• This example will provide a record count at the end of the report
Macro’s
THANK YOU
HAVE FUN!!