Upload
deepak-dada
View
6
Download
0
Tags:
Embed Size (px)
DESCRIPTION
eazytrieve
Citation preview
TABLE OF CONTENTS Introduction to Easytrieve Capabilities Structure of Easytrieve program Environment Definition Data Definition Processing Activities Decision and Branching Logic Input & Output Specification Report Processing Table Processing Synchronized File Processing
INTRODUCTION
Easytrieve is an information retrieval and data management tool designed to simplify computer programming and to perform complex programming tasks.
CAPABILITIES
Easytrieve has all the capabilities of a standard retrieval system as well as the comprehensiveness and flexibility required for complex reports, data extraction and file maintenance requirements.
CAPABILITIES
File Access
Accepts any number of input files Processes QSAM, ISAM, VSAM , IMS/DLI files, IDMS &
SQL Synchronizes file processing Processes data in alphabetic, numeric, packed,
packed-unsigned or binary format Provides flexible edit masks Provides default report headings Allows multiple use of field definitions with COPY
keyword
CAPABILITIES
Logic Process
Provides standard programming constructions
Provides powerful calculation capabilities
Performs special tests useful in editing
Supports Move for corresponding fields
Includes special start & finish procedures
Sorts on any number of keys
CAPABILITIES
Report Output
Automatic formatting of reports & customizing optionsProvides Control breaks on any number of keysAutomatically creates summary file for subtotalsProcesses only fields that are required for REPORTAllows explicit positioning of print layout for pre-
printed forms
MODES OF OPERATION
Easytrieve provides five modes of operation that facilitate production as well as ad-hoc programming.
Syntax check source statementsSyntax check and compile source statementsSyntax check, compile and execute source
statements (Default)Syntax check and compile source statements
and produce an object moduleExecute previously link edited programs
STRUCTURE OF PROGRAM
Environment section PARM (parameters)(Optional)
Library section FILE (parameters)(Optional if no files) DEFINE fields
Activity section (s) PROGRAM (statements)JOB (Statements) (Job procedures)SORT (Sort procedures)SCREEN (statements)
SAMPLE PROGRAMFILE PERSNL FB(150 1800)
EMP# 9 5 N NAME 17 8 A GROSS 94 4 P 2
DEPT 98 3 N
JOB INPUT PERSNL NAME FIRST-PROGRAMPRINT PAY-RPT
REPORT PAY-RPT LINESIZE 80TITLE 01 ‘PERSONNEL REPORT EXAMPLE-1’LINE 01 DEPT NAME EMP# GROSS
SAMPLE REPORT
30/06/02 PERSONNEL REPORT EXAMPLE-1 PAGE 1
DEPT NAME EMP# GROSS903 WIMN 12267 373.60943 BERG 11473 759.20915 CORNING 02688 146.16935 NAGLE 00370 554.40911 ARNOLD 01963 445.50914 MANHART 11602 344.80917 TALL 11931 492.26918 BRANDOW 02200 804.64911 LARSON 11357 283.92932 BYER 11467 396.68921 HUSS 11376 360.80911 POWELL 11710 243.20943 MCMAHON 04234 386.40
ENVIRONMENT DEFINITION
PARM Statement:SYNTAX - Terminates Easytrieve processing after completion of the syntax check operation. Allows early checkout of program before data files necessary for execution are available.COMPILE - Terminates Easytrieve processing after completion of the syntax check and compile operations.
If PARM statement is not used, the default is syntax check, compile and execute.
An eg. PARM LINK (pgmname R) + ABEXIT (SNAP) + DEBUG (DMAP) +
XREF (LONG) + LIST (PARM)
ENVIRONMENT DEFINITION
PARM statement customizes the operating environment for the duration of a program’s compilation & executionPARM establishes program level parameters in the following areas :
SYNTAX, COMPILE, LINK determine the mode of execution
BIND, PLAN, PREPNAME, SQLID, SSID and USERID establish parameters for SQL execution
DATA / LIBRARY DEFINITION
FILE StatementAll files and databases that the program references must be defined using the FILE statement.
FILE filename File Type => [IS/ VIRTUAL/ DLI/
VS ([ES] [CREATE [RESET]/ UPDATE] Device Type => [CARD/PUNCH/PRINTER/DISK/TAPE] Record Format => [F/V/U/FB/VB/VBS]
DATA / LIBRARY DEFINITION
DEFINE StatementFields are defined in the library using DEFINE statement. Two categories of data can be defined :1. File data2. Working Storage dataField names must be unique within a file or working storage. The keyword DEFINE is optional within Library section
DATA / LIBRARY DEFINITION
Basic syntax of DEFINE statement is as follows :
DEFINE field-name Location Length S/W DataFormat [MASK ( [letter] [BWZ] [lit-4])] [VALUE lit-5]
Location - specifies the location of the field’s leftmost byte
Length - specifies the length of the fieldS/W - specifies the storage of the fieldDataFormat - specifies data format(A/N/P/B/U)MASK - Optional parameter specifying pattern edit
mask for printing numeric fields on a report. letter-identifier for a mask specified with lit-4
BWZ - Blank When Zerolit-4 - print edit mask (9/Z/*/-/$/X)VALUE - To initialize working storage fields to
specific values
PROCESSING ACTIVITIES The activity definition section of the program contains the statements that perform the tasks of reading in, processing and writing out data. Four processing activities – PROGRAM, JOB, SORT and SCREEN.
PROGRAM is a simple top-down set of instructions which is used to initiate other activities. JOB activities read data from input files, examine and manipulate this data and write data to output files and initiate reports. SORT activities sequence the files in the order specified by parameters of this statement. SCREEN activities define screen-oriented transactions.
PROGRAM ACTIVITY
Program identifies and initiates a processing activity
PROGRAM NAME program-name [ activity ] [USING field-name1 GIVING field-name2]
Program-name - names the processing activityActivity - activity which is initiated by the programField-name1 - field to which parameter is passed from
parent programField-name2 - field containing the parameter you return to
the parent program
PROCEDURES
ProcsSeparate modules of program code used to perform specific tasksDefined at the end of each activityLocal to the activity after which they are coded
JOB STATEMENTJOB statement identifies the files whose records are automatically provided to the program (automatic input)JOB [INPUT {file-name KEY(field-name)}…{NULL}] [START start-proc-name] [FINISH finish-proc-name] [NAME job-name] INPUT file-name - Optional parameter identifying automatic input - provides the name of the file used in automatic input KEY field-name - identifies fields used in synchronized file processing NULL - inhibits automatic input. Normally, a job is implicitly stopped when the automatic file is exhausted. With NULL, the program continues until a STOP statement is executed.
JOB STATEMENT JOB statement identifies the files whose records are automatically provided to the program (automatic input)JOB [INPUT {file-name KEY(field-name)}…{NULL}] [START start-proc-name] [FINISH finish-proc-name] [NAME job-name] START - The optional START start-proc-name parameter
identifies a procedure to be executed during the initiation of the JOB. FINISH - The optional FINISH finish-proc-name parameter
identifies a procedure to be executed during the normal termination of the JOB. NAME job-name - names the JOB activity.Used for documentation only.
JOB CONTROL FLOWReset working storageOpen I/O files[PERFORM start-proc] Step 1JOB …retrieve automatic input
IF EOF . . . Logic generated by JOBreset working storagecloses I/O files[PERFORM finish-proc]wrap-up REPORTSgo to the next JOB/SORT activityEND-IF
IF …. Step 2. . . Data examination and END-IF Manipulation statements
SORT STATEMENTSORT 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]file-name-1 - name of the input file to be sortedfile-name-2 - name of the sorted output file (can be the same as file-name-1 except in case of VSAM and ISAM)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 F 150 VIRTUAL *SORT PERSNL + TO SORTER + USING EMP# + BEFORE INCLUDE-RECS* INCLUDE-RECS. PROC IF GROSS LT 29999 SELECT END-IF END-PROC*
SCREEN PROCESSINGThe SCREEN statement defines and initiates a SCREEN activity. A SCREEN
activity defines a transaction-oriented processing activity under the control of keys pressed by the terminal operator. Statements can also be inserted in screen procedures to retrieve and maintain files and databases.
SCREEN NAME screen-name [UPPERCASE ROWCOUNT rows LINESIZE columns]
Screen-name - name of the screen. For documentation.Rows - number of rows to be displayed on the screen
Columns - number of columns on a lineStructure of SCREEN statement
SCREEN statement Screen declaration statements
KEYs, TITLEs, ROWs (in any order) Screen procedures (both special-named and user-defined, in
any order)
SAMPLE SCREEN
DEFINE WS-REPLY W 1 A SCREEN NAME MAIN-MENU TITLE 'Employee File Main Menu' ROW 6 COL 10 'Type an option, then press Enter.' ROW 8 COL 10 'Option ===>' WS-REPLY VALUE ('V' 'E' 'D' 'X')
+ ERROR 'Please type V, E, D, or X' ROW 10 COL 22 'V View employee' ROW 11 COL 22 'E Edit employee' ROW 12 COL 22 'D Delete employee' ROW 13 COL 22 'X Exit' KEY F1 NAME 'Help' IMMEDIATE KEY F3 NAME 'Exit' EXIT KEY F12 NAME 'Cancel' EXIT IMMEDIATE
|------------------------------------------------------------------------------------------------------------------------------------------------|| Employee File Main Menu |
| Type an option, then press Enter. |
| || Option ===> |
| V View employee |
| E Edit employee |
| D Delete employee |
| X Exit || || F1=Help F3=Exit F12=Cancel ||------------------------------------------------------------------------------------------------------------------------------------------------|
DECISION & BRANCHING LOGIC
IF condition statements
ELSE-IF (optional) statements ELSE (optional) statements END-IF
DO WHILE / DO UNTIL conditionstatements
ENDDO
DECISION & BRANCHING LOGIC
CASE field-name WHEN condition
statements OTHERWISE condition
statementsEND-CASE
GOTO {label/JOB}
PERFORM proc-name
EXECUTE job-name|sort-name|screen-name STOP [EXECUTE]
INPUT / OUTPUT SPECIFICATON
Automatic I/O provides sequential reading of a data file and production of one or more reports. Statements supporting this level are
JOB - specifies the input file DISPLAY - produces printed o/p not directly supported by reports
PRINT - initiates report outputControlled I/O provides the capability to process any sequential or keyed file (ISAM/VSAM). Controlled I/O statements are
GET - sequentially reads one record POINT - positions to a particular record for subsequent sequential
I/O PUT - sequentially writes one record READ - reads one keyed record
WRITE - rewrites, adds or deletes one keyed recordDatabase I/O provides access to IMS, DB2 and IDMS databases.
DISPLAY STATEMENT
DISPLAY [file-name] [{TITLE|NOTITLE} / SKIP lit-1 / CONTROL lit-2]
[lit-3 / field-name / +lit-4 / - lit-4/ COL lit-5]
file-name - Optional parameter specifying destination of the DISPLAYED data. The
named file should be designated as a PRINTER file. The default is
SYSPRINT.lit-3/field name - Specify the data to be printed+lit-4 / -lit-4 - Adjustment of horizontal spacing
between displayed itemsCOL lit-5 - Specifies precisely where data is placed
on the print line
PRINT STATEMENT
PRINT report-name
PRINT statement initiates report output by causing the named report to extract the current values of the fields to be output and to format them according to the specifications in the report declaratives. The next statement to be executed after the PRINT statement is the associated REPORT statement.
GET & PUT STATEMENTS
GET statement makes the next or previous sequential record of the named file available for processing.
GET file-name [PRIOR]
PUT outputs records to SEQUENTIAL files and also adds consecutive records to an INDEXED or RELATIVE file.
PUT file-name-1 [from file-name-2]
POINT STATEMENT
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.
POINT file-name {EQ/=/GE/>=} {field-name/literal}
POINT statement only locates the specified position of the record in the file. GET statement is necessary to retrieve the data for processing.
POINT STATEMENT EXAMPLE
FILE PAYFILE VS REC-KEY 1 3 NJOB INPUT NULL POINT PAYFILE GE 500 GET PAYFILE DO WHILE (REC-KEY < 600 AND NOT EOF
PAYFILE) PRINT PAY-RPT GET PAYFILE ENDDO STOPREPORT PAY-RPT …Above statements retrieve those records with keys
between 500 and 599 inclusive from file PAY-FILE and output them to report PAY-RPT.
READ STATEMENT
READ statement provides random access to keyed and relative-record VSAM and ISAM files.
READ file-name KEY field-name [STATUS]file-name - identifies the file you wish to accessKEY field-name - search value to identify the specific
record to be retrieved.STATUS - 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.
WRITE STATEMENT
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.WRITE file-name-1 [DELETE / UPDATE / ADD] [FROM
file-name-2]
file-name-1 - Name of the file to be modified
DELETE / UPDATE / ADD - Specify the activity to be performed. Required
for deleting or adding records and optional for update activity. Default is
UPDATE if the parameter is not coded.
FROM file-name-2 - WRITE copies the current record of file-name-2 to
file-name-1 for either an UPDATE or an ADD operation. This parameter
is invalid for DELETE operation.
READ / WRITE EXAMPLE
FILE PAYFILE VS UPDATE EMPL# 1 5 N NAME 6 20 AJOB INPUT NULL EMPL# = 44152 READ PAYFILE KEY EMPL# STATUS IF FILE-STATUS NOT ZERO GOTO ERRTASK END-IF IF NAME EQ ‘OLDNAME’ NAME EQ ‘NEWNAME’ WRITE PAYFILE UPDATE END-IF STOP
REPORT PROCESSING
Reports are defined by the following set of statements
REPORT SEQUENCE CONTROL TITLE HEADING LINE report procedures BEFORE-BREAK TERMINATION
SAMPLE PROGRAM REPORT
DECLARATIVESREPORT UPD-RPT PAGESIZE 51 LINESIZE 63 NODATE NOPAGE SEQUENCE DEPT LAST-NAME CONTROL DEPT TITLE 1 ‘ANNUAL UPDATE REPORT - SALARIED EMPLOYEES’ HEADING LAST-NAME ‘NAME’ HEADING SERVICE ‘SERV’ LINE DEPT LAST-NAME SERVICE RAISE SALARY
The above report is ordered by department number and within each department, by last-name. The report is segmented by department, the dollar values are subtotalled for each department. There are 5 columns spaced three characters apart across the 63-character-wide report.
REPORT TYPES
Standard format - Default format consisting of Title area, Heading area and Report Body.
PAGESIZE
Label Format - Includes mailing labels, form-letters and other special-purpose reports.
SIZE DOWN
TITLE AREAHEADING AREA
REPORT BODY
LINESIZE
LINESIZE
REPORT STATEMENT
REPORT report-name + [SUMMARY] + Format Determination Parameters
[SUMFILE sum-file-name] + [LABELS ([ACROSS lit-1] + Label Parameters [DOWN lit-2] +
[SIZE lit-3] + [NEWPAGE]] + [PRINTER file-name] + File Directing Parameters
[PAGESIZE lit-4] + Spacing control Parameters [LINESIZE lit-5] + [SPREAD] + [NOSPREAD] +
[NOADJUST] + [NODATE] +
[NOPAGE] + [LIMIT lit-6] + Testing aids Parameters [EVERY lit-7]
REPORT STATEMENT
report-name - Names the reportSUMMARY - Inhibits printing of detail data on control reports. Only
quantitative fields are totaled (those defined with decimal positions)SUMFILE sum-file-name - SUMFILE is used to generate a summary
file that contains the control and summary field values. Summary-file-name identifies the file to contain the summary data.
LABELS - ACROSS specifies the number of labels printed side-by-side across the page, DOWN specifies the number of print lines on each label, SIZE specifies the width of each label and NEWPAGE prints first line of each label at the top of a page.
PRINTER file-name - Identifies a file-name other than the default print destination
REPORT STATEMENT PAGESIZE - sets the number of print lines per pageLINESIZE - sets the number of print columns on each report lineSPREAD/NOSPREAD - Adjusts column spacing on the report.SPREAD
maximizes number of spaces between columns. NOSPREAD, the default, puts three spaces between columns and centers the report.
NOADJUST - Left justifies the report. Centering is the default.NODATE - Suppresses printing of date in the leftmost 8 columns of the
report titleNOPAGE - Suppresses printing of characters PAGE and the page
number in the rightmost 11 columns of the report titleLIMIT - Specifies the number of print statements accepted for this report.
Used in TestingEVERY - Specifies the occurrence value for processing every nth Print
command directed to the report
SEQUENCE STATEMENT
SEQUENCE field-name-1 [D] [,field-name-2 [D]] ...
Specifies the order in which the fields on the report should be ordered.
Inclusion of ‘D’ indicates the field is sequenced in descending order,
default is ascending order.
CONTROL STATEMENT
CONTROL [field-name FINAL] [NEWPAGE/RENUM] [NOPRINT]
Specifies the field name(s) on which the report should be controlled.
FINAL parameter is coded to specify options for the control break which occurs at end-of-report.
Following options alter the normal control break processing.NEWPAGE - causes a skip to the top of the next page after control
break processing for the specified field is completed.RENUM - causes a skip to the top of the next page and resets the
page number to 1 on the page following the control break. NOPRINT - suppresses printing the summary line for the specified
control break.
TITLE STATEMENT
TITLE [lit-1] {field-name, ‘lit-2’, +lit-3/-lit-3/COL lit-4}
Each title line is centered horizontally within the title area of the report. Current date is printed in leftmost 8 positions unless NODATE option is
specified on the REPORT statement.The word PAGE and page number are printed in rightmost 11 positions
unless NOPAGE option is specified on the REPORT statement.lit-1 - Specifies the position of the title line within the title area.field-name- Specifies that the contents of the named field will appear on
the title line.‘lit-2’ - Specifies a character string (enclosed in quotes) for the title item. +lit-3 / -lit-3 - Specifies the no. of characters to be added/subtracted from
the normal 3 character space between items.COL lit-4 - Specifies the column number where the 1st character of the
next title item will be printed
HEADING STATEMENT
HEADING field-name (‘literal’...)
Optionally defines an alternate column heading to be printed in place of the specified field-name.
field-name - Specifies the name of a field coded on the LINE statement. The value of the literal is the content of the new heading.
Eg. HEADING LAST-NAME ‘NAME’
Multiple literals within parentheses are stacked vertically over the column when printed.
Eg. HEADING LAST-NAME (‘EMPLOYEE’, ‘NAME’) produces EMPLOYEE NAME
LINE STATEMENT
LINE [lit-1] {field-name, ‘lit-2’, +lit-3/-lit-3/COL lit-4/POS lit-5} LINE statement defines the contents of the lines of the report.lit-1 - Specifies the position of the line within the line group when there are
multiple lines. field-name- Specifies that the contents of the named field will appear on the
print line.‘lit-2’ - Specifies a character string (enclosed in quotes) for the line item. +lit-3 / -lit-3 - Specifies the no. of characters to be added/subtracted from the
normal 3 character space between items.COL lit-4 - Specifies the column number where the 1st character of the next
line item will be printedPOS lit-5 - Enables to position items on lines 2 thru 99 so that they line up
under specified items on line 1. lit-5 specifies the item number on line 1 under which the item is to be placed.
LINE STATEMENT EXAMPLE.
LINE 1 REGION + SSN + NAME + DOBLINE 2 POS 2 PHONE + POS 3 STREET + POS 4 DATE-OF-HIRELINE 3 POS 3 CITY -2 STATE -2 ZIP
Line 2 lists phone number under Social Security number, street address under name and date-of-hire under Date Of Birth. Line 3 lists the city, state and zip under Name and street address
o/p : SOUTHWEST 571-40-8057 Florance Smith 11-26-72 785-4815 3250 Big street 08-03-81 Riverside CA 09265
TABLE PROCESSING
A table is a collection of uniform data records. Tables have two parts :
1. The argument uniquely identifies a table entry. 2. The description is information directly associated with the
argument. Tables are defined by FILE statements in the library section.
TABLE option must be coded. FILE file-name TABLE [INSTREAM / literal] The only fields defined for TABLE files are ARG (argument)
and DESC (description). ARG defines the field used to search the table. DESC defines the field which contains the desired
information.
TABLE PROCESSING
There are two types of TABLEs, instream and external.
Instream Tables reside within your program, they are established for use when the program is compiled. Instream table data is coded immediately following the FILE statement. The word ENDTABLE indicates end of table data.
External Tables are stored on files external to the program, they are established for use during initiation of the JOB activity that contains the SEARCH statement which references them.
INSTREAM TABLE EXAMPLE
FILE WEEKDAY TABLE INSTREAM ARG 1 1 A DESC 3 9 A1 SUNDAY2 MONDAY3 TUESDAY4 WEDNESDAY5 THURSDAY6 FRIDAY7 SATURDAYENDTABLE
SEARCH STATEMENT
SEARCH statement is used to access table information.SEARCH file-name WITH field-name-1 GIVING field-name-2
file-name - name of the file which describes the table and its source.
WITH field-name-1 - This parameter identifies the field that contains the search argument. Field-name-1 can be defined in Working storage or in any file except a file with TABLE attribute.
GIVING field-name-2 - This parameter identifies the receiving field for the results of the table search. This field can be defined in Working storage or in any file except a file with TABLE attribute
TABLE SEARCH OPERATION
FILE CALENDAR DAY-OF-WEEK 12 1 A NAME-OF-DAY 14 20 AFILE WEEKDAY TABLE INSTREAM ARG 1 1 A DESC 3 9 A1 SUNDAY2 MONDAY3 TUESDAY4 WEDNESDAY5 THURSDAY6 FRIDAY7 SATURDAYENDTABLEJOB INPUT CALENDAR SEARCH WEEKDAY WITH DAY-OF-WEEK GIVING NAME-OF-DAY IF WEEKDAY DISPLAY NAME-OF-DAY, ‘IS DAY’, DAY-OF-WEEK ELSE DISPLAY ‘****INVALID DAY OF WEEK = ’, DAY-OF-WEEK END-IF
SYNCHRONIZED FILE PROCESSING
Easytrieve simplifies combining data from more than one file.
Has the capacity to synchronize any number of files which can be processed sequentially.
SYNCHRONIZED FILE
PROCESSING EG.FILE PERSNL FB(150 1800)
OLD-EMP# 9 5 N *FILE PERSUPD EMP# 1 5 N RAISE-PERCENT 7 2 N*FILE SORTPER F 150 VIRTUAL UPD-EMP# 9 5 N NAME 17 8 A PAY-GROSS 94 4 P 2*
NEWSAL W 4 P 2*FILE NEWPERS FB(150 1800)*FILE ERRPRINT PRINTER*
SYNCHRONIZED FILE
PROCESSING EG.SORT PERSNL TO SORTPER USING OLD-EMP#
JOB INPUT (SORTPER KEY(UPD-EMP#) PERSUPD KEY (EMP#) )
IF MATCHED NEWSAL = PAY-GROSS * (1 + RAISE-PERCENT /100) PRINT NEW-RPT PAY-GROSS = NEW-SALEND-IFIF SORTPER PUT NEWPERS FROM SORTPERELSE DISPLAY ERRPRINT EMP# ‘RECORD NOT MATCHED’END-IFREPORT NEW-RPT LINESIZE 80 NOPAGE NODATE SEQUENCE NAME TITLE ‘SALARY UPDATE REPORT’ LINE UPD-EMP# NAME PAY-GROSS NEWSAL RAISE-PERCENTEND