The below tutorial gives brief overview of Easytrieve.
Structure
of an Easytrieve program
Contains
3 sections
~~~~~~~~~~~~~~~~~~~
ENVIRONMENT
SECTION : Optional
LIBRARY
SECTION : Optional
ACTIVITY
SECTION : Mandatory
ENVIRONMENT
SECTION (Equivalent to ID Division & Environment Division)
Establishes
parameters for the program. These parameters override
standard Easytrieve options.
LIBRARY
SECTION (Equivalent to DATA DIVISION in cobol)
Describes
datafiles and other fields(including working storage
fields) to be used in the program.
ACTIVITY
SECTION
There
are 2 types of activities - JOB and SORT
JOB
activities read from or write to files and manipulate data.
SORT
activities create sequenced files.
ENVIRONMENT
SECTION
~~~~~~~~~~~~~~~~~~~~
PARM
STATEMENT
The
parameters of the PARM statement provide a method for customizing the operating
environment for the duration of one program's compilation and execution.
ABEXIT
(SNAP/NOSNAP/NO)
ABEXIT
indicates the level of control exercised over program interrupt
codes
1 through 11.
-
SNAP prints a formatted dump of CA-Easytrieve Plus
storage
areas along with an error analysis report.
- NOSNAP prints only a error analysis report.
- NO inhibits CA-Easytrieve Plus interception of program interrupts.
COMPILE
COMPILE
terminates execution after the completion of the syntax check and
compile
operations.
DEBUG
DEBUG
and its subparameters control generation of certain system outputs.
These
outputs are used to analyze programming errors that cause abnormal
execution
termination.
Subparameters
of DEBUG :
-
CLIST
CLIST
creates a condensed listing of the executable program produced
by
the compiler.
-
PMAP
PMAP
creates a complete listing of the executable program produced by
the
compiler.
-
DMAP
DMAP
creates a listing of the data map for each file and its
Associated
fields.
-
FLDCHK
FLDCHK
validates all data references during program execution.
-
FLOW
FLOW
activates a trace of the statements being executed.
STATE
STATE
saves the statement number of the statement currently being
executed.
The statement number is then printed in the associated abnormal
termination
messages.
XREF
XREF
causes the creation of a cross reference listing of each field name,
file
name, procedure name, segment name, report name, and statement label.
ENVIRONMENT
(COBOL,NONE)
LINK
(prgname-1 R)
LINK
terminates execution after the completion of syntax check and compile
operations.
Prgname-1
is the name of the program.
Subparameter
'R' specifies that the new program replaces an existing program
with
the same name.
For
eg.,
1)
Chgman pgm PARM stmt : PARM LINK (STCIB010 R)
2)
PARM statement for EZT programs to be compiled outside chgman :
PARM
DEBUG (NOCLIST NODMAP NOFLDCHK NOFLOW NOXREF) +
LIST
(NOFILE NOPARM) ENVIRONMENT COBOL
LIBRARY
SECTION
~~~~~~~~~~~~~~~~
FILE
statement - This statement describes the files accessed by the
program.
SYNTAX
:-
FILE
<filename> <filetype> <devicetype> <recordformat>
Filename:
Can be a max of 8 characters (Same as DDName in JCL)
Filetype:
Specifies file type. Default is sequential. If the file type is
something
other than sequential, this parameter must be specified
FILE-TYPE DESCRIPTION
IS Indexed
Sequential Access method
VS
Virtual Storage Access method.
ES
ESDS
UPDATE
- code the UPDATE option to update this file with the PUT or WRITE
statements.
Devicetype:
This could be CARD, PUNCH, PRINTER, DISK, TAPE.
For
Reports this parameter MUST be specified as PRINTER.
Recordformat
: This specifies the record format of the file. This parameter can
take the following values :
F=fixed
unblocked, FB=fixed blocked
V=variable
unblocked, VB=variable blocked
U=undefined
For
Eg.,
- For VSAM file -> FILE SMLML VS
- Sequential file -> FILE MBRFILE
- Reports -> FILE STML250R PRINTER
FIELD
DECLARATIONS
Field
names can be a max of 40 characters. It can contain
alphabets(A-Z
and a-z), numbers(0-9) and all special characters except
delimiters.
A field name should contain atleast one alphabet or special char.
Examples
:
- Working Storage fields ->
a)
NO-OF-DAYS W 7 N -> Field type –
N for Numeric & A for Char.
|
|_Length of the field
|
|__Indicates
Working storage variable
b)
PRINT-FLAG W 1 A VALUE 'N'
|
|__VALUE
clause is similar to COBOL
- Fields to be used within Report Section like page number etc., should be defined with type “S”
- MASK can be used for editing characters(to be displayed in rpt etc.,)
a)
For Eg., PAGENO S 5 N VALUE 1 MASK('ZZZZZ')
| |__Usage is similar to COBOL
|
|__If
a field is defined as type ‘S’ it can be modified
in REPORT section.
b)
MASK of 9 causes a digit to print.
c)
MASK of Z causes a digit to print (except for leading zeros).
d)
MASK of * causes an asterisk to replace leading zero digits.
e)
MASK of - causes a minus sign to print prior to the first non-zero
digit
of
a negative number.
f)
MASK of $ causes a currency symbol to print prior to the first
non-zero
digit
- We can use DEFINE statement to declare fields in ACTIVITY section.
Eg.,
DEFINE CURRENT-MONTH W 10 A VALUE 'JANUARY'
- We can Redefine fields/records by specifying the offset.
Example
:
FILE
MBRFILE
MEMBER-REC
1 248 A
ST-BASE-SSN-N
MEMBER-REC + 02 09 N
ST-BASE-DEP-IND
MEMBER-REC + 11 02 A
ST-PRI-NAME
MEMBER-REC + 11 25 A
ST-PRI-SEX
MEMBER-REC + 43 01 A
ST-PRI-DOB
MEMBER-REC + 44 07 N
ST-DEP-NAME
MEMBER-REC + 13 25 A
ST-DEP-SEQ-NBR
MEMBER-REC + 38 02 A
ST-DEP-SEX
MEMBER-REC + 47 01 A
ST-DEP-DOB
MEMBER-REC + 40 07 N
ST-DEP-REL
MEMBER-REC + 48 02 A
- OCCURS clause can be used to declare tables :
Examples
:
a)
WS-TABLE
W 26 A OCCURS 23
WS-DUE-OFF-DT
WS-TABLE 8 A
WS-DUE-OFF-DT-MM
WS-DUE-OFF-DT 2 N
WS-DUE-OFF-DT-DD
WS-DUE-OFF-DT +2 2 N MASK('99')
WS-DUE-OFF-DT-DD-A
WS-DUE-OFF-DT-DD 2 A
WS-DUE-OFF-DT-CC
WS-DUE-OFF-DT +4 2 N
WS-DUE-OFF-DT-YY
WS-DUE-OFF-DT +6 2 N
WS-NUM-MISSED
WS-TABLE +8 3 N
WS-NUM-MISSED1
WS-TABLE +8 3 A
WS-JUL-INIT-DT-07
WS-TABLE +11 7 N
WS-INIT-DT
WS-TABLE +18 8 N
NOTE
:
Variables
coded in BOLD are Primary variables of the Table (i.e., similar to
05
level).
Variables
in ITALICS are Redefined variables
- REPORT HEADINGS : Default report heading for a field is the field name. Incase we need a different heading to be displayed in the report we can use HEADING option.
For
Eg.,
a)
WS-FNAME W 15 A HEADING ('FIRST NAME')
|
|__Heading
displayed is FIRSTNAME
b)PAY-GROSS
W 04 P 2 HEADING('GROSS' 'PAY')
|
|__Heading
will be split into 2 lines & is
displayed
as : GROSS PAY
c)
CONTRACT W 11 N HEADING ('EMPLOYEE' 'ID') +
MASK
'999-99-9999-99'
CONTINUATIONS
: + OR -
The
hyphen indicates that the statement continues with the first position
in
the next statement area (which can be a blank).
The
plus symbol indicates that the statement continues with the first
nonblank
character in the next statement area (which could be in the first
position);
leading blanks are ignored.
PROCESSING
- JOB – JOB statement performs the following activities
- Retrieval of input files
- Examination and manipulation of data
- Initiation of printed reports
- Production of output files.
- SORT statement
JOB:
SYNTAX
– JOB INPUT <filename> START <procname> FINISH
<procname>
|
| |_This proc will be
|
| performed at End of JOB
|
|__The PROC mentioned here will be executed
|
automatically when the JOB begins
|____Identifies
that the Job has an Automatic input. The file
specified
here will be read automatically and the
records
will be processed sequentially until EOF.
- When INPUT is not specified, EZT automatically takes the first File defined
in
the Library section as Input.
- To override the default input file NULL should be coded in place of filename
Eg.,
JOB INPUT NULL
PROC:
Procedures(or
PROCs) can be coded to execute a set of statements. The PROCs can be
called from the JOB statement by using PERFORM statement. PROCs must
be coded immediately after the associated JOB, SORT or REPORT
statement
Example
:
JOB
INPUT SMLML START START-PARA
IF
MSR-7061-CURR-RREP-SOURCE EQ 'M' OR +
MSR-7061-CURR-RREP-SOURCE
EQ 'P'
PERFORM
LOC-31-PARA
END-IF
GOTO
JOB
LOC-31-PARA.
PROC
IF
(WS-HOLD-MSR-JUL-DT GT WS-TEMP-INIT-DT-07)
PRINT
STML240R
END-IF
END-PROC
ASSIGNMENTS
& MOVES :
- 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. MOVE statement does not transfer the value in Numeric form(ie., even if its used for numeric fields the value moved is in Character form). However, when we move ZEROES the value moved is Numeric
- The MOVE LIKE statement copies fields with identical field names from one
file
to another.
SYNTAX
: MOVE LIKE <file1/rec1> to <file2/rec2>
IF,
DO & CASE statements :
- IF, ELSE-IF, ELSE & END-IF statements are available in Easytrieve. Relational operators are :
i)
EQ or =
ii)
NE or »= or NQ
iii)
LT or < or LS
iv)
LE or <= or LQ
v)
GT or > or GR
vi)
GE or >= or GQ
- To perform a set of statements n times, DO WHILE or DO UNTIL statement can be used.
Example
:
I
= 1
DO
WHILE I < 10
I
= I + 1
END-DO
- CASE stmt : CASE is similar to EVALUATE statement.
Example
:
i)
CASE
ST-DEP-DOB-C
WHEN
1
WS-DOB-CC
EQ '18'
WHEN
0 2 -> OR need not be coded explicitly
WS-DOB-CC
EQ '19'
WHEN
3
WS-DOB-CC
EQ '20'
END-CASE
ii)
CASE
WORK-GROSS
WHEN
0 THRU 1000
XMAS-BONUS
= PAY-GROSS * 1.03
WHEN
1001 THRU 5000
XMAS-BONUS
= PAY-GROSS * 1.05
OTHERWISE
XMAS-BONUS
= PAY-GROSS * 1.10
END-CASE
FILE
OPERATIONS :
- GET statement : Used to READ a file sequentially.
SYNTAX
- GET <filename> STATUS
|___If
STATUS is specified FILE STATUS is returned
after
the GET operation
Eg.,
GET
PERSNL STATUS
IF
PERSNL:FILE-STATUS NE 0
DISPLAY
PERSNL:FILE-STATUS
END-IF
- POINT statement : Equivalent to START in COBOL.
SYNTAX
- POINT <filename> <relational operator> <field name>
STATUS
Eg.,
POINT
DUPIN GE HD-IN-KEY STATUS
- PRINT : PRINT statement requests report output
SYNTAX
- PRINT <rptname>
|
|__
If report name is not specified default will be assumed
- PUT : performs sequential file output
SYNTAX
– PUT <filename> FROM <recname> STATUS
|
|__
this clause is optional
- READ : Read statement is used for Random Access to VSAM datasets.
SYNTAX
- READ <file-name> KEY <field-name> STATUSâ
- WRITE : Write statement is used for writing recs into VSAM files. Its used to Update, Add or Delete recs from VSAM files. To update a record, UPDATE subparameter must have been coded in the FILE definition.
SYNTAX
– WRITE <filename> <activity> FROM <recname>
STATUS
|
|
|__can
have “UPDATE” or “ADD” or “DELETE”.
UPDATE
is the default operation.
Eg.,
a)
FILE
INTFILE VS (UPDATE) -> File definition
WRITE
INTFILE UPDATE STATUS -> Write stmt in JOB
REPORT
Definition
SYNTAX
of REPORT stmt :
REPORT
<rptname> <options>
Report
Definition Statements
Following
statements define the content of the report and must be coded in the
same order as shown below.
SEQUENCE
CONTROL
SUM
TITLE
HEADING
LINE
special
procedures
- SEQUENCE :
The
SEQUENCE statement optionally specifies the order of the report. We
can
order a report based on the content of one or more fields. The
fields
do not have to be part of the printed report.
SYNTAX
- SEQUENCE field-name-1 field-name2 D
|__indicates
Descending order
Default
is Ascending order.
- CONTROL :
The
CONTROL statement identifies control fields used for a control
report.
A control break occurs whenever the value of any control field
changes.
SYNTAX
– CONTROL field-name1 <NEWPAGE/RENUM> <NOPRINT>
|__Optional
NEWPAGE
causes a skip to top-of-page after control break processing is
complete
for the specified field.
RENUM
performs the same function as NEWPAGE, and also resets the page
number
to 1 on the page following the control break.
NOPRINT
suppresses printing the summary line group for the specified
control
break
- SUM :
SUM
statement prints the Totals of the specified fields at the end of
report
or whenever control break occurs
Normally,
Easytrieve automatically totals all quantitative fields
specified
on LINE statements. The SUM statement overrides this process;
only
the fields specified on the SUM statement are totaled. The fields
The
SUM statement is only valid within a Control Report.
SYNTAX
– SUM fieldname
- TITLE :
The
TITLE statement defines the title items and their position on the
title
line.
Easytrieve
automatically positions the system date and current
page
count on title line one. This can be overridden by the options on
the
REPORT statement (NODATE/NOKDATE/LONGDATE/SHORTDATE and
NOPAGE/NOKPAGE).
Each
title line is centered within the title area of the report unless we
specify
NOADJUST in REPORT stmt.
Example
:
TITLE
1 COL 15 'PGM: STCIB085 ' +
COL
45 'BLUE CROSS AND BLUE SHIELD OF GEORGIA, INC.' +
COL
97 'RPT: STC085R1'
TITLE
2 COL 50 'REPORT OF INVENTORIED STATE CLAIMS'
TITLE
3 COL 40 ' '
TITLE
4 COL 15 'CATEGORY:' +
COL
25 WT-CATEGORY-NAME(CAT-SS) +
COL
87 'REPORT PERIOD: ' RPT-DATE
- HEADING :
The
HEADING statement optionally defines an alternate heading for a
field.
When
defining the field, you can specify the default heading.
HEADING
WS-INIT-PRT-GREG-DT-06 ('DATE' 'RECEIVED')
HEADING
WS-NUM-ACTIVATED ('NUMBER' 'ACTIVATED')
- LINE :
Line
Stmt defines the detail lines for the report
Syntax
: LINE <COL XX1>or <POS> field name1 +
<COL
XX2>or <POS> field name2
COL
specifies the column number where the next line item is placed. We
must
specify the NOADJUST option of the REPORT statement to use the COL
option.
The
POS parameter enables you to position line items on lines 2 through
99
so
that they line up under particular line items on the first line.
REPORT
PROCEDURES
REPORT-INPUT.
PROC
It
permits final screening and modification of report input data. It is
performed
for each record selected for the report that contains the PROC.
We
must execute a SELECT statement in the PROC to cause data to continue
to
the
report.
BEFORE-LINE.
PROC
The
proc is executed before each line is printed
AFTER-LINE.
PROC
The
proc is executed after each line is printed
BEFORE-BREAK.
PROC
It
permits modification of totals and special annotation before total
line printing caused by the CONTROL statement. A system-defined field
named LEVEL can be tested to determine which field has caused the
break, when we have control breaks based on more than 1 field.
LEVEL
= 1 for minor break(ie., the last field coded in control stmt)
=
2 for next break(last but one
=
N + 1 for final totals.
(N
is the number of control fields)
AFTER-BREAK.
PROC
Same
as BEFORE-BREAK proc except that the PROC will be executed after the
Total lines for Control break has been executed.
ENDPAGE.
PROC
Will
be executed at the end of each page. Can be used to print
Footnotes...
TERMINATION.
PROC
Will
be executed at the end of rpt.
REPORT
PROCS – Eg.,
REPORT
NEW-CIC-SUM PRINTER STC085R3
SEQUENCE
CAT-SS
CONTROL
FINAL NOPRINT CAT-SS NOPRINT
TITLE
1 'PGM: STCIB085 ' +
'BLUE
CROSS AND BLUE SHIELD OF GEORGIA, INC.' +
'RPT:
STC085R3'
TITLE
2 'REPORT OF INVENTORIED STATE CLAIMS'
TITLE
3 'CATEGORY SUMMARY - NUMBER RECEIVED IN REPORTING PERIOD'
LINE
1 WT-CATEGORY-NAME(CAT-SS) +
CLMS-PER-CAT
REPORT-INPUT.
PROC
SELECT
END-PROC
AFTER-BREAK.
PROC
IF
LEVEL = 1
DISPLAY
' '
DISPLAY
'INVENTORY FILE STATISTICS'
DISPLAY
' '
DISPLAY
' RECORDS ON INVENTORY FILE : ' CIC-CNT
END-IF
END-PROC
SAMPLE
EZT PGM :-
PARM
DEBUG (NOCLIST NODMAP NOFLDCHK NOFLOW NOXREF) +
LIST
(NOFILE NOPARM) ENVIRONMENT COBOL
**********************************************************************
*
PROGRAM NAME : ADHOC *
*
PROGRAMMER : SYNTEL *
*
PURPOSE : *
*
THIS PROGRAM WILL READ THE STATE MERIT FILE AND CREATE A REPORT *
*
OF EMPLOYEES AND DEPENDENTS THAT HAVE EITHER SPECIAL CHARACTER *
*
OR A BLANK SPACE IN THE FIRST POSITION OF FIRST NAME, *
*
LAST NAME OR MIDDLE NAME. *
**********************************************************************
***************
*
INPUT FILE *
***************
FILE
MBRFILE
MEMBER-REC
1 248 A
ST-BASE-SSN-N
MEMBER-REC +02 09 N
ST-BASE-DEP-IND
MEMBER-REC +11 02 A
ST-PRI-NAME
MEMBER-REC +11 25 A
ST-PRI-SEX
MEMBER-REC +43 01 A
ST-PRI-DOB
MEMBER-REC +44 07 N
ST-PRI-DOB-C
ST-PRI-DOB 01 N
ST-PRI-DOB-YY
ST-PRI-DOB +01 02 N
ST-PRI-DOB-MM
ST-PRI-DOB +03 02 N
ST-PRI-DOB-DD
ST-PRI-DOB +05 02 N
ST-DEP-NAME
MEMBER-REC +13 25 A
ST-DEP-SEQ-NBR
MEMBER-REC +38 02 A
ST-DEP-SEX
MEMBER-REC +47 01 A
ST-DEP-DOB
MEMBER-REC +40 07 N
ST-DEP-DOB-C
ST-DEP-DOB 01 N
ST-DEP-DOB-YY
ST-DEP-DOB +01 02 N
ST-DEP-DOB-MM
ST-DEP-DOB +03 02 N
ST-DEP-DOB-DD
ST-DEP-DOB +05 02 N
ST-DEP-REL
MEMBER-REC +48 02 A
****************
*
REPORT FILE *
****************
FILE
REPORT1 PRINTER
******************
*
WORKING STORAGE
******************
WS-LINK-REC
W 61 A
WS-FULL-NAME
WS-LINK-REC 25 A
WS-FNAME
WS-LINK-REC +25 15 A HEADING ('FIRST NAME')
WS-F-FIRST
WS-FNAME 01 A
WS-LNAME
WS-LINK-REC +40 20 A HEADING ('LAST NAME')
WS-L-FIRST
WS-LNAME 01 A
WS-L-15-20
WS-LNAME +15 05 A
WS-MNAME
WS-LINK-REC +60 01 A HEADING ('MIDDLE' 'INITIAL')
WS-ERROR
W 04 A HEADING ('ERROR' 'INDICATOR')
F-ERROR
WS-ERROR 01 A
L-ERROR
WS-ERROR +01 01 A
M-ERROR
WS-ERROR +02 01 A
E-ERROR
WS-ERROR +03 01 A
WS-SEX
W 01 A HEADING ('SEX')
WS-REL
W 02 A HEADING ('RELATION')
WS-MEMBER-ID
W 09 A HEADING ('MEMBER ID')
WS-SEQ-NBR
W 02 A HEADING ('SEQ' 'NBR')
WS-DOB
W 10 A HEADING ('DOB')
WS-DOB-MM
WS-DOB 02 A
WS-FIL1
WS-DOB +02 01 A VALUE '/'
WS-DOB-DD
WS-DOB +03 02 A
WS-FIL2
WS-DOB +05 01 A VALUE '/'
WS-DOB-CC
WS-DOB +06 02 A
WS-DOB-YY
WS-DOB +08 02 A
*----------------------------------------------------------------------*
JOB
INPUT MBRFILE
*----------------------------------------------------------------------*
MOVE
SPACES TO WS-LINK-REC
CASE
ST-BASE-DEP-IND
WHEN
'ZD'
WS-FULL-NAME
EQ ST-DEP-NAME
OTHERWISE
WS-FULL-NAME
EQ ST-PRI-NAME
END-CASE
CALL
STRNAME USING (WS-LINK-REC)
IF
ST-BASE-DEP-IND EQ 'ZD'
WS-SEQ-NBR
EQ ST-DEP-SEQ-NBR
CASE
ST-DEP-DOB-C
WHEN
1
WS-DOB-CC
EQ '18'
WHEN
0 2
WS-DOB-CC
EQ '19'
WHEN
3
WS-DOB-CC
EQ '20'
END-CASE
WS-DOB-YY
EQ ST-DEP-DOB-YY
WS-DOB-MM
EQ ST-DEP-DOB-MM
WS-DOB-DD
EQ ST-DEP-DOB-DD
WS-SEX
EQ ST-DEP-SEX
WS-REL
EQ ST-DEP-REL
ELSE
WS-SEQ-NBR
EQ '00'
CASE
ST-PRI-DOB-C
WHEN
1
WS-DOB-CC
EQ '18'
WHEN
0 2
WS-DOB-CC
EQ '19'
WHEN
3
WS-DOB-CC
EQ '20'
END-CASE
WS-DOB-YY
EQ ST-PRI-DOB-YY
WS-DOB-MM
EQ ST-PRI-DOB-MM
WS-DOB-DD
EQ ST-PRI-DOB-DD
WS-SEX
EQ ST-PRI-SEX
MOVE
SPACES TO WS-REL
END-IF
WS-MEMBER-ID
EQ ST-BASE-SSN-N
MOVE
SPACES TO WS-ERROR
IF
(WS-F-FIRST NOT ALPHABETIC) OR +
(WS-F-FIRST
SPACE)
F-ERROR
EQ 'F'
END-IF
IF
(WS-L-FIRST NOT ALPHABETIC) OR +
(WS-L-FIRST
SPACE)
L-ERROR
EQ 'L'
END-IF
IF
WS-L-15-20 NOT SPACES
E-ERROR
EQ 'E'
END-IF
IF
(WS-MNAME NOT ALPHABETIC) OR +
(WS-MNAME
SPACE)
M-ERROR
EQ 'M'
END-IF
IF
WS-ERROR NOT SPACES
PRINT
REPORT1
END-IF
GOTO
JOB
REPORT
REPORT1 PRINTER REPORT1
TITLE
01 'MEMBERS IN STATE TAPE WITH NAME ISSUES'
LINE
01 WS-MEMBER-ID +
WS-SEQ-NBR
+
WS-LNAME
+
WS-FNAME
+
WS-MNAME
+
WS-DOB
+
WS-SEX
+
WS-REL
+
WS-ERROR
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.