C012 Eztrieve

Download as pdf or txt
Download as pdf or txt
You are on page 1of 114

EASYTRIEVE PLUS

Objective:To provide an insight into


EASYTRIEVE PLUS and its utilization in
Database Management Systems.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 1/114
Course Details
No: C014
Name Easytrieve
Introduction Easytrieve is a tool which
helps in information
retrieval and in Data Base
Management.This material
gives an insight into how
Easytrieve can be used
with IMS and DB2 DBMS.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 2/114
Course Details
Pre-Requisite Knowledge of IMS and
DB2 DBMS.
Target To be decided by the CR
Audience and SWS
Mode of Class Room
Training
Evaluation Attendance > 80 %
Criteria and/or
(Case study Completion
or Test score > 50 %)

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 3/114
Lesson Plan
M# Topic Time(hrs)
1 Introduction 1
2 Library Section 1
3 Activity Section 2
4 Error Messages 0.5
5 Easytrieve with IMS 1
6 Easytrieve with DB2 2
7
8
9
Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 4/114
• This material is made for EBSCO - Easytrieve
to Cobol conversion project training program.
As it is project specific, it will not be peer
reviewed.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 5/114
Modules
Duration : 8 Hrs
• Introduction
• Library Section
• Activity section
• Error Messages
• Dealing with DB2
• Dealing with IMS

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 6/114
Module 1- Introduction
Duration : 1 hour
• Introduction to Easytrieve Plus
• Capabilities :-
– File Processing
– Operations
– Output
• Program Structure

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 7/114
Module 2-Library Section
Duration : 1 hour

• Data Formats
• Mask
• Record Definitions
• Arrays

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 8/114
Module 3-Activity Section
Duration: 2 hours
• JOB Statement
• Assignment Statement
• Conditional Branching
• Case Stmt / PERFORM Stmt / STOP stmt
• Input / Output Stmt
• Controlled I/O
• Procedure Processing

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 9/114
Module 4- Error Messages
Duration:1/2 hr
• Error Messages
• Error Codes
• Syntax Diagnostic Messages

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 10/114
Module 5- Dealing with DB2
Duration : 1 hour
• EZT Plus Structure
• DB2 Statements
• Cursors-Processing
• SQLCA
• Error Handling

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 11/114
Module 6- Dealing with IMS
Duration : 2 hours
• Introduction to IMS Database
• FILE Statement
• RECORD Statement
• SSA
• DLI Functions
• DLI statement
• RETRIEVE Statement

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 12/114
Module 1- Introduction
Duration : 1 hours
• Introduction to Easytrieve Plus
• Capabilities :-
– File Processing
– Operations
– Output
• Program Structure

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 13/114
EASYTRIEVE PLUS

• A tool which helps information retrieval and


Data Base Management system for simplified
programming. Provides the user with Good
reporting capabilities.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 14/114
Capabilities
1. File Processing : - Processes SAM, ISAM,
VSAM or IMS/DLI Files Allows fixed,
variable, undefined, or spanned record
formats. Matches unlimited number of files.
2. Operations: Sorts on any number of Keys
3. Output: Very Good Reporting Features
Automatically formats output with all totals
calculated internally. Provides summary
report.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 15/114
Program Structure
• Environment section - Optional
– Override standard EZT options and
choose new one by using PARM
• Library Section - Optional
– for defining all files and Working storage
• Activity Section - Mandatory
– JOB statement and SORT statements

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 16/114
Environment Section
Environment Section (Optional)
Given in comments. Used to describe the
program ID, Description, Date written etc.
Ex: PARM DEBUG(PGM1)
*PROGRAM-ID PGM1.
*AUTHOR. IMR.
*DATE WRITTEN. 08/20/1997.
*DESCRIPTION. Sample Program

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 17/114
Library Section
• Library Section
Used to define all input/output files and
Working storage fields in the program
Example:
FILE PERSNL FB(150 1800)
NAME 17 16 A
LAST-NAME NAME 8 A
PAY-GROSS 94 8 A

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 18/114
Activity Section
• Activity Section (Mandatory)
– Two types of activities - JOB and SORT
– JOB Statement indicates the start of the
program logic.
– SORT Statement is used to sort the sequential
files.
– Any number of JOB and SORT statement.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 19/114
Activity Section
• JOB activities read information from input
files examine and manipulate information,
write information to output files, and
produce printed reports.
• SORT activities create sorted sequential
output files that contain all or part of the
records from another (input) file.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 20/114
Statement Area
• Each line contain a single statement. Can
also have multiple statements in Single line
eg. Cost = A + B. PRICE = COST + Others
• Any non blank line starting with ‘*’ will be
treated as comment line.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 21/114
Continuation
• Can continue lines in a statement to the next
line using + or - character.
Eg
Field name W 8 A +
VALUE ‘ABC-
DEF’.
• JOB INPUT NULL +
START INITIALISE

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 22/114
Quiz
• What will be the value of the variable-
VAR1 W 1 4 N VALUE ‘THIS IS ST -
RING’
• What are the activities in the Activity
section?

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 23/114
Quiz Answers
• ‘THIS IS ST RING’
• JOB and SORT

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 24/114
Module 2 - Library Section
Duration: 1 hrs
• Library Section
• Data Formats
• Mask
• Record Definitions

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 25/114
Library Section
The Library section of your program provides
1. A general description of the groups of data
(files) on which your program is going to
operate (via the FILE statement)
2. A specific description of the individual items
of data (fields) within each record of the
files or within working storage (via the
DEFINE statement optionally)

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 26/114
File Declaration
The syntax of File declaration is
FILE <file-name>
[file type <IS/VIRTUAL>
<DLI (DB-NAME)>
<VS>]
[ device type is <CARD>
<PRINTER>
<DISK/TAPE> ]

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 27/114
File Type Parameter
IS - Indexed Sequential Access
Method
VIRTUAL - Easytrieve Plus virtual file
manager (VFM)
DLI - designates an IMS/DLI
database ,dbd-name is alphabetic and
names the database definition within
the Program Specification Block (PSB) to be
processed.
Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 28/114
Field Definitions
This is the name you give to the field you are
defining. It must start with a letter ; can
contain letters, numbers, and special
characters; and can be from 1 to 40
characters long.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 29/114
Data Formats For Fields

A - Alphabetic.
N - zoned decimal.
P - Packed decimal.
B - Binary

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 30/114
A - Alphabetic
A - Alphabetic. Use when none of the
numeric data types apply to this field.
Example:
Name 17 6 A

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 31/114
N - Zoned Decimal
N - zoned decimal. The field contains
digits 0 thru 9 in external decimal form.

Example:
Date-Of-Hire 136 6 N
SALARY 1 4 N 2

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 32/114
P - Packed
Packed.
Example:
Pay-Gross 94 4 P 2

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 33/114
B - Binary
Depending upon their field length, binary
fields can contain values whose maximum is
equivalent to the following number of
decimal digits :
Length in Bytes Digits
1 3
2 5
3 8
4 10
Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 34/114
Field Declaration
Example :
POS Length TYPE DEC
FILE EMP-FILE
EMP-REC 1 40 A
EMP-ID 1 5 N
EMP-NAME 5 25 A EMP-
SALARY 30 5 P 2 EMP-
PERKS 35 5 B 0

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 35/114
Example File Declaration
FILE PERSNL FB (150 1800)
NAME 17 16 A
LAST-NAME NAME 8 A
PAY-GROSS 94 4 P2
DEPT 98 3 N
FILE PHSSF DLI (NPDH006)
HIS-PSB 1 250 A
HIS-STATUS 11 2 A

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 36/114
ReDefinition
While defining a grouped field definitions the
name of the group should be defined first with
full length and individual fields should be defined
by referring to group name, starting position and
length of the individual field. Eg.
Date-of-hire w 6 N
hire-mm date-of-hire 2 N
hire-dd date-of-hire +2 2 N
hire-yy date-of-hire +4 2 N

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 37/114
Example: WS Declaration
SALARY W 4 P2
CURR-DATE W 8 N
CURR-MM CURR-DATE 2 N
CURR-DD CURR -DATE + 2 2 N
CURR-YY CURR-DATE + 4 4 N

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 38/114
Arrays
• The OCCURS option establishes an array
for the field.

• Example:
WS-VAR1 W 3 N 0 OCCURS 40
Accessing 20th occurrence of variable-
WS-VAR1(20)

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 39/114
Arrays (Contd.)
• Indexing is data reference that results when
EZT Plus derives a displacement value to
correspond to a particular occurrence in a field
name.
• Example:
WS-VAR1 W 3 N 0 OCCURS 4 INDEX INDX
Accessing 3rd occurrence of variable-
INDX = (3 - 1) * 4
WS-VAR1

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 40/114
Initialization
Parameter: Value
Syntax: { VALUE Literal-1}

Example
YEAR W 4 N Value 1999

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 41/114
Mask Parameter
Optional MASK parameter can specify a
pattern (edit mask) for printing a numeric
field on a report. Alphabetic fields cannot be
edited.
Syntax: MASK [letter] [BWZ] [letter-4]

For example:-
• WS-TFLAG W 3 P 0 MASK ('ZZ,ZZ9')

• WS-CFLAG W 3 P 0 MASK ('--,--9')


Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 42/114
Points to Note W.R.T MASK
[BWZ]
BWZ (Blank When Zero) suppresses
printing a numeric field when it contains all
zeroes.
Example:
W-VAR1 W 6 N 0 VALUE 123 MASK +
‘BWZ’

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 43/114
Print Edit Mask
It is an alphabetic literal created with a
combination of the following characters :-
9 - causes any digit to print.
Z - causes any digit except leading zeroes
to print
* - causes an asterisk to replace leading
zero digits

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 44/114
Print Edit Mask(Contd.)
- - causes a minus sign to print before the
first or after the last digit of a negative
number.
$ - causes a currency symbol to print before
the first non-zero digit.
X - allows any character to be printed with
the edited data.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 45/114
Examples
• ONE W 4 B VALUE 1

• WS-TEST-MODE-FLAG W 1 A
• WS-NPGDATE-AREA W 36 A
WS-NPGDATE WS-NPGDATE-AREA 6 N
• WS-DATE1 W 6 N
WS-DD1 WS-DATE1 2 N
WS-MM1 WS-DATE1 +2 2 N
WS-YY1 WS-DATE1 +4 2 N
• WS-STOREYYMM W 4 N MASK ('ZZZZ')
• WS-APPLIT W 25 A OCCURS 5

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 46/114
Module 3-Activity Section
Duration: 2 hrs
• JOB Statement
• Assignment Statement
• Conditional Branching
• Case Stmt / PERFORM Stmt / STOP stmt
• Input / Output Stmt
• Controlled I/O
• Procedure Processing

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 47/114
Activity Section
Activity section is an important part of
Easytrieve Plus program since it covers logic,
statement framing and almost similar to
procedure division in COBOL.
JOB
START

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 48/114
Job Stmt.
Identifies the files whose Records are
automatically provided
JOB
INPUT(FILE-NAME [KEY(FIELD-NAME)]
[NAME Job-name]

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 49/114
Example
• JOB INPUT ( MAST-FILE-KEY(MAST-EMP-ID) +
TRAN-FILE KEY(TRAN-EMP-ID))
• JOB INPUT NULL
• JOB INPUT PAYFILE
• JOB INPUT JDB +
START INIT
• JOB

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 50/114
Null Subparameter
NULL - code this subparameter to inhibit
automatic input. Normally, a job is
implicitly stopped when the automatic
input file(s) is exhausted. However, if
you code NULL, the program continues
running until a STOP statement is
executed.
Example : JOB INPUT NULL

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 51/114
SORT Activity
SORT File-name-1
TO File-name-2 +
USING (Field-name) +
[BEFORE (proc name)] +
[Name Sort-name]

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 52/114
Report
• REPORT is the first stmt of the report
declaratives.
• Parameters:
Format Determination
File Directing
Spacing Control
Testing Aids

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 53/114
Report(Cond.)
REPORT report-name +
[Summary]
LABELS ([ACROSS literal-1] + Format
[DOWN literal-2] + Determination
[SIZE literal-3] +
[NEWPAGE]
File
[PRINTER file-name]
Directing

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 54/114
Report(Contd.)
[PAGESIZE literal-4] +
[LINESIZE literal-5] +
Spacing Control
[SPREAD] +
[NOSPREAD]

[LIMIT literal-6] + Testing Aids


[EVERY literal-7]

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 55/114
Assignment Statement
The format used to copy data from one field to
another, or from a literal to a field. The syntax

field-1 [= EQ] field-2 [literal-1]

In the above, the value of field-1 is set equal to


the value of field-2 or literal-1.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 56/114
Points To Note
a. Only one equivalent may be specified i.e. either
field-2 or literal-1
e.g field-1 = field-2 or field-1 = literal-1
b. If field-1 has been DEFINEd as alphabetic,
literal must also be alphabetic. If literal is
shorter than field-1, padding is on the right.
C. If both field-1 and field-2 are alphabetic, but
not the same size, padding or truncation, as
appropriate occurs on the right.
Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 57/114
Contd ….
D. If field-1 is alphabetic and field-2 is numeric,
the resulting value in field-1 will be zonal
decimal, with padding or truncation on the left,
as necessary.
E. If field-1 is numeric, field-2 or literal must be
numeric.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 58/114
Conditional Branching
• IF salary GT 7778
bonus = 888
ELSE
bonus = 999
END-IF.
• DO and END-DO
• GOTO procedure/para name
• PERFORM

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 59/114
Case Stmt
CASE <field-1>
when <value-1>
perform action-1
when <value-2>
perform action-2
END-CASE

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 60/114
Perform Stmt

PERFORM procedure/para name

PERFORM statement cause a branch to


another location in the program.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 61/114
Input / Output Stmts
EASYTRIEVE PLUS supports the following
input and output statements

JOB - specifies the input file


PRINT - initiates report output
DISPLAY - produces printed output not
directly supported by a report.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 62/114
Print Statement
The PRINT statement initiates report output
by causing the named report to extract the
current value of the fields to be output and to
format them according to the specifications
immediately or deferred.
E.g PRINT report-name

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 63/114
Print Stmt. (Cond.)
The report-name parameter is the name of the
report which contains the data being output
with the PRINT statement.
It is important that the data should be made
available along with report format before
executing the print statement.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 64/114
Display Stmt
The Display statement outputs data to the system
printer or a named file. This data is spaced
according to the specified parameters.

DISPLAY [field-name]
e.g DISPLAY error-message

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 65/114
Procedure Processing
Procedures are defined using the PROC and
END-PROC statements.
Invoked By : PERFORM statement.
PROC and END-PROC statements
<proc-name>. PROC
Statements
Statements
END-PROC

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 66/114
Relational Operators
Valid Relational Operators are
EQ = Equal
NE Not equal
LT < Less than
LE <= Less than or equal to
GT > Greater than
GE >= Greater than or equal to

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 67/114
STOP Stmt
This statement terminates EASYTRIEVE PLUS
activities. It can be used for premature
termination of activities using automatic input.
The STOP statement must be used to terminate
JOB activities which have INPUT NULL.
Format
STOP [EXECUTE]
STOP

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 68/114
Controlled I/O Stmts
Provides the capability to process any sequential
or keyed file (ISAM or VSAM). Stmts are:-
GET - sequentially reads one record
POINT - positions a keyed file to a
particular record for subsequent
sequential I/O
PUT - sequentially writes one record
READ - reads one keyed record
WRITE - rewrites, adds one keyed record.
Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 69/114
GET Stmt
• The GET statement makes the next
sequential record of the named file available
for processing.
• Syntax:
GET file-name
• The file name parameter is required. It can
be any file name declared in the Library
section.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 70/114
PUT Stmt.
• The PUT statement outputs data to a
sequential file whose name is specified in the
statement.
• Syntax
PUT file-name-1 [from file-name-2]
• PUT creates new sequential file or adds
consecutive records to an existing VSAM file.
• Both file-name-1 and file-name-2 should be
declared in Library section.
Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 71/114
Point Stmt
The POINT statement initiates a search for a
position within an indexed or relative-record
file, based on a comparison between keys in the
file and a search value specified in the
statement.
Syntax:
POINT file-name [EQ/GE] [field-name, +
literal]

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 72/114
Point stmt.(Contd.)
• The POINT statement only locates the
specified position of the record in the file.
We still have to use GET statement to
retrieve the data for processing.
• File-name must have a declaration in the
Library section of the program.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 73/114
READ stmt
• The READ statement provides random
access to keyed and relative-record VSAM
and ISAM files.
• Syntax :
READ file-name KEY field-name STATUS
• File-name is the file need to be accessed and
should be declared in the Library section of
the program.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 74/114
Read Stmt (Contd.)
KEY field-name
This parameter serves as a search value to
identify the specific record to be retrieved.
The contents of the specified field-name must
match the contents of the key of the desired
record.
STATUS
This parameter is optional. If included,

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 75/114
Read Stmt. (Contd.)
Execution of the READ statement sets a return
code in the FILE-STATUS field of the input
file to indicate the success or failure of the
operation.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 76/114
Write Stmt

The WRITE statement is used in the maintenance


of keyed and relative-record VSAM files. Write
updates or deletes the current record of the named
file, or adds new records.
Syntax:
WRITE file-name [delete,update,add] from
file-name-1

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 77/114
Write Stmt(Contd.)
File-name
names the file to be modified. It must have
declaration in the library section
[delete
update
add] These parameters specify the maintenance
activity to be performed. They are required
for deleting or adding records. It is optional

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 78/114
Write Stmt(Contd.)
for update activity. The default is UPDATE.
File-name-1
This is optional. If included, the write
statement copies the current record to the
file-name.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 79/114
Exercise 1
• Which file is retrieved in the following cases?
FILE FILE1 (1) JOB INPUT VAR1
VAR1 1 10 A (2) JOB
VAR2 11 2 N SORT FILE1 TO FILE2 +
FILE FILE2 USING (VAR2)
(3) JOB
VAR3 1 10 A
(4) JOB INPUT NULL
VAR4 11 2 N

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 80/114
Exercise 2
• What will be produced in the Report?
REPORT ABC
TITLE 01 COL 20 SSN
TITLE 02 SYSDATE COL 20 NAME
(Assume, SSN = 123-45-6789 and NAME = ‘IMR’)

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 81/114
Module 4- Error Messages
• Topics Duration: 1/2 hrs

• Error Messages
• Error Codes
• Syntax Diagnostic Messages

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 82/114
Error Types

Easytreive Plus provides a comprehensive set of


diagnostic messages which fall into 2 categories
Operational Errors & Pgm Syntax Errors

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 83/114
Error Codes
A001 File OPEN Error
A002 Invalid block Size
A003 Insufficient Core storage
A005 I/O error
A007 Table input not in sequence
A008 Too many table entries
A009 report processing terminated due to sort error
A012 Invalid Length of file name
A013 wrong record length for a file

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 84/114
Syntax Diagnostic Messages
B003 - Expected continuation not received
B004 - Report Exceeds page size
B007 - Invalid IF - END-if pairing
B010 - Invalid Block size
B011- Table input not in sequence
B012 - Duplicate name for a file, field or report
B027 - Not a valid name file,field or report
B048 - Field name not in file
B094 - Invalid record format

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 85/114
Module 6- Dealing with DB2
Duration : 1 hours
• EZT Plus Structure
• DB2 Statements
• Cursors-Processing
• SQLCA
• Error Handling

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 86/114
Structure of EZT Plus
For DB2
• Environment Section
– PARM statement only
• Library Definition Section
– Host variable declaration and cursor declaration
• Activity Description section(s)
– DB2 processing like opening, fetching, closing the
cursor.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 87/114
DB2 Statements
• Add SQL before every DB2 Statement

Example:
SQL UPDATE PHVICCI +
SET PH_INIT_CNT_RPRNT = +
:BLANKONE +
WHERE CURRENT OF
VICCICURSOR

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 88/114
Cursor-Processing
• Best way to handle the DB2.
• Steps involved
– Declare cursor
– Open Cursor
– Fetch Cursor
– Close Cursor

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 89/114
Cursor-Processing(Contd.)
Declare the Cursor
• Declared in Library section as-
SQL DECLARE <cursor-name> CURSOR FOR
<select statement(query)>

Example :
SQL DECLARE EMPCURSOR CURSOR +
FOR SELECT EMPNO, ENAME FROM +
EMP_TABLE WHERE DEPTNO = 100
Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 90/114
Cursor-Processing(Contd.)
Open the Cursor
• Coded in Activity Section as-
SQL OPEN <cursor-name>

Example :
SQL OPEN EMPCURSOR

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 91/114
Cursor-Processing(Contd.)
Fetch the Cursor
• Coded in Activity Section as-
SQL FETCH <cursor-name> INTO :<host-
variables>

Example :
SQL FETCH EMPCURSOR INTO +
:W-NO +
:W-NAME
Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 92/114
Cursor-Processing(Contd.)
Close the Cursor
• Coded in Activity Section as-
SQL CLOSE <cursor-name>

Example :
SQL CLOSE EMPCURSOR

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 93/114
SQLCA
• No need to include SQLCA explicitly.
• Any field of SQLCA can be used without
declaration.

Example:
IF SQLCODE NE +0, +100
----

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 94/114
Error Handling
• SQLCODE is used to find the error if occurred.
• DSNTIAR routine can be used to handle the
errors. It is a standard error-reporting routine
IBM supplied as a part of DB2.
• DSNTIAR requires three arguments.
– First argument is SQLCA
– Second argument identifies the data area where you want
DSNTIAR to return formatted error messages.
– Third arg. Is numeric item that contains the length of the
individual text lines the routine returns.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 95/114
Error Handling(Contd.)
• Calling DSNTIAR in Easytrieve Plus-
Activity Section Entry:-
IF SQLCODE NE +0 +100
PERFORM ERR-ROUTINE
END-IF
ERR-ROUTINE. PROC
CALL DSNTIAR USING +
(SQLCA, WS-SQL-MSG, WS-SQL-TEXT-LEN)
--------
Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 96/114
Error Handling(Contd.)
Library Section Entry :-
WS-SQL-MSG W 1682 A
WS-SQL-MSG-LEN WS-SQL-MSG 2 B 0 +
VALUE +1680
WS-SQL-MSG-LINE WS-SQL-MSG +2 80 A +
OCCURS 21 INDEX MSG-INDX
WS-SQL-TEXT-LEN W 4 B 0 VALUE +80
DB2-RETURN-CODE W 2 B 0

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 97/114
Quiz
1. Which DB2 routine is used to deal with SQL
errors?
2. In which section of Easytrieve Plus cursors are
opened?
3. In which section of Easytrieve Plus SQLCA is
included?

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 98/114
Quiz - Answers
1. DSNTIAR.
2. Activity section
3. No declaration for SQLCA

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 99/114
Module 6- Dealing with IMS
Duration : 2 hours
• Introduction to IMS Database
• FILE Statement
• RECORD Statement
• SSA
• DLI Functions
• DLI statement
• RETRIEVE Statement

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 100/114
Introduction to IMS Database
• Hierarchical Database
• Most, if not all, IMS data bases use VSAM data
sets, either KSDS or RRDS.
• Root (parent) and Child hierarchy.
• Root segment is the entry point to Database
• Maximum level is 15 from root to lowest child

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 101/114
Introduction to IMS Database
I M S D a t a b a s e

V e n d o r 1

I t e m 1 I t e m 2 I t e m 3

L o c 1L o c 2L o c 3L o c 4L o c 1L o c 2L o c 1

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 102/114
FILE Statement
• Identifies the Database
• Defines the PCB to be processed
• Syntax :-
FILE filename DLI (dbd-name [literal-1]
• Example:
FILE HISDB DLI (NPDH006)
HIS-PCB 1 250 A
HIS-STATUS 11 2 A

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 103/114
RECORD Statement
• Identifies the database segment segments which
are to be available for processing.
• One RECORD statement must be coded for
each segment of the database to be processed.
• Must be coded in the same order as in PSB
which defines the database.
• All segment of the database need not be
defined, but the parent of each RECORD must
be coded.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 104/114
RECORD Statement(Contd.)
• Syntax :-
RECORD segment-1 literal-1 [segment-2]
Literal-1 - positive integer (length of segment)
• Segment-2 -Parent of segment-1
• Example :
RECORD ECHILD 262 EROOT
ESTAFNO 1 7 A
ESURNME 8 20 A

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 105/114
Record Definitions
Record definition should start with word RECORD followed
by record name. Record allocates a work work space which
contains the segment data during execution

RECORD EROOT
STAFF-NO 1 7 N
SURNAME 8 20 A
INITIALS 48 4 A
DEPT 138 6 A

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 106/114
Record Formats

F = Fixed unblocked
V = Variable unblocked
U = undefined
FB= Fixed blocked
VB= Variable Blocked
VSS = variable blocked spanned.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 107/114
SSA
• Segment Search Argument
• Unqualified SSAs
• Qualified SSAs
• Unqualified SSA-
SSA-UNQUAL W 8 A VALUE ‘EROOT ‘
• Qualified SSAs
SSA-QUAL W 27 A +
VALUE ‘EROOT (ESTAFNO > 10000)

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 108/114
DLI Functions
• Four character field
• Specifies the operation to be performed
• GU, GN, GNP, GHU, GHN, GHNP,
ISRT, REPL, DLET
• G indicates ‘GET’
• H indicates ‘HOLD’- is used in either updating
or Deleting the segment.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 109/114
DLI statement
• Provides controlled I/O of an IMS database.
• Anywhere in the JOB
• Complete control over the creation and
maintenance of a database.
• Syntax :-
DLI file-name record-name ‘dli-function’
[SSANO field-name] SSA ssa-name
– file-name identifies the database to be processed

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 110/114
DLI statement(Contd.)
• Example -
DLI HISDB EROOT ‘GU’ SSA (SSA-QUAL)
In library section-
SSA-QUAL W 27 A VALUE ‘EROOT (ES -
TAFNO = ‘)
SSA-ROOT-KEY SSA-QUAL +19 7 A
SSA-END SSA-QUAL +27 1 A VALUE ‘)’

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 111/114
RETRIEVE Statement
•Immediately following the JOB statement
•Describe automatic database input.
•Only one RETRIEVE Statement in JOB activity
•Syntax:-
RETRIEVE file-name
SELECT (record-name [SSA ssa-name] +
[ LIMIT ‘literal’] +
[ WHILE (condition) ]…)

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 112/114
RETRIEVE Statement
• Example :
JOB INPUT JDB
RETRIEVE JDB SELECT JROOT +
WHILE ( A-DATABASE = ‘NPDH006’ +
AND A-SEGMENT = ‘EROOT’)

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 113/114
Handling Status code
• Two character field
• spaces - Successful retrieval
• GE- Segment not found
• GB- End of Database
• GA- Current position goes up one or more level
• GP - Issuing GNP without establishing
parentage.

Rel. Dt: 07 Jun, 1999 C014 Easytrieve Version 1.00 Slide: 114/114

You might also like