You are on page 1of 31

EASYTRIEVE

Introduction
Easy Language Easytrieve

 Easytrieve is an easy English like language.


 Very easy to code
 Mainly used for reports generation and
matching files on the key fields.
Easy Language Easytrieve

 ENVIRONMENT SECTION (Equivalent to ID


Division & Environment Division)
 LIBRARY SECTION (Equivalent to DATA DIVISION
in COBOL)
 ACTIVITY SECTION (Equivalent to PROCEDURE
DIVISION in COBOL)
Environment Section

 This section contains information about the


program name, author etc
 This section will also contains parm
statement. Parm statement is used when
program is not directly coded in sysin and is
compiled.
 For eg.
program name: ENREGO01
PARM(ENREGO01)
LIBRARY SECTION

 All the input and output files are declared in


this section
 Syntax for file declaration:
File filename
var1 start pos length type
for eg
FILE MEMBINFO
MEMBNO 1 13 A
MEMBPH 14 7 N
Library section continues….

 You can redefine the same variable again and


again.
For e.g.
MEMBNAME 25 46 A
MEMBFIRST 25 15 A
MEMBMIDLE 40 1 A
MEMBLNAME 41 20 A
Working storage variables

 Working storage variables are defined using key


word W.
 Definition of working storage syntax
var1 W length of var Type
e.g.
HOLD-MEMB W 46 A
 Redefinition of working storage variable.
WS-BATCH W 03 A
WS-BATCH1 WS-BATCH 02 A
WS-BATCH2 WS-BATCH +2 01 A
Various data types

Maximum field lengths ( in bytes) for different


types of variables in Easytrieve are given
below :
 A Alphanumeric 32,767
 N Numeric 18
 P Packed 10
 U Unsigned packed 9
 B Binary 4
 I Integer 4
 F Fixed point ASCII 19
How to handle decimal points?

 When we want to represent variable


123.45 then it is defined as
var1 W 5 N 2
Arrays and Masks

 Definition of array
diag-code W 5 A OCCURS 5
 Mask is used to print the numeric variable
with certain mask
 For E.g.
AD-DATE W 8 N MASK(’99/99/9999’)
 We can also suppress leading zeros by using z
in mask.
Activity Section

 Activity section consists of various


procedures

 Starts with JOB or SORT statement


SORT STATEMENT

SORT statement orders any file which can


be processed sequentially.

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


USING (field-name [D])
[BEFORE proc-name]
[NAME sort-name]
SORT STATEMENT

file-name-1 - name of the input file to be sorted


file-name-2 - name of the sorted output file
USING field-name [D] - Identifies data fields of
file-name-1 used as sort keys. Sub-parameter
D - for descending order.
BEFORE proc-name - Optional parameter that
identifies a procedure that prescreens,
modifies and selects input records for the
sort.
NAME sort-name- names the SORT activity.
Used for documentation only
EG. OF SORT PROCEDURE

FILE PERSNL FB(150 1800)


EMP# 9 5 N
GROSS 94 4 P 2
*
FILE SORTER FB (150 1800)
*
SORT PERSNL +
TO SORTER +
USING EMP# +
BEFORE INCLUDE-RECS
*
INCLUDE-RECS. PROC
IF GROSS LT 29999
SELECT
END-IF
END-PROC
*
Job statement

 Syntax
JOB INPUT filename START initial-proc FINISH final-proc
E.g.
JOB INPUT MEMBFILE START initial-proc FINISH final-
proc
 Initial-proc will get executed at the beginning of
the program and final-proc at the end of the
program
 In between these two proc, file records will be
read.
Procedures

 How to call procedures?


e.g.. Perform calc-member
 Procedure is written at the end of the job
statement and its syntax is as written below
Calc-member. Proc
-------------------
End-proc
 You can also call one procedure from other.
Logical operators

 “OR” is the logical operator in easytrieve.


 We don’t have “AND” in easytrieve instead of
using “AND” we use just space.For eg.

IF IN-REC-TYPE ¬= '10' '20' '30'


GOTO JOB
END-IF
IF IN-REC-TYPE = ‘25' OR +
’31’
PERFORM MEMB-CALC-PROC
END-IF
IF ELSE and DO verb
 IF ELSE.
IF cond1
statements
ELSE cond2
statements
END-IF
 DO UNTIL
DO UNTIL var1 > 5
var1 = var1 + 1
END-DO
Case Verb

 Syntax
CASE var1
WHEN abc
perform read-membfile
WHEN xyz
perform read-claimfile
END-CASE
 When var1 equals to abc then first condition will be executed
and when var1 equals to xyz second condition will get
executed.
How to assign value

 Assignments (using EQ or =)
assigns the value in right side to the variable in the
left side.
Example : MSR-7061-CURR-RREP-SOURCE EQ 'P'

 MOVE statement moves a string from one


variable to another
End of file Verb

 End of file can be captured by


statement EOF.
Syntax
IF EOF membfile
statements
END-IF
PUT and GOTO JOB and STOP
Verb.

 PUT Verb
For writing a record in the output file command is
PUT outfile.
 GOTO JOB Verb
Whenever we want to read next record in the file
GOTO JOB command is used.
 STOP Verb
STOP verb terminates the execution of that particular
job alone, whereas STOP EXECUTE terminates the
execution of the program itself.
Sample Program
*****************************************************************************
FILE FILE1 FB (40 400)
*
************************************************************************
* INPUT FILE1 LAYOUT
************************************************************************
FILE1-RECORD 1 40 A
EMP-NBR1 1 5 N
EMP-NAME1 7 10 A
EMP-SALARY1 18 6 N
*
FILE FILE2 FB (30 300)
*
************************************************************************
* INPUT FILE2 LAYOUT
************************************************************************
FILE2-RECORD 1 30 A
EMP-NBR2 1 5 N
EMP-SALARY2 7 6 N
EMP-ROLE2 14 3 A
*
FILE FILE3 FB (20 200)
************************************************************************
* OUTPUT FILE LAYOUT
************************************************************************
FILE3-RECORD 1 20 A
EMP-NBR3 1 5 N
EMP-NAME3 7 10 A
EMP-ROLE3 18 3 A
*
************************************************************************
Sample Program
JOB INPUT (FILE1 KEY(EMP-NBR1) +
FILE2 KEY(EMP-NBR2))
*
IF MATCHED
MOVE EMP-NBR1 TO EMP-NBR3
MOVE EMP-NAME1 TO EMP-NAME3
MOVE EMP-ROLE2 TO EMP-ROLE3
PUT FILE3
ELSE
IF FILE1
MOVE EMP-NBR1 TO EMP-NBR3
MOVE EMP-NAME1 TO EMP-NAME3
MOVE SPACES TO EMP-ROLE3
PUT FILE3
END-IF
END-IF
*
GO TO JOB
*
Report

 How to call report?


you just need to say
print reportname in your program.
Sample Report

94 REPORT UPD-RPT PAGESIZE 51 LINESIZE 63 NODATE NOPAGE


95 SEQUENCE DEPT LAST-NAME
96 CONTROL DEPT
97 TITLE 1 'ANNUAL UPDATE REPORT - SALARIED EMPLOYEES'
98 HEADING LAST-NAME 'NAME'
99 HEADING SERVICE 'SERV'
100 LINE DEPT LAST-NAME SERVICE RAISE SALARY
ANNUAL UPDATE REPORT - SALARIED EMPLOYEES

DEPT NAME SERV RAISE SALARY

901 WALTERS 10 2,204.80 24,252.80


901 2,204.80 24,252.80

903 WIMN 30 1,942.72 23,369.92


903 1,942.72 23,369.92

911 ARNOLD 13 2,316.60 25,482.60


GREEN 12 1,901.12 20,912.32
HAFER 11 634.14 6,975.54
ISAAC 16 1,630.72 18,937.92
KRUSE 21 1,260.48 15,865.28
LARSON 15 1,476.38 17,240.22
POST 12 1,518.40 16,702.40
POWELL 26 1,264.64 15,911.04
REYNOLDS 20 905.58 11,961.38
SMOTH 26 1,639.04 20,029.44
STRIDE 13 2,009.28 22,102.08
YOUNG 11 1,630.72 17,937.92
911 18,187.10 210,058.14
SEQUENCE Statement

 This will sort the report on the given


variables
 In our example report will be sorted on
the Dept and Last Name.
CONTROL Statement

 The CONTROL statement identifies control


fields used for a control report. A control
break occurs whenever the value of any
control field changes.
Title ,Heading and Lines

 Titles are written right at the top of the


report
 They are aligned centrally by default
 Headings are written above each
column(if coded in the program)
 Lines are the actual data in the report
which comes in the form of rows
Thank You !!!

You might also like