Professional Documents
Culture Documents
Objective:To provide an insight into EASYTRIEVE PLUS and its utilization in Database Management Systems.
Slide: 1/114
Course Details
No: Name C014 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# 1 2 3 4 5 6 7 8 9 Topic Introduction Library Section Activity Section Error Messages Easytrieve with IMS Easytrieve with DB2 Time(hrs) 1 1 2 0.5 1 2
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.
Slide: 5/114
Modules
Duration : 8 Hrs
Introduction Library Section Activity section Error Messages Dealing with DB2 Dealing with IMS
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
Slide: 7/114
Slide: 8/114
Slide: 10/114
Slide: 11/114
Module 1- Introduction
Duration : 1 hours Introduction to Easytrieve Plus Capabilities : File Processing Operations Output
Program Structure
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.
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
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.
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.
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.
Slide: 21/114
Continuation
Can continue lines in a statement to the next line using + or - character. Eg Field name W 8 A + VALUE ABCDEF. 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 variableVAR1 W 1 4 N VALUE THIS IS ST RING What are the activities in the Activity section?
Slide: 23/114
Quiz Answers
THIS IS ST RING JOB and SORT
Slide: 24/114
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
IS
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.
Slide: 29/114
Slide: 30/114
A - Alphabetic
A - Alphabetic. Use when none of the numeric data types apply to this field. Example: Name 17 6 A
Slide: 31/114
N - Zoned Decimal
N - zoned decimal. The field contains digits 0 thru 9 in external decimal form. Example: Date-Of-Hire SALARY
136 6 N 1 4 N 2
Slide: 32/114
P - Packed
Packed. Example: Pay-Gross
94 4 P 2
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 FILE EMP-FILE EMP-REC 1 EMP-ID 1 EMP-NAME 5 SALARY 30 PERKS 35 Length 40 5 25 5 5 P B A N A 2 0 TYPE DEC
EMPEMP-
Slide: 35/114
16 8 4 3
A A P2 N
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 CURR-DATE W CURR-MM CURR-DATE CURR-DD CURR -DATE + 2 CURR-YY CURR-DATE + 4 4 8 2 2 4 P2 N N N N
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 variableWS-VAR1(20)
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 variableINDX = (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
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 WS-CFLAG
Rel. Dt: 07 Jun, 1999
W W
Slide: 43/114
Slide: 44/114
Slide: 45/114
Examples
ONE W 4 B VALUE 1 WS-TEST-MODE-FLAG W 1 A W 36 A WS-NPGDATE-AREA WS-NPGDATE WS-NPGDATE-AREA 6 N W 6 N WS-DATE1 WS-DD1 WS-DATE1 2 N WS-MM1 WS-DATE1 +2 2 N WS-YY1 WS-DATE1 +4 2 N W 4 N MASK ('ZZZZ') WS-STOREYYMM W 25 A OCCURS 5 WS-APPLIT
Slide: 46/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
Slide: 48/114
Job Stmt.
Identifies the files whose Records are automatically provided JOB INPUT(FILE-NAME [KEY(FIELD-NAME)] [NAME Job-name]
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
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]
Slide: 52/114
Report
REPORT is the first stmt of the report declaratives. Parameters: Format Determination File Directing Spacing Control Testing Aids
Slide: 53/114
Report(Cond.)
REPORT report-name + [Summary] LABELS ([ACROSS literal-1] + [DOWN literal-2] + [SIZE literal-3] + [NEWPAGE] File [PRINTER file-name]
Format Determination
Directing
Slide: 54/114
Report(Contd.)
[PAGESIZE literal-4] + [LINESIZE literal-5] + [SPREAD] + [NOSPREAD] [LIMIT literal-6] + [EVERY literal-7]
Spacing Control
Testing Aids
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.
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.
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
Slide: 60/114
Perform Stmt
PERFORM procedure/para name PERFORM statement cause a branch to another location in the program.
Slide: 61/114
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
Slide: 63/114
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
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
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
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.
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.
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.
Slide: 74/114
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.
Slide: 79/114
Exercise 1
Which file is retrieved in the following cases?
FILE FILE1 VAR1 1 10 VAR2 11 2 FILE FILE2 VAR3 1 10 VAR4 11 2 (1) JOB INPUT VAR1 A (2) JOB N SORT FILE1 TO FILE2 + USING (VAR2) (3) JOB A (4) JOB INPUT NULL N
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)
Slide: 81/114
Slide: 82/114
Error Types
Easytreive Plus provides a comprehensive set of diagnostic messages which fall into 2 categories Operational Errors & Pgm Syntax Errors
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
Slide: 84/114
Slide: 85/114
Slide: 86/114
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
Slide: 89/114
Cursor-Processing(Contd.)
Declare the Cursor Declared in Library section asSQL 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 asSQL OPEN <cursor-name> Example : SQL OPEN EMPCURSOR
Slide: 91/114
Cursor-Processing(Contd.)
Fetch the Cursor Coded in Activity Section asSQL FETCH <cursor-name> INTO :<hostvariables> 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 asSQL CLOSE <cursor-name> Example : SQL CLOSE EMPCURSOR
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 PlusActivity 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?
Slide: 98/114
Quiz - Answers
1. DSNTIAR. 2. Activity section 3. No declaration for SQLCA
Slide: 99/114
Slide: 101/114
o c 2L
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 SURNAME 8 20 INITIALS 48 4 DEPT 138 6
N A A A
Slide: 106/114
Record Formats
F = Fixed unblocked V = Variable unblocked U = undefined FB= Fixed blocked VB= Variable Blocked VSS = variable blocked spanned.
Slide: 107/114
SSA
Segment Search Argument Unqualified SSAs Qualified SSAs Unqualified SSASSA-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.
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
Slide: 110/114
DLI statement(Contd.)
Example DLI HISDB EROOT GU SSA (SSA-QUAL) In library sectionSSA-QUAL W 27 A VALUE EROOT (ES TAFNO = ) SSA-ROOT-KEY SSA-QUAL +19 7 A SSA-END SSA-QUAL +27 1 A VALUE )
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)
Slide: 113/114
Slide: 114/114