You are on page 1of 112

Basic Eztrieve Plus

Introduction

•EZTRIEVE PLUS is an information retrieval and data management


system designed to simplify computer programming.
It’s English like language and simple declarative statements provide
the tools to produce comprehensive reports with ease while it’s
enhanced. facilities provide the capability to perform complex
programming tasks.

IN OTHER TERMS
“ EASYTRIEVE PLUS is user-friendly, allowing you to
retrieve and manage data using simple, English-like
statements. It can both process data and create
formatted reports without resort to complicated
programming languages.”
Capabilities
Operations

• Performs computations through user logic, including


percentages, averages and others

• Sorts on any number of keys


EZTRIEVE does not have it’s own sort. It exits to the sort installed at
the facility it’s running on e.g. SYNCSORT.

• Calls programs and subroutines written in other languages and


integrates them into the job
Output

• Outputs any number of files or reports on one pass of the input


file

• Formats output with all totals calculated internally

• Provides summary reports and output files with no limits on the


number & size of control fields

• Allows page and line sizes to vary as needed by overriding


default values
Structure
Program Structure

Generally an Eztrieve Programs contains 3 Parts

• Environment Definition

• Library Section

• Activity Definition
Environment Section

• Optional

• If used, must be first section and includes only one statement (PARM)

• The Environment Section allows user to override system default.


It is seldom used.

• Eg :- PARM ABEXIT SNAP DEBUG (PMAP DMAP FLOW)


Library Section

• Also called Data Definition Section

• Describes data fields and usually necessary for file processing and
report generation

• Contains file and field definitions as well as working storage fields


Activity Definition

Contains the Program logic

• JOB statement

• SORT statement

• PROC/END-PROC statements

• REPORT statements
Sample Program – A First Look

FILE INFILE VS
NAME 1 30 A
CITY 31 15 A
STATE 46 2 A
ZIP 48 5 N

JOB
PRINT RPT1

REPORT RPT1
TITLE ‘CSC FSG’
TITLE 2 ‘BASIC EZTRIEVE TRAINING’
TITLE 3 ‘SAMPLE REPORT TITLES’
LINE NAME CITY STATE ZIP
Syntax
Field Definition

DEFINE <fieldname> <startpos> <length> <type> <decimals>

• keyword DEFINE is optional


Field Definition Contd.

Field Definition - <fieldname>

DEFINE fieldname startpos length type decimals

• fieldname can be 1 - 40 characters


• must begin with alphabetic character (A-Z)
• other positions can be alphabetic (A-Z), numeric (0-9)
• Can contain dashes (-) to separate “words”

Sample fieldname
FLDA
POLICY-NUMBER
POLICY-NUMBER-X
BENEFICIARY-1
BENEFICIARY1
Field Definition Contd.

Field Definition – <startpos>

DEFINE fieldname startpos length type decimals

• startpos is the actual position in the record where the field begins
• can use ‘*’ to specify that one field immediately follows another

Sample <startpos>
FIELD-A 1 10 A
FIELD-B 11 6 N
FIELD-C * 2 A
FIELD-D 45 4 P 2
Field Definition Contd.

Field Definition – <length>

DEFINE fieldname startpos length type decimals

• length is the number of bytes (positions) required to store the field


• a 7-byte numeric field which is packed has a length of 4, not 7

Sample length

FIELD-A 1 10 A
FIELD-B 11 6 N
FIELD-C * 2 A
FIELD-D 45 4 P 2
Field Definition Contd.

Field Definition - <type>

DEFINE fieldname startpos length type decimals

• type determines the format of the field and what kind of data it can
hold

Sample type
FIELD-A 1 10 A
FIELD-B 11 6 N
FIELD-C * 2 A
FIELD-D 45 4 P 2
Field Definition Contd.

Field Types
• ‘A’ - Alphanumeric
• ‘N’ - Numeric, Zoned Decimal
– (x’F1F2F3F4F5’)
• ‘P’ - Numeric, Packed Decimal
– (x’12345F’)
• ‘U’ - Numeric, Unsigned Packed Decimal
– (x’012345’)
• ‘B’ - Numeric, Signed Binary
– (x’3039’)
Field Definition Contd.

Field Definition - <decimals>

DEFINE fieldname startpos length type decimals

• decimals optionally defines the number of decimal positions required


for the field

• number of decimals available is determined by the field type


Field Definition Contd.

Field Definition - <decimals>

• numeric fields with decimal places are considered signed

• numeric fields without decimals assumes zero decimal places

Sample decimals

FIELD-A 1 10 A
FIELD-B 11 6 N 0
FIELD-C * 2 A
FIELD-D 45 4 P 2
Field Definition Contd.

Decimal Positions

Data Max Decimal


Type Lgth Positions
‘A’ 254 Not Valid
‘N’ 18 0 - 18
‘P’ 10 0 - 18
‘U’ 9 0 - 18
‘B’ 4 0 - 10
Field Definition Contd.

Library Section Review


FILE INFILE
DEFINE NAME 1 30 A
DEFINE CITY 31 15 A
DEFINE STATE 46 2 A
DEFINE ZIP 48 5 N

OR.....
FILE INFILE
NAME 1 30 A
CITY 31 15 A
STATE 46 2 A
ZIP 48 5 N
Working Storage Fields

• Used for fields not on a file record (i.e. calculated fields, indicators,
etc.)

• Defined with a DEFINE statement

• Same as other DEFINE statements except there is no starting


location. Code a literal ‘W’ instead to indicate the field is a work field
Working Storage Fields Contd..

• Usually coded after all file and record definitions and before the JOB
statement

Example:
GROSS-PAY W 6 P 2
INDICATOR1 W 1 A
Redefining Fields

Redefining Fields in a Record

• Specify another DEFINE statement with the appropriate starting


location, length and type.

EXAMPLE 1:
FULL-NAME 1 19 A
LAST-NAME 1 10 A
FIRST-NAME 11 8 A
MIDDLE-INIT 19 1 A
Redefining Fields Contd..

Redefining Working Storage Fields


• Refer back to the field being redefined since there’s no starting
location

EXAMPLE 1:
FULL-NAME W 19 A
LAST-NAME FULL-NAME 10 A
FIRST-NAME FULL-NAME +10 8 A
MIDDLE-INIT FULL-NAME +18 1 A

 In this case, LAST-NAME starts at the beginning of FULL-NAME.

• FIRST-NAME starts in the 11th byte of FULL-NAME (at a


displacement of +10 starting at zero).
Assigning Values to Fields

• Three ways to place a value in a field

– VALUE parameter of DEFINE statement


– Assignment in the JOB activity area
– MOVE statement in the JOB activity area
Assigning Values to Fields

VALUE parameter

• Initializes the contents of a field in working storage


• Added to the DEFINE statement
• Default value of alphanumeric field is space
• Default value of numeric field is zero
• Cannot be used on an overlay redefinition (redefinition by listing a
specific field) unless the original definition is an alphanumeric field
Assigning Values to Fields

VALUE parameter-cont’d

• If alphanumeric value, must be enclosed in single quotes

EXAMPLE:
NAME W 20 A VALUE ‘SMITH’
AMOUNT W 8 N VALUE 1000
Assigning Values to Fields

ASSIGNMENTS

• The assignment statement is a JOB activity which establishes a value


for a field

• Can be a copy of the data in another field, can be a literal, or can be


the result of an arithmetic operation

• The result is converted to the format of the receiving field

EXAMPLES
FIELD-A = FIELD-C
FIELD-A = ‘TRUCK’
WS-AMT = 123.45
NET-AMT = GROSS-AMT - PENALTIES
Assigning Values to Fields

Notes for ASSIGNMENT

• Alphabetic fields are left justified and padded with spaces, if necessary

• Truncation, if required, will occur to the rightmost characters

• Numeric fields are decimal aligned and padded with zeroes on either
side of the decimal as appropriate

• The value ‘EQ’ can be substituted for the equal sign (‘=‘)
Assigning Values to Fields

MOVE Statement

• ‘MOVE’ transfers character strings from one location to another

• This is always an alphanumeric move meaning the move will be done


left to right

• No format conversions performed

• Number of characters moved depends on the length of the shorter field

• Unless specified, no padding occurs

• Recommend using ASSIGNMENT (EQ) instead of MOVE when


possible
Assigning Values to Fields

Sample MOVE statements

MOVE FIELDA TO FIELDB


Before After
1) FIELDA ABC123 ABC123
FIELDB bbbbbb ABC123
2) FIELDA ABC12 ABC12
FIELDB XXXXXX ABC12X
3) FIELDA ABC12 ABC12
FIELDB XXXX ABC1
Assigning Values to Fields

Sample MOVE different formats

MOVE FIELDA TO FIELDB


Before After
1) FIELDA X’12345F’ X’12345F’
FIELDB X’F0F1F2’ X’12345F’
2) FIELDA X’123F’ X’123F’
FIELDB X’404040’ X’123F40’
3) FIELDA X’12345F’ X’12345F’
FIELDB X’1234’ X’1234’
Assigning Values to Fields

One More Sample - MOVE

MOVE ‘TRUCK’ TO FIELDB


Before After
FIELDB bbbbbb TRUCK

MOVE ‘CAR’ TO FIELDB


Before After
FIELDB TRUCK CARCK
Tables in EASYTRIEVE

• There are 2 types of tables available in EASYTRIEVE.


– Tables can be INSTREAM
– (Or) Tables can be EXTERNAL.

• Sample table INSTREAM:


FILE DAYTABL TABLE INSTREAM
ARG 1 1 A
DESC 5 10 A
1 MONDAY
2 TUESDAY
3 WEDNESDAY
ENDTABLE

• Sample table EXTERNAL:


FILE FILEB TABLE(1000)
ARG 1 14 A
DESC 21 75 A

Searching in TABLES.
Decision and Branching
Logic
Activity Definition

• This section is where the logic of the program is defined

• Simple programs which read a file and print a report won’t have much
in the activity section. In fact, there could only be ONE statement
required!
DECISION and BRANCHING LOGIC

IF / END-IF
• Controls the execution of associated statements which occur between
the IF and the END-IF statements
• END-IF is required for each IF

IF conditional-expression
statement(s)
END-IF
DECISION and BRANCHING LOGIC

IF / ELSE / END-IF
• Allows for the different processing when the conditional statement is
FALSE

IF conditional-expression
statement(s)
ELSE
statement(s)
END-IF
DECISION and BRANCHING LOGIC

More on the IF
• IF statements can be nested

• Each IF must have corresponding END-IF

• Recommend indentation of nested IF’s for readability

• Can use logical connectors “AND” or “OR”

• Break up of the IF statement with “AND” “OR” with “EQ” “NE” for
multiple value checking.
DECISION and BRANCHING LOGIC

Embedded “IF” Example

IF condition1
IF condition2
statement(s)
ELSE
statement(s)
END-IF
END-IF
DECISION and BRANCHING LOGIC

DO WHILE / END-DO

• Allows for automated looping

• DO must have corresponding END-DO

• The statements following the DO WHILE are executed when the


condition is TRUE

• DO Whiles can be nested

DO WHILE conditional-expression
statement(s)
END-DO
DECISION and BRANCHING LOGIC

Conditional Expressions

• Used as parameters of the IF and DO WHILE statements

• Offer an alternative to normal top-to-bottom execution

• Evaluated by asking “Is this condition TRUE?”


DECISION and BRANCHING LOGIC

Common Condition types

• Field Relation Condition

• Field Series Condition

• Field Class Condition

• File Presence Condition (not covered in this class)


DECISION and BRANCHING LOGIC

Field Relation Condition

• Compares the value of a field to the value of another field, literal or


arithmetic expression

• The two values are separated by an operator

• Alphanumeric literals must be enclosed in apostrophes.


DECISION and BRANCHING LOGIC

Field Relation Examples

IF FIELD-A = FIELD-B

IF PAY-TYPE = ‘HOURLY’

IF HOURS-WORKED > 40

IF TOTAL-COMM-AMT < (COMM-AMT * .5)

• Remember, each IF must end with an END-IF


DECISION and BRANCHING LOGIC

Valid Relational Operators

Operator Values
Equal = EQ
Not Equal ^= NE NQ
Less Than < LT LS
Less Than or Equal <= LE LQ ^<
Greater Than > GT GR
Greater Than or Equal >= GE GQ ^<

• As always, be careful when using AND or OR with negative


operators (i.e. NE)
DECISION and BRANCHING LOGIC

Field Series Conditions


• Compares a field and a series of values
• Subject field is compared to a range of values
• Alphanumeric comparisons are made bit-by-bit, left-to-right
• Only EQUAL and NOT EQUAL operators can be used in a Field
Series comparison
DECISION and BRANCHING LOGIC

Field Series Examples

IF HOURS-WORKED = 1 THRU 40

IF DEPARTMENT = ‘AA’ THRU ‘BC’

IF COMPANY-CODE = ‘XXX’ ‘YYY’

IF GROSS-PAY = 1.00 THRU MAX-FOR-BONUS


DECISION and BRANCHING LOGIC

Field Class Condition

• Used to determine whether ALL positions of a field contain alphabetic,


numeric, space or zero characters
DECISION and BRANCHING LOGIC

Field Class Example - NUMERIC

IF HOURS-WORKED NUMERIC

• The field is tested for digits 0 through 9 in the correct format for the
field’s defined type (i.e. alphanumeric, numeric, packed, etc.)

• In the case of data types N and P, the low-order position is tested for
a valid sign
DECISION and BRANCHING LOGIC

Field Class Example - ZERO

IF HOURS-WORKED ZERO

• ZERO, ZEROS or ZEROES valid

• Field is tested for a zero character in the correct format for the field’s
definition (same as NUMERIC check)
DECISION and BRANCHING LOGIC

Field Class Example - ALPHABETIC

IF FIRST-NAME ALPHABETIC

• Each byte of the field is tested for the letters A through Z or a space.
DECISION and BRANCHING LOGIC

Field Class Example - SPACES

IF FIRST-NAME SPACES

• SPACE or SPACES valid

• Each byte of the field is tested for a space (x’40’)


File Processing
File Processing

• Accepts any number of input files.

• Processes SAM, ISAM, VSAM or IMS/DLI files.

• Allows fixed, variable, undefined, or spanned record formats.

• Processes data in alphabetic, numeric, packed, packed-unsigned


or binary formats.

• Searches files and performs logical data selection based on input


or calculations.

• Matches an unlimited number of files.

• Creates subfiles containing selected records from a master file.


File Statement

FILE <filename>

• filename is 1 - 8 characters
• must begin with alphabetic character (A - Z)
• other positions can be alphabetic (A-Z), numeric (0-9) or national (@,
#, $)
• filename matches the DD name in the JCL
File Statement Contd.

FILE statement (VSAM)


FILE filename VS

• if VSAM file, must add the VS parameter to the end of the FILE
statement
File Processing

• EASYTRIEVE can process all sorts of files and databases including :


 Sequential
 VSAM
 IMS/ DLI
 IDMS
 SQL

• Processing can be either automatic or controlled.


Automatic – EZT + controls input through the JOB and SORT statement
Controlled – through the Programmer Codes Input / Output Statement
such as GET , PUT , POINT , READ and WRITE
File Processing

• EASYTRIEVE can take one or many input files and create reports.
• EASYTRIEVE can take one or many input files and create one or many
output files.
• EASYTRIEVE can take one or many input files and create reports as
well as input files.
• How can EASYTRIEVE identify whether a file is INPUT or OUTPUT ?
File Processing

• Controlled Processing is necessary when one needs to –


a. Access data from more than one input file.
b. Randomly access VSAM or database file.

• Controlled Processing is not allowed for a file that has already been
defined as an automatic input file.
Reading Files

• EZTRIEVE PLUS will automatically read a file without explicit


instructions to do so

• The automatic file processing feature handles EOF situations. No


need to code EOF logic in most cases.
File Processing

JOB statement

• JOB INPUT < file name > NAME < job name>

• The job statement performs sequential processing of <file name >


• Ezetrieve handles the opening and closing of files.It performs several
tasks as :
- validates block length
- allocates buffer areas
- allocates work areas
- closes the file at the end of each activity.

• JOB INPUT NULL NAME Control-Input


‘NULL’ indicates that there is no automatic input and all file processing will
be controlled.
File Processing

GET statement

• GET < file name > STATUS

• This statement reads the next record of the file.

• One must test for end-of-file (EOF) and code the STOP statement , else the
program will execute forever.
– STOP / STOP < execute>

• Some FILE-STATUS values are


0 operation performed successfully
4 end-of-file during a GET
16 record not found during a READ.
File Processing

PUT statement

• PUT < file name > from <file name2>

• This statement writes data onto an output file from an input file.

• It can also be used to write data onto the file directly.

• The FROM Parameter is equivalent to coding a MOVE statement prior to


the PUT statement.
File Processing

READ statement

• READ < file name > KEY <field-name> STATUS

• Used to randomly access a VSAM File.

• It returns STATUS Codes which , should be handled in the Code.

• The KEY Parameter indicates the field name to be used while searching
for a corresponding record.
File Processing

POINT statement

• POINT < file name > operator <field-name> STATUS

• Used to set a position within a VSAM file from where sequential processing
can begin.

• Data can be retrieved either via Automatic File input or with a GET
statement.

• The relational operator can specify an exact match with an ‘equal operator ’
(EQ or = ) or can be a ‘ Greater than or equal to operator ’ (GE or >=).
File Processing

WRITE statement

• WRITE < file name > (UPDATE/ADD/DELETE) <from file name>


STATUS

• Used to update a VSAM File.


Reporting
Reporting

Printing a Report

• If input fields are reported, there is no need to move fields from the
input record to a print line

• Simply give the report a “logical” name


Reporting

Printing a Report - Cont’d

PRINT rptname

• PRINT is a keyword

• rptname is a user defined variable (up to 40 characters) and cannot


be an EZTRIEVE reserved word (like “REPORT” or “LINE”)
Reporting

Build onto Library Section

FILE INFILE
NAME 1 30 A
CITY 31 15 A
STATE 46 2 A
ZIP 48 5 N

JOB
PRINT RPT1
Reporting

REPORT Activity

• The description of a report is considered a sub-activity.

• The REPORT statement describes the characteristics of the report.


Reporting

REPORT Activity - Cont’d

• The REPORT statement has many parameters, but each has default
and none are required

• Multiple reports can be printed with a single pass of the file. Need
separate REPORT statements and must specify PRINT statement for
each.
Reporting

REPORT Statement

REPORT rptname

• REPORT is a keyword that must be present

• rptname is a user defined variable and corresponds to the PRINT


statement in the logic portion of the activity section
Reporting
Standard Format
 LINE SIZE 

TOP MARGIN

TITLE AREA (OPTIONAL)

HEADING AREA (OPTIONAL)

REPORT BODY

BOTTOM MARGIN
Reporting

Report Titles

• May specify up to 99 title lines

• Automatically centers each line on the page (can be manually


controlled with default overrides)
Reporting

TITLE Statement

TITLE literal1
TITLE 2 literal2
TITLE 3 literal3

– TITLE (TITLE 2, etc) are keywords and are required

– literal1 (literal2, etc.) are user defined and can be as wide as the
report (up to 132 characters)
Reporting

Sample TITLE Statements

TITLE ‘CSC GTS’


TITLE 2 ‘BASIC EZTRIEVE TRAINING’
TITLE 3 ‘SAMPLE REPORT TITLES’
Reporting

Detail Lines

• May specify up to 99 detail lines


• Fields and literals are printed in the order they are specified on the
LINE statement
• Length of each field reserved on the report is determined by the larger
of the field size or the column heading
• Default is to automatically place 3 spaces between each field on the
line
Reporting

Detail Lines - Cont’d

• Unless specified otherwise, the field name is used as the column


heading on the report

• Line is automatically centered on the page


Reporting

LINE Statement

LINE field/literal
LINE 2 field/literal
LINE 3 field/literal

– LINE (LINE 2, etc) are keywords and are required


– field can be fields from the input record, calculated fields or
working storage fields
– literal can be any literal value
Reporting

Sample LINE Statements

LINE NAME
LINE 2 CITY ‘, ‘ STATE ZIP
LINE 3 ‘ ‘
Reporting

Put it Together - A Second Look

FILE INFILE
NAME 1 30 A
CITY 31 15 A
STATE 46 2 A
ZIP 48 5 N
JOB
PRINT RPT1
REPORT RPT1
TITLE ‘CSC FSG’
TITLE 2 ‘BASIC EZTRIEVE TRAINING’
TITLE 3 ‘SAMPLE REPORT TITLES’
LINE NAME CITY STATE ZIP
Reporting

Sample with multiple reports

JOB
PRINT DETAIL-RPT
PRINT SUMMARY-RPT
REPORT DETAIL-RPT
TITLE ‘CSC FSG’
TITLE 2 ‘DETAIL RPT’
LINE .........
REPORT SUMMARY-RPT SUMMARY
TITLE ‘CSC FSG’
TITLE 2 ‘SUMMARY RPT’
LINE .........
Advanced Reporting
Advanced Reporting

Column Headings

• Defaults to the field name

• Can be overridden on the DEFINE statement

• Can be overridden in the REPORT sub-activity section


Advanced Reporting

HEADING Parm on the DEFINE statement

fieldname startpos length type decimals HEADING (‘literal’)

• Coded after the field definitions

• Keyword HEADING is required

• Literal value placed in single quotes


Advanced Reporting

Sample HEADING - I

POLICY-NUMBER 1 15 A HEADING (‘POL NUM’)

Replaces the literal POLICY-NUMBER as a column heading with one


line heading ‘ POL NUM’
Advanced Reporting

Sample HEADING – II

POLICY-NUMBER 1 15 A HEADING (‘POL’ ‘NUM’)

Replaces the literal POLICY-NUMBER as a column heading with a two


line heading ‘ POL ’
NUM
Advanced Reporting

HEADING parm in the REPORT sub-activity

REPORT <rptname>
TITLE literal1
HEADING fieldname (‘literal’)
LINE fields/literals

• Coded after the TITLE lines

• If coded here, must specify the field name


Advanced Reporting

More on HEADINGS
• If specified on the DEFINE statement and in the REPORT area, the
definition in the REPORT area overrides the one on the DEFINE
statement.
Advanced Reporting

SEQUENCING detail lines

• Use the SEQUENCE statement when you want a report sorted in a


particular sort order

• SEQUENCE statement immediately follows the REPORT statement

• Specify sort fields in highest to lowest order


Advanced Reporting

Sample SEQUENCE statement

REPORT ......
SEQUENCE PLAN-CODE POLICY-NUM
TITLE .....
LINE .......

• This example will report records by POLICY-NUM within PLAN-CODE


Advanced Reporting

More on SEQUENCE

• SEQUENCE defaults to ascending sort order

• To specify descending sequence, code a ‘D’ after the appropriate field


(note ‘A’ can be specified for ascending, but is not necessary)
Advanced Reporting

Another Sample SEQUENCE

REPORT ......
SEQUENCE PLAN-CODE POLICY-NUM D
TITLE .....
LINE .......

• This example will report records by descending POLICY-NUM within


ascending PLAN-CODE
Advanced Reporting

CONTROL Statement

• Use the CONTROL statement when you want to add the values in
columns or want to perform control breaks on a field(s)

• CONTROL statement immediately follows the SEQUENCE statement,


if coded, otherwise it will follow the REPORT statement
Advanced Reporting

CONTROL - Column Totals

• Automatically totals all numeric quantitative fields (any field defined


with decimal places).

• Because of this, be careful about specifying a decimal value (even ‘0’)


on field such as Social Security Number unless you want it totaled,
too.
Advanced Reporting

CONTROL BREAKS

• Control breaks occur whenever the value of any control field changes
or when EOF occurs

• The CONTROL statement coded by itself will produce only final totals.
Add control fields to the CONTROL statement when you want
subtotals.
Advanced Reporting

Sample CONTROL statement

REPORT ......
SEQUENCE PLAN-CODE POLICY-NUM
CONTROL
TITLE .....
LINE .......

• This example will report records by POLICY-NUM within PLAN-


CODE and will add up any column specified on the LINE statement
which is defined with decimal places
Advanced Reporting

CONTROL BREAK notes

• You should always sort the records with a SEQUENCE statement to


make control breaks work properly. Control fields are generally
specified in the same order as they are sorted
Advanced Reporting

More CONTROL BREAK notes

• The format of the report will vary slightly when using control breaks.
The control field(s) is only printed on the first detail line of the group,
not on every line

• This default can be changed (not covered in this class)


Advanced Reporting

More CONTROL BREAK notes

• Multiple control fields can be specified by adding additional fields on


the CONTROL statement

• Quantitative fields can not be used as control break fields


Advanced Reporting

Another Sample CONTROL statement

REPORT ......
SEQUENCE COMPANY PLAN-CD POLICY
CONTROL COMPANY PLAN-CD
TITLE .....
LINE .......

• This example will produce 2 levels of sub-totals (COMPANY and


PLAN-CD) and grand totals when EOF is reached
Advanced Reporting

Counting Records

• Use the TALLY command on the LINE statement

• Report sub-activity must include the CONTROL statement (with or


without any control fields)
Advanced Reporting

Sample TALLY statement

REPORT RPT1
SEQUENCE PLAN-CODE POLICY-NUM
CONTROL
TITLE .....
LINE PLAN-CODE POLICY-NUM TALLY

• This example will provide a record count at the end of the report
Macro’s

Definition & Processing

• Macro’s in Easytreive is more similar to COBOL Copybooks


• Macros are invoked in Easytrieve Program Using the “%”
symbol.
• While coding Macro’s the Key word “MACRO” should be the first
executable word inside the Macro.
• Just like Copybooks, Macro’s usually have different element type
associated with them in Change Control tools like “ChangeMan”
& “Endevor”.
• Just like the “Replacing By” clause available in COBOL while
using copybooks in COBOL program.
In macros too we can have same macro used for both input
& output files, with proper prefixes as “In” & “Out”.
Macro’s

Example : GETDATE Macro


MACRO USER-DATE
*
* GET THE CURRENT DATE AND PUT INTO USER FIELD LESS SLASHES
*
DEFINE GETDATE-DATE W 8 A
DEFINE GETDATE-FIRST6 GETDATE-DATE 6 N
DEFINE GETDATE-LAST5 GETDATE-DATE +3 5 A
DEFINE GETDATE-LAST6 GETDATE-DATE +2 6 A
DEFINE GETDATE-LAST3 GETDATE-DATE +5 3 A
DEFINE GETDATE-LAST2 GETDATE-DATE +6 2 A

GETDATE-DATE = SYSDATE * MOVE ALL 8


GETDATE-LAST3 = GETDATE-LAST2 * SHIFT LEFT OVER LAST /
GETDATE-LAST6 = GETDATE-LAST5 * SHIFT LEFT OVER FIRST /
&USER-DATE = GETDATE-FIRST6 * MOVE TO USER FIELD
DB2

Definition & Processing

• DB2 in Easytreive can be achieved by declaring CURSOR’s.


• Cursors can be declared in a convenient way say like an SQLFile.
• Later in the Easytrieve program, we use the SQLFile just like an
normal file with data in.
• Thereafter dump that SQLFile in a proper FLAT file and use that
data.
DB2

Definition & Processing


*
FILE SQLFILE1 SQL +
(SELECT STATE,DIST,AGT, +
FROM DB2TBLE +
WHERE ((STATE = 'CA' AND DIST ¬= 'SIMI ' +
INTO :STATE, :DIST, :AGT )
*************************
* FILE FROM THE DATA BASE
*************************
STATE 1 2 A
DIST 3 2 A
AGT 5 3 A
Basic Eztrieve Plus

THANK YOU

HAVE FUN!!

You might also like