166
EASYTRIEVE PLUS PRODUCT INFORMATION .......................................... 5 Description ........................................................................................................................ 5 Capabilities ........................................................................................................................ 6 PROGRAM STRUCTURE ............................................ 7 ENVIRONMENT Section .................................................................................................... 7 LIBRARY Section ................................................................................................................ 7 ACTVITY Section ................................................................................................................. 7 Example - Primer 1 ........................................................................................................... 9 Example - Primer 2 ......................................................................................................... 10 Example - Primer 3 ......................................................................................................... 11 Example - Primer 4 ......................................................................................................... 12 Example - Primer 5 ......................................................................................................... 13 Example - Primer 6 ......................................................................................................... 14 Example - Primer 7 ......................................................................................................... 15 LIBRARY ........................................................................................................................... 16 FILE Statement ................................................................................................................ 16 Field Definition Statement ............................................................................................. 16 Field - name ....................................................................................................................... 17 Start - location .................................................................................................................. 17 Field - length ..................................................................................................................... 17 HEADING Parameter ...................................................................................................... 18 MASK ................................................................................................................................ 18 Defining Edit Masks ........................................................................................................ 19 System Default Masks .................................................................................................... 20 Redefining a Field ........................................................................................................... 20 Working Storage ............................................................................................................. 20 VALUE 'literal' .................................................................................................................. 21 RESET ............................................................................................................................... 21 Library Exercise ............................................................................................................... 21 JOB statement ................................................................................................................. 24 - 1 -

Easy Tri Eve Plus

Embed Size (px)

Citation preview

Page 1: Easy Tri Eve Plus

EASYTRIEVE PLUS

PRODUCT INFORMATION.................................................................................................5

Description..............................................................................................................................5

Capabilities.............................................................................................................................6

PROGRAM STRUCTURE.....................................................................................................7

ENVIRONMENT Section........................................................................................................7

LIBRARY Section....................................................................................................................7

ACTVITY Section....................................................................................................................7

Example - Primer 1.................................................................................................................9

Example - Primer 2...............................................................................................................10

Example - Primer 3...............................................................................................................11

Example - Primer 4...............................................................................................................12

Example - Primer 5...............................................................................................................13

Example - Primer 6...............................................................................................................14

Example - Primer 7...............................................................................................................15

LIBRARY...............................................................................................................................16

FILE Statement.....................................................................................................................16

Field Definition Statement....................................................................................................16

Field - name ............................................................................................................................17

Start - location ........................................................................................................................17

Field - length ...........................................................................................................................17

HEADING Parameter...........................................................................................................18

MASK....................................................................................................................................18

Defining Edit Masks..............................................................................................................19

System Default Masks...........................................................................................................20

Redefining a Field.................................................................................................................20

Working Storage...................................................................................................................20

VALUE 'literal'......................................................................................................................21

RESET...................................................................................................................................21

Library Exercise....................................................................................................................21

JOB statement.......................................................................................................................24

IF / ELSE..............................................................................................................................26

Special Ifs..............................................................................................................................26

Combining Conditional Expressions....................................................................................27

Assignment Statement...........................................................................................................27

- 1 -

Page 2: Easy Tri Eve Plus

EASYTRIEVE PLUS

Calculations..........................................................................................................................28

Parentheses in Calculations.................................................................................................28

Rounding in Calculations.....................................................................................................28

Rounding Example................................................................................................................29

PRINT...................................................................................................................................29

REPORT................................................................................................................................30

REPORT Statement...............................................................................................................30

Spacing Control Parameters................................................................................................32

Testing Aid Parameters........................................................................................................32

Format Determination Parameters.......................................................................................33

Report Definition Statements................................................................................................33

SEQUENCE..........................................................................................................................33

CONTROL............................................................................................................................34

SUM......................................................................................................................................35

TITLE Statement...................................................................................................................35

HEADING Statement............................................................................................................36

LINE statement.....................................................................................................................36

Multiple Reports...................................................................................................................37

TALLY...................................................................................................................................38

S Working Storage................................................................................................................41

Relative Start-Location.........................................................................................................41

Relative Redefinition.............................................................................................................42

JOB ACTIVITY.....................................................................................................................42

STOP Statement....................................................................................................................42

DISPLAY Statement..............................................................................................................43

NEWPAGE............................................................................................................................43

SKIP number.........................................................................................................................43

Integer...................................................................................................................................44

Report......................................................................................................................................45

REPORT Statement...............................................................................................................45

Format Determination Parameters.......................................................................................46

SUMMARY............................................................................................................................55

SUMSPACE..........................................................................................................................55

TALLYSIZE...........................................................................................................................55

- 2 -

Page 3: Easy Tri Eve Plus

EASYTRIEVE PLUS

SUMFILE..............................................................................................................................55

FILE Directing Parameters..................................................................................................58

Report Procedures (PROCs).................................................................................................59

REPORT-INPUT. PROC......................................................................................................60

BEFORE-BREAK. PROC.....................................................................................................62

AFTER-BREAK. PROC........................................................................................................64

BEFORE-LINE. PROC.........................................................................................................64

ENDPAGE. PROC................................................................................................................64

TERMINATION. PROC........................................................................................................64

EXERCISE............................................................................................................................65

LIBRARY...............................................................................................................................67

FILE Statement.....................................................................................................................67

Virtual File Manager (VFM)................................................................................................69

COPY Statement...................................................................................................................70

EXIT Parameter....................................................................................................................70

ACTIVITY..............................................................................................................................71

CALL Statement....................................................................................................................71

MOVE Statement...................................................................................................................71

MOVE LIKE..........................................................................................................................73

User-Procedures (PROCs)...................................................................................................73

END-PROC...........................................................................................................................74

Nesting PROCs.....................................................................................................................75

START/FINISH Parameters..................................................................................................75

GOTO Statement...................................................................................................................76

Label.....................................................................................................................................76

JOB.......................................................................................................................................76

DO WHILE/END-DO Statements.........................................................................................77

Nesting Example...................................................................................................................77

SORT.....................................................................................................................................78

SORT Procedure...................................................................................................................79

FILE PROCESSING.............................................................................................................81

GET Statement......................................................................................................................81

PUT Statement......................................................................................................................82

VSAM......................................................................................................................................84

- 3 -

Page 4: Easy Tri Eve Plus

EASYTRIEVE PLUS

VSAM File Statement............................................................................................................84

PASSWORD literal...............................................................................................................84

VSAM File Creation (Loading).............................................................................................85

STATUS.................................................................................................................................85

VSAM Input...........................................................................................................................86

POINT Statement..................................................................................................................88

READ Statement...................................................................................................................89

WRITE...................................................................................................................................90

Synchronized File Processing...............................................................................................91

Representation of Synchronized Input Flow.........................................................................93

Special Tests for Synchronized Files....................................................................................94

MATCHED............................................................................................................................94

Checking for Duplicate Records...........................................................................................95

File Presence Test and End of File Test (EOF)....................................................................95

Possible Tests for Record Pairs............................................................................................96

Example 1 - Output to Two Files..........................................................................................97

Code......................................................................................................................................97

Record Presentation for Processing.....................................................................................98

Representation of Output Files.............................................................................................98

Multiple Job Activities Exercise..........................................................................................101

TABLES/INDEXING/ARRAYS............................................................................................101

SEARCH Statement.............................................................................................................103

Exercise...............................................................................................................................104

Indexing..............................................................................................................................105

Arrays..................................................................................................................................105

Subscripts............................................................................................................................110

EXCERCISES......................................................................................................................113

MACROS..............................................................................................................................114

OVERVIEW.........................................................................................................................114

Objective.............................................................................................................................114

GENERAL INFORMATION...............................................................................................114

Macro Applications.............................................................................................................114

CREATING MACROS.........................................................................................................115

Testing Macros Within a Program.....................................................................................118

- 4 -

Page 5: Easy Tri Eve Plus

EASYTRIEVE PLUS

Data Dictionary..................................................................................................................120

Logic Templating................................................................................................................121

CODING TECHNIQUES....................................................................................................123

OVERVIEW.........................................................................................................................123

Objectives............................................................................................................................123

SYSTEM-DEFINED FIELDS.............................................................................................124

General Purpose Fields......................................................................................................124

File Processing Fields........................................................................................................125

Report Processing Fields....................................................................................................125

ENVIRONMENT.................................................................................................................127

Debugging...........................................................................................................................128

BIT TESTING......................................................................................................................129

SUMMARY..........................................................................................................................130

- 5 -

Page 6: Easy Tri Eve Plus

EASYTRIEVE PLUS

PRODUCT INFORMATION

Description

EASYTRIEVE PLUS is an information retrieval and data management system that offers expanded capabilities for both business and data processing professionals.

The information retrieval capabilities allow non-data processing personnel to generate reports that meet the information requirements of their organization.

Automatic report composition features built into EASYTRIEVE PLUS allow for immediate productivity by even the most inexperienced computer users. As user experience increases more sophisticated procedures are available to provide reports of greater complexity without sacrificing simplicity.

The data management features of EASYTRIEVE PLUS make it an effective application development tool. You can use this powerful, fourth-generation language to :

Prototype applications

Assist in the design and quick development of production programs

Perform file maintenance on a variety of file types

Capabilities

EASYTRIEVE PLUS provides :

Automatic report formatting without sacrificing flexibility Production of unlimited reports from a single pass of the data Edit masks, such as floating money symbols, check protection, and blank when

zero Capability for special forms Complete conditional logic Powerful calculation capabilities User-friendly data base interfaces to a variety of common data bases complete

with standard call capabilities Extracts of all types of data from any combination of files - sequential, ISAM,

VSAM, or data bases Access of data fixed, variable , undefined or spanned record formats. Random access of ISAM and VSAM files and databases. Access of variable length fields. Matches and merges of any number of files; any number of keys. Before and after control break logic.

- 6 -

Page 7: Easy Tri Eve Plus

EASYTRIEVE PLUS

EASYTRIEVE PLUS allows:

User-defined reports An unlimited number of input files. Array processing

EASYTRIEVE PLUS performs:

Extensive table lookups (file and instream) Special tests (alphabetic, numeric, blanks, bit testing) Calls of user programs and subroutines by use of standard linkage conventions.

- 7 -

Page 8: Easy Tri Eve Plus

EASYTRIEVE PLUS

PROGRAM STRUCTUREThere are three basic sections to every EASYTRIEVE PLUS program. They are:

An Environment Section (optional)

A Library Section

One or More Activity Sections.

ENVIRONMENT Section

You use the ENVIRONMENT section to change EASYTRIEVE PLUS 'system defaults. It is an optional and infrequently used section of an EASYTRIEVE PLUS program. The examples in this Student Guide do not include an environment. Environment parameters are discussed in Section 6 of the Student Guide.

LIBRARY Section

The LIBRARY section of the program is used to define all input, output, and working storage fields used in the program.

ACTVITY Section

An ACTIVITY section can be one of two types: JOB or SORT.

A JOB activity is where program logic is coded. It can also contain a REPORT sub activity which generates a formatted report. Pro gram logic can be structured into components called PROCs (short for procedures)

The SORT activity is simply used to sort your data before doing other processing.

- 8 -

Page 9: Easy Tri Eve Plus

EASYTRIEVE PLUS

The following diagram shows basic program structure excluding the Environment section.

Figure 1:- Basic Program Structure

- 9 -

LIBRARY

JOB SORT

LOGIC PROC

PROC

REPORT

PROC

Page 10: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example - Primer 1

This example shows a very basic report program. It takes the input data and automatically formats it into a report. Filed names are used as column headings and the page number and date are automatically generated.

FILE PERSBL FB ( 150 1800)NAME 17 8 AEMP# 9 5 NDEPARTMENT 98 3 NNET 90 4 P 2GROSS 94 4 P 2

JOB INPUT PERSNL NAME PRIMER-ONEPRINT PAY-RPT

REPORT PAY-RPT LINESIZE 70TILTLE 01 'PERSONNEL REPORT PRIMER ONE'LINE 01 NAME DEPARTMENT EMP# GROSS NET

Primer 1 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONENAME DEPARTMENT EMP# GROSS NETWIMN 903 12267 373.60 251.65BERG 943 11473 759.20 547.88CORNING 915 02688 146.16 103.43NAGLE 935 00370 554.40 340.59ARNOLD 911 01963 445.50 356.87MANHART 914 11602 344.80 250.89TALL 917 11931 492.26 355.19BRANDOW 918 02200 804.64 554.31LARSON 911 11357 283.92 215.47BYER 932 11467 396.98 259.80HUSS 921 11376 360.80 223.71POWELL 911 11710 243.20 167.96MCMOHAN 943 00370 386.40 283.19FORREST 931 03416 13.80 13.19POST 911 00445 292.00 206.60PETRIK 921 00577 220.80 154.70VETTER 914 01895 279.36 189.06KRUSE 911 03571 242.40 182.09LOYAL 912 04225 292.20 230.50DENNING 919 02765 135.85 109.60WEST 940 04132 736.00 429.62THOMPSON 923 01743 250.40 187.40SMOTH 911 01730 315.20 202.43NORIDGE 944 03936 324.00 242.25

- 10 -

Page 11: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example - Primer 2

This program adds a simple arithmetic expression to compute employee deductions. Note that the field name DEDUCTIONS has been added to the LINE statement.

FILE PERSBL FB ( 150 1800)NAME 17 8 AEMP# 9 5 NDEPARTMENT 98 3 NNET 90 4 P 2GROSS 94 4 P 2DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME PRIMER-TWOPRINT PAY-RPT

REPORT PAY-RPT LINESIZE 70TILTLE 01 'PERSONNEL REPORT PRIMER TWO'LINE 01 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

Primer 2 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONENAME DEPARTMENT EMP# GROSS NET DEDUCTIONSWIMN 903 12267 373.60 251.65 121.95BERG 943 11473 759.20 547.88 211.32CORNING 915 02688 146.16 103.43 42.73NAGLE 935 00370 554.40 340.59 213.81ARNOLD 911 01963 445.50 356.87 88.63MANHART 914 11602 344.80 250.89 93.91TALL 917 11931 492.26 355.19 137.07BRANDOW 918 02200 804.64 554.31 250.33LARSON 911 11357 283.92 215.47 68.45BYER 932 11467 396.98 259.80 136.88HUSS 921 11376 360.80 223.71 137.09POWELL 911 11710 243.20 167.96 75.24MCMOHAN 943 00370 386.40 283.19 103.21FORREST 931 03416 13.80 13.19 0.61POST 911 00445 292.00 206.60 85.40PETRIK 921 00577 220.80 154.70 66.10VETTER 914 01895 279.36 189.06 90.30KRUSE 911 03571 242.40 182.09 60.31LOYAL 912 04225 292.20 230.50 64.70DENNING 919 02765 135.85 109.60 26.25WEST 940 04132 736.00 429.62 306.38THOMPSON 923 01743 250.40 187.40 63.00SMOTH 911 01730 315.20 202.43 112.77NORIDGE 944 03936 324.00 242.25 81.75

- 11 -

Page 12: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example - Primer 3

This program adds some elementary logic to assure that employee deductions are computed only when DEPARTMENT = 911.

FILE PERSBL FB ( 150 1800)NAME 17 8 AEMP# 9 5 NDEPARTMENT 98 3 NNET 90 4 P 2GROSS 94 4 P 2DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME PRIMER-THREEIF DEPARTMENT = 911

DEDUCTIONS = GROSS - NETPRINT PAY-RPT

END-IF

REPORT PAY-RPT LINESIZE 70TITLE 01 'PERSONNEL REPORT PRIMER THREE'LINE 01 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

Primer 3 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONENAME DEPARTMENT EMP# GROSS NET DEDUCTIONSARNOLD 911 01963 445.50 356.87 88.63LARSON 911 11357 283.92 215.47 68.45POWELL 911 11710 243.20 167.96 75.24POST 911 00445 292.00 206.60 85.40KRUSE 911 03571 242.40 182.09 60.31SMOTH 911 01730 315.20 202.43 112.77

- 12 -

Page 13: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example - Primer 4

This program builds on the logic of the previous example. The THRU parameter has been added to enable the calculation of deductions for departments 911, 912, 913, 914, 921.

FILE PERSBL FB ( 150 1800)NAME 17 8 AEMP# 9 5 NDEPARTMENT 98 3 NNET 90 4 P 2GROSS 94 4 P 2DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME PRIMER-FOURIF DEPARTMENT = 911 THRU 914 921

DEDUCTIONS = GROSS - NETPRINT PAY-RPT

END-IF

REPORT PAY-RPT LINESIZE 70TILTLE 01 'PERSONNEL REPORT PRIMER FOUR'LINE 01 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

Primer 4 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONENAME DEPARTMENT EMP# GROSS NET DEDUCTIONSARNOLD 911 01963 445.50 356.87 88.63MANHART 914 11602 344.80 250.89 93.91LARSON 911 11357 283.92 215.47 68.45HUSS 921 11376 360.80 223.71 137.09POWELL 911 11710 243.20 167.96 75.24POST 911 00445 292.00 206.60 85.40PETRIK 921 00577 220.80 154.70 66.10VETTER 914 01895 279.36 189.06 90.30KRUSE 911 03571 242.40 182.09 60.31LOYAL 912 04225 292.20 230.50 64.70SMOTH 911 01730 315.20 202.43 112.77

- 13 -

Page 14: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example - Primer 5

This program adds a SEQUENCE statement to the REPORT activity which sorts employees alphabetically by NAME under DEPARTMENT.

FILE PERSBL FB ( 150 1800)NAME 17 8 AEMP# 9 5 NDEPARTMENT 98 3 NNET 90 4 P 2GROSS 94 4 P 2DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME PRIMER-FIVEIF DEPARTMENT = 911 THRU 914 921

DEDUCTIONS = GROSS - NETPRINT PAY-RPT

END-IF

REPORT PAY-RPT LINESIZE 70TILTLE 01 'PERSONNEL REPORT PRIMER FIVE'LINE 01 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

Primer 5 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONENAME DEPARTMENT EMP# GROSS NET DEDUCTIONSARNOLD 911 01963 445.50 356.87 88.63KRUSE 911 03571 242.40 182.09 60.31LARSON 911 11357 283.92 215.47 68.45POWELL 911 11710 243.20 167.96 75.24POST 911 00445 292.00 206.60 85.40SMOTH 911 01730 315.20 202.43 112.77LOYAL 912 04225 292.20 230.50 64.70MANHART 914 11602 344.80 250.89 93.91VETTER 914 01895 279.36 189.06 90.30HUSS 921 11376 360.80 223.71 137.09PETRIK 921 00577 220.80 154.70 66.10

- 14 -

Page 15: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example - Primer 6

This program adds a CONTROL statement to the REPORT activity which causes totals to be printed for all packed decimal field types.

FILE PERSBL FB ( 150 1800)NAME 17 8 AEMP# 9 5 NDEPARTMENT 98 3 NNET 90 4 P 2GROSS 94 4 P 2DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME PRIMER-SIXIF DEPARTMENT = 911 THRU 914 921

DEDUCTIONS = GROSS - NETPRINT PAY-RPT

END-IF

REPORT PAY-RPT LINESIZE 77TILTLE 01 'PERSONNEL REPORT PRIMER SIX'LINE 01 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

Primer 6 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONENAME DEPARTMENT EMP# GROSS NET DEDUCTIONSARNOLD 911 01963 445.50 356.87 88.63KRUSE 911 03571 242.40 182.09 60.31LARSON 911 11357 283.92 215.47 68.45POWELL 911 11710 243.20 167.96 75.24POST 911 00445 292.00 206.60 85.40SMOTH 911 01730 315.20 202.43 112.77LOYAL 912 04225 292.20 230.50 64.70MANHART 914 11602 344.80 250.89 93.91VETTER 914 01895 279.36 189.06 90.30HUSS 921 11376 360.80 223.71 137.09PETRIK 921 00577 220.80 154.70 66.10

3320.18 2380.28 942.9

- 15 -

Page 16: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example - Primer 7

This program builds upon the previous program by adding the field name DEPARTMENT to the CONTROL statement. This causes totals to be printed for each department.. (Called a "control break" on department) Also, a less cryptic heading name has been added for the EMP# field (EMPLOYEE NUMBER)

FILE PERSBL FB ( 150 1800)NAME 17 8 AEMP# 9 5 NDEPARTMENT 98 3 NNET 90 4 P 2GROSS 94 4 P 2DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME PRIMER-SEVENIF DEPARTMENT = 911 THRU 914 921

DEDUCTIONS = GROSS - NETPRINT PAY-RPT

END-IF

REPORT PAY-RPT LINESIZE 80TITLE 01 'PERSONNEL REPORT PRIMER SEVEN'TITLE 02 'NOTICE THE ALTERNATE COLUMN HEADING AND

SUBTOTAL'HEADING EMP# ('EMPLOYEE' 'NUMBER')LINE 01 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

Primer 7 Output

2 / 13 / 88 PERSONNEL REPORT PRIMER ONENAME DEPARTMENT EMP# GROSS NET DEDUCTIONSARNOLD 911 01963 445.50 356.87 88.63KRUSE 911 03571 242.40 182.09 60.31LARSON 911 11357 283.92 215.47 68.45POWELL 911 11710 243.20 167.96 75.24POST 911 00445 292.00 206.60 85.40SMOTH 911 01730 315.20 202.43 112.77

911 1822.22 1331.42 490.8LOYAL 912 04225 292.20 230.50 64.70

912 292.20 230.50 64.70MANHART 914 11602 344.80 250.89 93.91VETTER 914 01895 279.36 189.06 90.30

914 624.16 439.95 184.21HUSS 921 11376 360.80 223.71 137.09PETRIK 921 00577 220.80 154.70 66.10

581.60 378.41 203.19

- 16 -

Page 17: Easy Tri Eve Plus

EASYTRIEVE PLUS

LIBRARY

The first task in coding an EASYTRIEVE PLUS program is to code the LIBRARY section. This section describes the file or files and fields you are using as input to your program. The library has two parts: the FILE statement and the field definition statements.

FILE Statement

The FILE statement describes the file you are using as input to your program. You code it at the beginning of the library section.

Syntax

where FILE is the keyword and file-name and file attributes are supplied by your data processing department.

Field Definition Statement

A filed definition specifies data fields within a record on a file.

Four parameters are always required : field-name, start-location, field-length, and data-type.

Additional parameters include the number of decimal positions for quantitative fields, HEADING and MASK.

Syntax

- 17 -

FILE file-name [file attributes]

field-name start-location field-length data-type +

[decimal-positions] [HEADING ‘literal’ ] +

[MASK ({[letter] [BWZ] [‘literal’] })] +

[VALUE literal] [RESET]

Page 18: Easy Tri Eve Plus

EASYTRIEVE PLUS

Field - name

You create a field-name or adapt the field name in a record layout for your EASYTRIEVE PLUS program. Field-names must be unique within a file. The name can be 1 to 40 alphanumeric characters. Special characters can be used, but not delimiters.

Start - location

The start location of a field is the position of its first character of data relative to the position of the first, character of data in the record.

Start location can be explicitly defined based on the number of positions it is from the first position (position 1) in the record: NAME 17 16 A

The start position for the field NAME is 17. The first character of data in this field begins in position 17, which is the 17th character of data in the record.

Field - length

You specify the length of a field in bytes (characters and/or spaces).

Data - type

You describe the type of data a field contains by coding the letter for that type after the field-length. There are five data-types.

Type Max. Length(Bytes)

A Alphanumeric 32,767N Numeric 18P Packed 10U Unsigned Packed 9B Binary 4

Decimal - positions

By specifying decimal-positions, you:

Identify a filed to EASYTRIEVE PLUS as being quantitative Identify the Filed(s) to be automatically totaled when specified in a CONTROL

report. Allow for proper placement of commas and decimals with leading zeros suppressed

when the field is printed

- 18 -

Page 19: Easy Tri Eve Plus

EASYTRIEVE PLUS

Four types of data can have decimal positions:

N NumericP PackedB BinaryU Unsigned Packed

Specify the decimal-positions by coding an integer (0 through 18) after the data-type. For example,

AMOUNT 40 5 N 2

is a five-byte numeric field with two decimal positions.

HEADING Parameter

You use the HEADING parameter to specify an alternative column heading for a field. (The default column heading is the field-name.)

Place the alternate column heading within single quotation marks. For example,

CL-NAME 5 20 A HEADING 'CLIENT NAME'

produces the column headingCLIENT NAME

MASK

An edit mask is a pattern of characters specifying how non-alphanumeric data is to be printed. Alphanumeric fields cannot be edited. An edit mask is created using combinations of the following characters:

9 Formats digits.Z suppresses Leading zeroes* Replaces leading zeroes With an asterisk- Prints a minus sign prior to the first non-zero digit of a negative number$ Prints a currency symbol prior to the first non-zero digit.

Each digit in the field must be designated in the mask. Any character which follows the last character of the edit mask is printed if the field is negative.

Example

MASK FIELD RESULT-------- -------- ------------$$,$$9 01234 $1,234$$,$$9 93142 $93,142

- 19 -

Page 20: Easy Tri Eve Plus

EASYTRIEVE PLUS

Defining Edit Masks

You can define standard edit masks when your system is installed.

Examples

Syntax

MASK is the EASYTRIEVE PLUS keyword Letter is used to name the edit mask that follows it. If you name a mask, you can

reuse it on other field definitions just by specifying the name. A name can be any letter from A through Y. This means that once you have defined a mask, you don't have to define a mask, you don't have to define it again.

BWZ (blank when zero) specifies that a field should not be printed if the entire field contains zeros. BWZ must be coded whenever needed

Literal is the format of the mask using the characters indicated on the previous page.

Examples

- 20 -

MASK USE

'(999) 999-9999' Telephone Number'999-99-9999' Social Security Number'z9/99/99' Date'$$,$$$,$$9.00 CREDIT Money (with floating $)'*,***,***,999.99-' Protected Check Amount'-,---,--9.99' Negative Number

[MASK ([letter] [BWZ]['literal'])]

If the data is 012345678And code is ……. The result is……

SSN 1 9 N MASK(A BWZ '999-99-9999')012-34-5678

SSN1 61 9 N MASK (A BWZ)

PAY 10 5 N 0 MASK '$$$,$$$,$$9-' $12,345,678

Page 21: Easy Tri Eve Plus

EASYTRIEVE PLUS

System Default Masks

Redefining a Field

Sometimes it is necessary to break a field into several parts in order to get the exact information for your report. A birth date, for example, may have been originally entered as one field in a record. Now you want to access this information by either the month, day, or year. With EASYTRIEVE PLUS you can redefine that field in the following manner:

DATE-OF-BIRTH 103 6 NMONTH 103 2 NDAY 105 2 NYEAR 107 2 N

DATE-OF-BIRTH

|_|_|_|_|_|_|0|2|1|0|5|5|_|_|_|_| position 103 105 107

In this exhibit the MONTH (02) starts in position 103 and occupies position 103 and 104. The DAY starts 105 and occupies positions 105 and 106. Finally, YEAR starts in 107 and occupies 107 and 108.

Working Storage

Working storage involves setting aside an area of storage as a place to keep calculations or other information that is to be created during the running of an EASYTRIEVE PLUS program.

Define working storage by specifying W' as the start location. The values stared in this field are associated with each individual record.

- 21 -

System Default Masks

Code MaskPAY 10 5 N O 'zz,zzz-'

PAY 10 5 N 2 'zzz.99-'

PAY 10 5 N '99999'

Page 22: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example

GROSS 30 4 N 2NET 34 4 N 2WORK-DEDUCT W 4 N 2 HEADING 'DEDUCTIONS'

VALUE 'literal'

You can use the VALUE option in the field definition statement to initialize the contents of a working storage field. Zeroes (for numeric fields) or blanks (for alphanumeric fields) are the defaults if no value is specified. The data can be any valid literal whose type matches that of the field being initialized.

ExampleCURR-MON W 10 A VALUE 'JANUARY'

RESET

When coded on the field definition for a W working storage field, RESET restores the field to its initial value whenever JOB or SORT is executed. The initial value is whatever you specify via a VALUE parameter or the default: zeroes far numeric fields, blanks for alphanumeric fields. RESET is useful when you need to ensure that a working storage field always has the same initial value each time you loop through an activity.

ExampleCURR-MON W 10 A VALUE 'JANUARY' RESET

Library Exercise

Using the following file layout and instructions, code the entire library section of an EASYTRIEV PLUS program, including the FILE statement.

File layout for file named PERSNL

DescriptiveField content

StartLocation Length Type Comments

Region 1 1 N Displacement is relative to oneEmployee Number

9 5 N

Employee Name 17 20 ANet Pay 90 4 P Two decimalsGross Pay 94 4 P Two decimalsDepartment 98 3 NDate of Hire 136 6 N Month day year

- 22 -

Page 23: Easy Tri Eve Plus

EASYTRIEVE PLUS

Redefine Date of Hire into month, day, and year. Code descriptive column headings for one field. Code masks for pay fields Add work fields for:

NEW-PAY (two decimal positions) DEDUCTIONS (two decimal positions) PERCENT-DEDUCTIONS (one decimal position)

- 23 -

Page 24: Easy Tri Eve Plus

EASYTRIEVE PLUS

JOB ACTIVITY

You will now learn how to code the processing activities to be done on the files that were defined in the library section. EASYTRIEVE PLUS executes these activities one at a time, in top-to-bottom order.

There are three parts of an activity : the JOB statement and two subactivities - logic and report.

- 24 -

LIBRARY

JOB SORT

LOGIC PROC

PROC

REPORT

PROC

Page 25: Easy Tri Eve Plus

EASYTRIEVE PLUS

This exhibit shows the location of the JOB statement and the subactivity in an EASYTRIEVE PLUS program.

You can use the logic subactivity to examine and manipulate data, initiate printed reports, and write data to a file.

You can use the report subactivity to format the desired report.

JOB statement

The JOB statement defines and initiates processing activity. It also identifies the name of the automatic input file.

Syntax

[ INPUT ]

The optional INPUT parameter identifies the automatic input to the activity.

When you do not specify INPUT, EASYTRIEVE PLUS automatically provides an input file. If a SORT activity immediately preceded the current JOB activity, the default input is the output file from that SORT activity. Otherwise, the default input is the first file named in the library section

file-name

File-name identifies the automatic input file(s). File-name identifies any file defined in the library section of the program eligible for sequential input processing.

- 25 -

** Library ***

ACTIVITY JOB INPUT PERSNL NAME PRIMER LOGIC IF DEPARTMENT = 911 THRU 914 921

EDUCTIONS = GROSS - NETRINT EXAMPLE

END-IF*

REPORT REPORT EXAMPLESEQUENCE DEPARTMENT NAMETITLE 1 'PRIMER EXAMPLE REPORT'LINE 1 NAME DEPARTMENT EMP# GROSS NET DEDUCTIONS

JOB INPUT [file-name] [NAME job-name]

Page 26: Easy Tri Eve Plus

EASYTRIEVE PLUS

[ NAME job-name ]

The optional NAME parameter names the JOB activity. Job-name can be up to 40 characters long, can contain any character other than a delimiter, and begin with A-Z or 0-9; it cannot consist of all numeric characters. This parameter is used only for documentation purposes.

Logic

Data selection and manipulation takes place in the logic section of an EASYTRIEVE PLUS program. Logic is coded immediately after the JOB statement.

If Statement

Processing within a JOB activity is dependent on the conditional (IF) statements present in the program.

When an IF statement is present, each record read from the input file is processed against the condition.

Every IF statement must end with END-IF

Syntax

ExamplesA literal : IF DEPT = 910

IF NAME = 'SMITH'IF AMT GE 500

The value in another field : IF DIV = HOLD-DIV

A series of literals : IF STATE = 'GA' , 'SC', 'TN'IF CLASS = 'A' THRU 'E'IF AMT NE 100 THRU 500IF DEPT = 900 940 THRU 950 960THRU 980

- 26 -

{EQ =}{NE =} {field-two }

IF field-one {GT > } {literal }{GE >=} {arithmetic expression }{LT < }{LE <=}

[ statements executed for true IF ][ ELSE ]

[ statements executed for false IF ]END-IF

Page 27: Easy Tri Eve Plus

EASYTRIEVE PLUS

IF / ELSE

ELSE specifies alternative processing when the condition established by the IF statement is not met.

For true IF's, all commands up to the ELSE (or END-IF if no ELSE is present) are executed.

For false IF's, commands between ELSE and END-IF are executed.

Following END-IF, processing continues regardless of the result of the IF.

Example

IF DIV = 'A' THRU 'L' DEDUCTIONS = GROSS * 15ELSE DEDUCTIONS = GROSS * 18END-IF

Records with the DIV in the A through L range are processed according to the statements) between the IF and ELSE. For all records with DIV not in the range A through L, the statement(s) following ELSE is executed until END-IF is reached.

Special Ifs

You use Special Ifs to check the integrity of the data in your files

Syntax

ExamplesIF AMT NOT NUMERICIF NAME SPACESIF STATE ALPHABETICIF AMT-DUE ZERO

- 27 -

{ALPHABETIC}{NUMERIC}{SPACE}

IF field-name [NOT] { SPACES}{ZERO}{ ZEROS}{ ZEROES}

Page 28: Easy Tri Eve Plus

EASYTRIEVE PLUS

Combining Conditional Expressions

You can combine conditional expressions

All conditional expressions are considered one statement AND statements are evaluated before Ors Parentheses may alter the normal order of evaluation.

Examples

IF DIV = 'A' AND AMT GE 500 AND STATE = 'GA'

The IF statement is true when all three conditions are true for that record.

IF DIV = 'A' OR STATE = 'GA' AND AMT GE 500

The IF statement is true when (DIV is equal to A) or (STATE is equal to GA and AMT is greater than or equal to 500)

Assignment Statement

The assignment statement establishes a value in a field. The value can be a copy of a value in another field, or it can be the result derived from an arithmetic or logical expression.

The assignment statement also accomplishes data conversion, such as packing or unpacking data.

Syntax

Examples

HOLD-DIV = DIVDEPT-NAME = 'ACCOUNTING DEPT'FACTOR = 1.1PAY = RATE * HOURSTAX = SALE * .06

- 28 -

field-name-1 [INTEGER] [ROUNDED TRUNCATED] {= EQ} field-name-2literal-1arithmetic expression

Page 29: Easy Tri Eve Plus

EASYTRIEVE PLUS

Calculations

There are four arithmetic operations in EASYTRIEVE PLUS :* multiplication / division+ addition- subtraction

Multiplication and division are performed before addition and subtraction in order from left to right. There must be a space before and after the arithmetic operators.

Syntax

Parentheses in Calculations

Parentheses can be used to override the normal order of operation. When parentheses are used, operation proceeds from the innermost level to the outermost. Any level of parentheses nesting is allowed.

RESULTS = GROSS - AMT * 1.3is the same as :

RESULT = GROSS - (AMT * 1.3)but different from

RESULT = (GROSS - AMT) * 1.3

Rounding in Calculations

To round the results of calculations, use the INTEGER and/or ROUNDED/TRUNCATED options.

Use the INTEGER option when you want to ignore the fractional portion of a value. INTEGER indicates that only the digits to the left of the decimal point should be transferred during the assignment.

Use ROUNDED or TRUNCATED when the receiving field is too small to hold the fractional result of the assignment. TRUNCATED is the default.

Use the ROUNDED option to round a fractional result of the assignment statement. Rounding takes place in the commonly accepted manner. That is, the least significant digit of the result (receiving field) has its value increased by one when the most significant digit of the excess decimal digits is greater than or equal to five. For example, if 10.75 is the value of the sending field and the receiving field has one decimal place, ROUNDED causes the receiving field to receive 10.8.

- 29 -

field-name {=EQ} value-1 {* / + -} value-2

Page 30: Easy Tri Eve Plus

EASYTRIEVE PLUS

Use the TRUNCATED option to truncate the result of the assignment statement. Low order digits are truncated on the right as necessary when the result is moved to the receiving field.

If INTEGER is used with ROUNDED, the result is rounded to the nearest integer before the INTEGER function is performed. If INTEGER is used with TRUNCATED, then only the INTEGER function is performed.

INTEGER, ROUNDED, and TRUNCATED are valid only with numeric fields.

Rounding Example

Assume

SENDFLD W 5 N 2 VALUE ( 10.75 )RCVFLD W 5 N 1

Then :

Assignment Statement RCVFLD ResultRCVFLD INTEGER ROUNDED = SENDFLD 11.0RCVFLD INTEGER TRUNCATED = SENDFLD 10.0RCVFLD INTEGER = SENDFLD 10.0RCVFLD ROUNDED = SENDFLD 10.8RCVFLD TRUNCATED = SENDFLD 10.7RCVFLD = SENDFLD 10.7

PRINT

The PRINT statement makes data available for output to a report.

Syntax

Example

IF REG = 25 PRINT RPT1 END-IFOnly records with a 25 in the REG field are output to the report.

- 30 -

PRINT report-name

Page 31: Easy Tri Eve Plus

EASYTRIEVE PLUS

Logic Example

JOB INPUT MSTRFL NAME SAMPLE INCOME = WEEKLY-GROSS * 52 IF REG = 10 TAX = INCOME * .05 ELSE

TAX = INCOME * .03 'PRINT RPT1

END-IF TOTAL-TAX = TOTAL-TAX + TAX

IF DEPT = 45 PRINT RPT2 END-IFPRINT RPT3 REPORT RPT1** Report Statements **REPORT RPT2** Report Statements **REPORT RPT3** Report Statements **

REPORT

The PRINT statement discussed previously identifies records for output. It does not cause the printing of the report. This is done by the report subactivity.

There are two parts to every report subactivity :

1. REPORT Statement - which specifies the type and physical characteristics of the report.

2. Report Definition Statements - which define the content of the report.

REPORT Statement

You code the REPORT statement first m a report subactivity. The report statement includes the keyword REPORT and report parameters.

Parameters are keywords that allow you to assign values that alter the physical characteristics of the final report. Although you can specify a large number of report parameters, you can produce most reports using default (EASYTRIEVE PLUS defined) parameter values.

Report statement parameters provide a simple way to define tailored reports. The parameters discussed in this section can be divided into three categories :

- 31 -

Page 32: Easy Tri Eve Plus

EASYTRIEVE PLUS

Spacing control parameters Testing aid parameters Format determination parameters

Syntax

REPORT report-name +[PAGESIZE nn] +[LINESIZE nn] +[SKIP nn] +[SPACE nn] +[TITLE SKIP nn] +

Spacing Control [SPREAD] + Parameters [NOSPREAD] + [NOADJUST] + [NODATE] + [NOPAGE] + [NOHEADING] +TestingAid [LIMIT nn] +Parameters [EVERY nn] +

Format [LABELS] +Determination ([ACROSS nn]Parameters [DOWN nn]

[SIZE nn]

- 32 -

Page 33: Easy Tri Eve Plus

EASYTRIEVE PLUS

Spacing Control Parameters

The following parameters control spacing on a standard format report.

PAGESIZE - lines per page (default is 58).

LINESIZE-length of each line (default ~s 132 print positions).

SKIP - number of blank lines to be inserted between ime groups (default is 0).

SPACE - number of blanks inserted between field columns and between fields and Burials in title and detail lines (default is 3).

TITLESKIP - number of blank lines inserted after last title line before first heading or detail line (default is 3).

SPREAD - requests that the columns of data be spread evenly over the entire line, overrides the SPACE parameter (default is NOSPREAD).

NOADJUST -requests that the title lines and report be left-justified on the page. The default is for the report to be centered on the page, SPREAD and NOADJUST are mutually exclusive.

NODATE - inhibits printing the date in positions one through eight of the first title line.

NOPAGE - inhibits the printing of a page number.

NO HEADING - inhibits the printing of column headings

Testing Aid Parameters

The following parameters control the amount of data output to a report.

LIMIT - limits the number of records printed on the report

EVERY - specifies that only every nth line is printed in the report.

- 33 -

Page 34: Easy Tri Eve Plus

EASYTRIEVE PLUS

Format Determination Parameters

The LABELS option specifies that the report will be in label format rather than the standard report format. The following sub-parameters are used with LABELS.

ACROSS specifies the number of labels printed across the print line(default is 4).

DOWN specifies the number of lines down from the first line of the first label to the first line of the second label (default is 6).

SIZE specifies the number of print positions from the first position on the first label to the first position on the second label (default is 30).

The LABELS option automatically inhibits the printing of the date, page, headings and titles.

Report Definition Statements

The second part of a report subactivity is the report definition statements. These statements define the content of your report. When you use report definition statements, you must code them immediately after the REPORT statement, in the following order:

SEQUENCECONTROLSUMTITLEHEADINGLINE

SEQUENCE

This statement allows you to specify the order of the data in the report.

You can sequence on any field from any input file or any W working storage field.

You can sequence on as many fields as your system sort allows.

Sequence fields are stated in major to minor order.

The sequence order is ascending. Coding D after a field-name reverses the order for that field only.

Syntax

- 34 -

SEQUENCE field-name-1 [D] . . . field-name-n [D]

Page 35: Easy Tri Eve Plus

EASYTRIEVE PLUS

Examples

SEQUENCE CO DIV DEPT GROSS-PAY DSEQUENCE GROUP AMT D CODE

CONTROL

A CONTROL statement specifies that a report should automatically accumulate and print totals. A control break occurs whenever the value of any control field changes or end-of-report is reached. CONTROL can be any non-quantitative field from any input file or any W working storage field. At each control break, the totals are printed for the quantitative fields specified in the report.

You can specify an unlimited number of control fields

Fields are coded on the CONTROL statement in a major to minor order.

Syntax

Final totals are automatically provided. You can alter the default by coding FINAL NOPRINT.

NOPRINT following any field-name or FINAL supresses the printing of totals (which have been accumulated) at that control break.

NEWPAGE following any field or FINAL causes a new page after the printing of the control

break totals (or, in the case of FINAL, before the printing of the final totals). Page numbers continue.

RENUM following any field or FINAL causes a new page with page numbers beginning at one after the printing of the control break totals (or, in the case of FINAL, before the printing of the final totals).

Examples

CONTROL CO RENUM DIV DEPT NOPRINTCONTROL FINAL NOPRINT CO NEWPAGE DIV

- 35 -

CONTROL [field-name] [NEW PAGE] [NO PRINT][FINAL] [RENUM]

Page 36: Easy Tri Eve Plus

EASYTRIEVE PLUS

SUM

The SUM statement specifies the quantitative fields to be totaled far a control report. Normally, EASYTRIEVE PLUS totals all quantitative fields specified on the LINE statement (to be discussed later). The SUM statement overrides this process; only the fields specified on the SUM statement are totalled.

You can use SUM only in control reports

You can SUM any quantitative field from any active file or any W field

Syntax

Examples

SUM GROSS NET

TITLE Statement

The TITLE statement allows you to define a title for your report. Up to 99 titles are permitted. You can specify literals and/or field names on the TITLE statement.

Syntax

You use ±nn to alter the normal spacing between literals or fields on the title lines. nn spaces are added to or subtracted from the SPACE parameter (default of 3).

COL nn specifies the print column number where the next title item is to begin. If you specify COL nn, you must also specify NOADJUST on the REPORT statement.

If no TITLEs are coded, the date and page number are not printed.

Examples

TITLE 1 'REPORT ONE'TITLE 3 'THIS PAGE FOR DIV' -2 DIV-NOTITLE 4 'ABC COMPANY'

- 36 -

SUM quant-field-1 . . . quant-field-n

TITLE [nn] [± nn ] [field-name][COL nn] [literal]

Page 37: Easy Tri Eve Plus

EASYTRIEVE PLUS

prints

12/10/85 REPORT ONE PAGE 1THIS PAGE FOR DIV 15ABC COMPANY

HEADING Statement

As in the Library section, you can define an alternate column heading fur a field in the Report subactivity- The HEADING statement overrides a HEADING parameter coded in the Library section of the program.

Use one HEADING statement per field.

Words in a heading may be stacked to save space in the column.

Syntax

Example 1

HEADING EMP-NO, 'EMP NO'prints a column heading on the report that looks like

EMP NO

Example 2Heading SSN ('SOCIAL' 'SECURITY' 'NUMBER')

prints the stacked column headingSOCIALSECURITYNUMBER

LINE statement

The LINE statement defines the content of a report line. Use LINE 1 to designate headings for the report columns.

You can specify up to 99 lines per record.

You can specify any field in an input file or in W working storage

Syntax

Literals print on all lines but not as headings.

- 37 -

HEADING field-name ('literal'…..)

LINE nn [± nn] [field-name][POS nn] [literal][COL nn]

Page 38: Easy Tri Eve Plus

EASYTRIEVE PLUS

±nn is used to alter the normal spacing between line items. nn is added to or subtracted from the SPACE parameter (default of 3).

POS provides for aligning fields under the corresponding column heading positions indicated on the LINE 1 statement.

COL nn species the print column number where the next field is to begin. If you specify COL nn, you must also specify NOAAJUST on the REPORT statement.

Example

LINE 1 DEPT DIV NAMELINE 2 POS 2 CODE POS 3 ADDRESSLINE 3 POS 3 CITY-STATE

prints the field's contents in the following format:DEPT DIV NAME911 02 MATT JONES

2232 HILLANYWHERE IL

Multiple Reports

Several reports can he produced simultaneously with one pass of the input file. No special coding is needed for multiple reports on the same printer.

FILE PERSBL FB ( 150 1800)NAME 17 8 AEMP# 9 5 NDEPARTMENT 98 3 NNET 90 4 P 2GROSS 94 4 P 2DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME MULTRPTSPRINT RPT1DEDUCTIONS = GROSS - NETPRINT RPT2

IF DEPARTMENT = 911PRINT RPT3

END-IF

-----------> REPORT RPT1 TITLE 1 'REPORT ONE' LINE 1 NAME DEPARTMENT GROSS NET

-----------> REPORT RPT2 SEQUENCE DEPARTMENT TITLE 1 'REPORT TWO' LINE 1 DEPARTMENT NAME GROSS NET DEDUCTIONS

- 38 -

Page 39: Easy Tri Eve Plus

EASYTRIEVE PLUS

-----------> REPORT RPT3 CONTROL TITLE 1 'REPORT THREE - DEPT 911' LINE 1 NAME GROSS NET DEDUCTIONS

REPORT ONE (RPT1) produces a very simple listing of all employees.

REPORT TWO (RPT2) gives the same information as REPORT ONE but includes an additional column with the deductions printed.REPORT THREE (RPT3) produces a report that contains only information from department 911.

TALLY

TALLY is a system-defined field for control reports. IL contains the number of detail records printed within each control break and can be printed on the report. TALLY can only be used in control reports. The value of TALLY only appears on summary lines.

Example

INPUT

OUTPUT

- 39 -

FILE PERSBL FB ( 150 1800)NAME 17 8 AEMP# 9 5 NDEPARTMENT 98 3 NNET 90 4 P 2GROSS 94 4 P 2DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME JOB1IF DEPT = 911 THRU 914

PRINT RPT1END-IF

REPORT RPT1SEQUENCE DEPT NAMECONTROL DEPTTITLE 1 'NUMBER OF EMPLOYEES BY DEPARTMENT'HEADING TALLY ('NUMBER' 'OF' 'PEOPLE')LINE 1 DEPT NAME TALLY

7/28/85 NUMBER OF EMPLOYEES BY DEPARTMENT PAGE 1DEPT NAME NO. OF PEOPLE911 ARNOLD

GREENHAFERISAACKRUSELARSONPOSTPOWELLREYNOLDSSMOTHSTRIDEYOUNG

911 12912 LOYAL912 1914 CROCI

GRECOMANHARTRYANVETTER

914 518

Page 40: Easy Tri Eve Plus

EASYTRIEVE PLUS

Report Exercise

Using the library and job activity sections shown below, code a report subactivity that produces the following report.

FILE PERSBL FB ( 150 1800)NAME 17 8 AEMP# 9 5 NDEPARTMENT 98 3 NNET 90 4 P 2GROSS 94 4 P 2DEDUCTIONS W 4 P 2

JOB INPUT PERSNL NAME JOB1DEDUCTIONS = GROSS - NETIF DEPT = 924 THRU 940

PRINT RPT1END-IF

2/15/89 EXERCISE ONE REPORT PAGE 1TOTALS FOR DEPARTMENT: 940

- 40 -

Page 41: Easy Tri Eve Plus

EASYTRIEVE PLUS

NAME EMP# GROSS PAY NET PAY DEDUCTIONSJONES 10949 804.80 560.63 244.17KELLY 12403 197.60 145.51 52.09PHILIPS 05807 253.26 213.76 39.50WEST 04132 736.00 429.62 306.38

1991.66 1349.52 642.14

2/15/89 EXERCISE ONE REPORT PAGE 2TOTALS FOR DEPARTMENT: 935

NAME EMP# GROSS PAY NET PAY DEDUCTIONSNAGLE 00370 554.40 340.59 213.81OSMON 09481 628.00 411.05 216.95

1182.4 751.64 430.76

2/15/89 EXERCISE ONE REPORT PAGE 3TOTALS FOR DEPARTMENT: 932

NAME EMP# GROSS PAY NET PAY DEDUCTIONSBYER 11467 396.68 259.80 136.88

396.68 259.80 136.88

2/15/89 EXERCISE ONE REPORT PAGE 4TOTALS FOR DEPARTMENT: 931

NAME EMP# GROSS PAY NET PAY DEDUCTIONSFORREST 03416 13.80 13.19 .61

13.80 13.19 .61

2/15/89 EXERCISE ONE REPORT PAGE 5TOTALS FOR DEPARTMENT: 924

NAME EMP# GROSS PAY NET PAY DEDUCTIONSROGERS 01549 329.00 230.17 98.83ZOLTAN 04935 125.00 25.00 100.00

454.00 255.17 198.83

- 41 -

Page 42: Easy Tri Eve Plus

EASYTRIEVE PLUS

S Working Storage

You can use S to designate working storage. S fields are fields used mainly for totaling and percentages. You can not send an S working storage field to a SEQUENCEd report. You use S working storage for a field that is not associated with a record (i.e. totals or counters).

ExamplesTOTAL-GROSS S 6 P 2TOTAL-EMPLOYEE S 3 P 0

The value in TOTAL-GROSS can be used for a total of gross salaries for all records selected for the report. The value in TOTAL-EMPLOYEE can be added to for a total number of employees selected for the report.

JOB INPUT PAYFILETOTAL-GROSS = TOTAL-GROSS + GROSS-PAYTOTAL-EMPLOYEE = TOTAL-EMPLOYEE + 1

Relative Start-Location

You can define the start-location of a field relative to a previously defined position in the record. Relatively defining a start-location eliminates the need to identify the actual start-location of a field. Relative start-locations are most useful when you are creating output files.

Use an asterisk in place of the number for a start-location when defining a field as relative to the previous field. When you use an asterisk, every field in the file should use the asterisk and every field must be defined.

Examples

EMP# * 5 NNAME * 16 AFILLER1 * 10 NADDRESS * 39 A

The ADDRESS field would then start in position 32 in the record.

- 42 -

Page 43: Easy Tri Eve Plus

EASYTRIEVE PLUS

Relative Redefinition

You can relatively redefine a field by designating the original field-name as the starting location for all subsequent fields in the redefinition.

Example

DATE OF BIRTH W 6 NMONTH DATE OF BIRTH 2 NDAY DATE OF BIRTH +2 2 NYEAR DATE OF BIRTH +4 2 N

The starting position of the redefined field is designated by using the original field name plus the sum of the lengths of all previous fields used in the redefinition.

JOB ACTIVITYLogic

STOP Statement

A STOP statement allows you to terminate an activity

Syntax

STOP ends the current activity and goes on to the next activity if additional activities are coded

STOP EXECUTE immediately terminates all EASYTRIEVE PLUS execution

Example

IF AMT NOT NUMERICSTOP

END-IF

- 43 -

STOP [EXECUTE]

Page 44: Easy Tri Eve Plus

EASYTRIEVE PLUS

DISPLAY Statement

A DISPLAY statement sends data to a specified output file or output device. DISPLAY is commonly used:

For error messages

For highlighting reports.

For hex display of selected information.

If DISPLAY is used in the JOB activity, the lines to be DISPLAYed are interspersed throughout the report in an unSEQUENCEd report. The lines to be DISPLAYed are printed at the beginning of a SEQUENCEd report.

Syntax

The DISPLAY statement has three different syntax formats. The next two pages show two formats with explanations and examples of the use of each of the formats.

Format 1

file-name

When you specify file-name, EASYTRIEVE PLUS prints data to the named file. If you do not specify file-name, the default is SYSPRINT/SYSLST (EASYTRIEVE PLUS output files).

NEWPAGE

The NEWPAGE option specifies that a skip to a new page occurs before the data is printed.

SKIP number

The SKIP option specifies that the designated number of lines are skipped before the data is printed.

- 44 -

DISPLAY [file-name] [NEWPAGE] [+ integer][SKIP NUMBER] [ COL integer]

[POS integer]

[literal-1] [literal-n][field-name-1] ……… [field-name-n]

Page 45: Easy Tri Eve Plus

EASYTRIEVE PLUS

Integer

Coding an integer modifies the horizontal spacing between display items

COL Integer

The COL integer option specifies the print column- number where EASYTRIEVE PLUS places the next display item.

POS Integer

The POS integer option on DISPLAY statements within report procedures causes the next display item to be positioned under the corresponding position on LINE 1 statement.

Literals or field-name

Code literals or field-names in the order you want them to appear on the printed line.

Example of Format 1

DISPLAY SKIP 2 '** RECORD NOT FOUND FOR KEY' +2 SSN

DISPLAY ERRFILE 'THIS REPORT IS FOR ERRORS +THAT WERE FOUND IN THE EDIT PHASE.'

Format II

In this format, EASYTRIEVE PLUS produces a hexadecimal and character dump of the current record or the specified field-name. The parameters, other than HEX, operate the same as in Format 1

Example of Format II

DISPLAY HEX NAME

produces :

CHAR WIMNZONE ECDD44444444444444NUMR 6945000000000000000

1..…5..…10..…15..…20

- 45 -

DISPLAY [filename] NEWPAGE HEX [field-name]SKIP NUMBER [file-

name]

Page 46: Easy Tri Eve Plus

EASYTRIEVE PLUS

Report

REPORT Statement

In addition to the REPORT statement parameters , the following can be used ;

- 46 -

REPORT report-name

DTLCT FIRSTEVERY +NONE

FormatDetermination SUMCTL HIARParameters NONE [DTLCOPY] ) +

TAG

[SUMMARY] +[SUMSPACE n] +[TALLYSIZE n] +[SUMFILE file-name] +

FileDirecting [PRINTER file-name]Parameters

Page 47: Easy Tri Eve Plus

EASYTRIEVE PLUS

Format Determination Parameters

DTLCTL

DTLCTL determines when control field values are printed on detail lines :

FIRST detail line (the default) EVERY detail line NONE of the detail lines

SUMCTL

SUMCTL determines when control field values are printed on total summary lines

HIAR

HIAR prints all fields from major control to minor control as far as the breaking field. HIAR is the default

NONE

NONE inhibits printing of control field values on total lines

TAG

TAG prints the control field name and the literal TOTAL on the left side of the subtotals and total lines of the report

DTLCOPY

DTLCOPY prints all values from detail lines onto summary lines

The following examples illustrates what effect these format determination parameters have on the final output in a control report.

- 47 -

Page 48: Easy Tri Eve Plus

EASYTRIEVE PLUS

Report: Control Example 1

Control breaks on MARITAL-STAT and REGION with totals and final totals Tags on total lines

INPUT

FILE PERSNL +FB ( 150 1800 )

REGION 1 1 NBRANCH 2 2 NEMP # 9 5 N HEADING ('EMPLOYEE' 'NUMBER')PAY - NET 90 4 P 2 HEADING ('NET' 'PAY')PAY - GROSS 94 4 P 2 HEADING ('GROSS' 'PAY')MARITAL-STAT 128 1 A HEADING ('MARITAL' 'STATUS')

* M - MARRIED * S - SINGLE

DEDUCTIONS W 4 P 2*JOB INPUT PERSNL NAME CONTROL-1

DEDUCTIONS = PAY-GROSS - PAY-NETPRINT CTLRPT1

REPORT CTLRPT1 SPACE 1 LINESIZE 72 SUMCTL TAGSEQUENCE REGION MARITAL-STAT BRANCH EMP#CONTROL REGION MARITAL-STATTITLE 1 'EASYTRIEVE PLUS CONTROL EXAMPLE ONE'TITLES 3 'NOTICE THE CONTROL BREAK FIELDSTITLE 4 'AND CONTROL BREAK LINES'

LINE 1 REGION BRANCH MARITAL-STAT EMP# PAY-GROSS PAY-NET DEDUCTIONS

- 48 -

Page 49: Easy Tri Eve Plus

EASYTRIEVE PLUS

OUTPUT

10/23/87 EASYTRIEVE PLUS CONTROL EXAMPLE ONENOTICE THE CONTROL BREAK FIELDSAND CONTROL BREAK LINES

MARITAL EMPLOYEE GROSS NETREGION BRANCH STATUS NUMBER PAY PAY DEDUCTIONS1 02 M 11473 759.20 547.88 211.32

04 11467 396.68 259.80 136.88MARITAL-STAT TOTAL 1155.88 807.68 348.20

1 01 S 12267 373.60 251.65 121.9501 02200 804.64 554.31 250.3302 00370 554.40 340.59 213.8103 11602 344.80 250.89 93.9103 02688 146.16 103.43 42.7304 11931 492.26 355.19 137.0704 11357 283.92 215.47 68.4504 01963 445.50 356.87 88.63

MARITAL-STAT-TOTAL 3445.28 2428.40 1016.88

REGION TOTAL 4601.16 3236.08 1365.08

2 01 M 11376 360.80 223.71 137.0902 03571 242.40 182.09 60.3103 04234 386.40 283.19 103.2103 03416 13.80 13.19 .6105 04225 295.20 230.50 64.7005 01895 279.36 189.06 90.30

MARITAL-STAT-TOTAL 1577.96 11121.74 456.22

2 02 S 11710 243.20 167.96 75.2403 02765 135.85 109.60 26.2503 00577 220.80 154.70 66.1004 00445 292.00 206.60 85.40

MARITAL-STAT-TOTAL 891.85 638.86 252.99

REGION TOTAL 2469.81 1760.60 709.21

CONTD…..

- 49 -

Page 50: Easy Tri Eve Plus

EASYTRIEVE PLUS

3 01 M 04589 313.60 229.69 83.9102 01730 315.20 202.43 112.7703 09481 628.00 411.05 216.9503 05914 313.60 222.61 90.9903 01549 329.00 230.17 98.3304 12829 365.60 238.04 127.56

MARITAL-STAT-TOTAL 2265.00 1533.99 731.01

3 01 S 12403 197.60 145.51 52.0901 05807 253.26 213.76 39.5001 04132 736.00 429.62 306.3802 12641 313.60 219.91 93.6902 09609 310.40 215.91 94.4902 07231 1004.00 685.23 318.7702 05805 174.15 134.03 40.1202 01743 250.40 187.40 63.00

- 50 -

Page 51: Easy Tri Eve Plus

EASYTRIEVE PLUS

10/23/87 EASYTRIEVE PLUS CONTROL EXAMPLE ONENOTICE THE CONTROL BREAK FIELDSAND CONTROL BREAK LINES

MARITAL EMPLOYEE GROSS NETREGION BRANCH STATUS NUMBER PAY PAY DEDUCTIONS3 03 S 07781 310.40 224.36 86.04

03 03936 324.00 242.25 81.7503 03890 386.40 272.53 113.8704 12318 282.40 195.13 87.2704 08262 376.00 215.95 160.05

MARITAL-STAT-TOTAL 4918.61 3381.59 11537.02

REGIONAL TOTAL 7183.61 4915.58 2268.03

4 01 M 05482 183.75 141.47 42.2802 09764 121.95 96.64 25.3103 11211 424.00 282.45 141.5504 10260 591.20 459.57 131.63

MARITAL-STAT-TOTAL 11320.90 980.13 340.77

4 01 S 10961 329.20 291.70 107.5001 05525 460.80 279.56 181.2402 06239 712.80 451.92 260.8803 10949 804.80 560.63 244.1703 04935 125.00 25.00 100.00

MARITAL-STAT-TOTAL 2502.60 1608.81 893.79

REGIONAL TOTAL 3823.50 2588.94 1234.56

FINAL TOTAL 18078.08 12501.20 5576.88

- 51 -

Page 52: Easy Tri Eve Plus

EASYTRIEVE PLUS

Report : Control Example 2

Control breaks on REGION and MARITAL STATUS Each REGION starts on a new page and REGION values are in the titles Totals for each region are printed but no final totals are printed

INPUT

FILE PERSNL +FB ( 150 1800 )

REGION 1 1 NBRANCH 2 2 NEMP # 9 5 N HEADING ('EMPLOYEE' 'NUMBER')PAY - NET 90 4 P 2 HEADING ('NET' 'PAY')PAY - GROSS 94 4 P 2 HEADING ('GROSS' 'PAY')MARITAL-STAT 128 1 A HEADING ('MARITAL' 'STATUS')

* M - MARRIED * S - SINGLE

DEDUCTIONS W 4 P 2JOB INPUT PERSNL NAME CONTROL-2

DEDUCTIONS = PAY-GROSS - PAY-NETPRINT CTLRPT2

REPORT CTLRPT2 SPACE 1 LINESIZE 72 SUMCTL TAGSEQUENCE REGION MARITAL-STAT BRANCH EMP#CONTROL FINAL NOPRINT REGION RENUM ,ARITAL-STATTITLE 01 'EASYTRIEVE PLUS CONTROL EXAMPLE TWOTITLES 03 'NOTICE THE FOLLOWING VARIABLE TITLE INFORMATION'TITLE 05 'THIS PAGE CONTAINS INFORMATION ABOUT'TITLE 06 'REGION : ' REGION

LINE 1 MARITAL-STAT BRANCH EMP# PAY-GROSS PAY-NET DEDUCTIONS

- 52 -

Page 53: Easy Tri Eve Plus

EASYTRIEVE PLUS

10/23/87 EASYTRIEVE PLUS CONTROL EXAMPLE TWONOTICE THE FOLLOWING VARIABLE TITLE INFORMATIONTHIS PAGE CONTAINS INFORMATION ABOUT

REGION : 1

MARITAL EMPLOYEE GROSS NETSTATUS BRANCH NUMBER PAY PAY DEDUCTIONS

02 11473 759.20 547.88 211.3204 11467 396.68 259.80 136.88

M 1155.88 807.68 348.20

01 12267 373.60 251.65 121.9501 02200 804.64 554.31 250.3302 00370 554.40 340.59 213.8103 11602 344.80 250.89 93.9103 02688 146.16 103.43 42.7304 11931 492.26 355.19 137.0704 11357 283.92 215.47 68.4504 01963 445.50 356.87 88.63

S 3445.28 2428.40 1016.88

4601.16 3236.08 1365.08

- 53 -

Page 54: Easy Tri Eve Plus

EASYTRIEVE PLUS

10/23/87 EASYTRIEVE PLUS CONTROL EXAMPLE TWONOTICE THE FOLLOWING VARIABLE TITLE INFORMATIONTHIS PAGE CONTAINS INFORMATION ABOUT

REGION : 2

MARITAL EMPLOYEE GROSS NETSTATUS BRANCH NUMBER PAY PAY DEDUCTIONSM 01 11376 360.80 223.71 137.09

02 03571 242.40 182.09 60.3103 04234 386.40 283.19 103.2103 03416 13.80 13.19 .6105 04225 295.20 230.50 64.7005 01895 279.36 189.06 90.30

M 1577.96 11121.74 456.22

S 02 11710 243.20 167.96 75.2403 02765 135.85 109.60 26.2503 00577 220.80 154.70 66.1004 00445 292.00 206.60 85.40

891.85 638.86 252.99

2469.81 1760.60 709.21

10/23/87 EASYTRIEVE PLUS CONTROL EXAMPLE TWONOTICE THE FOLLOWING VARIABLE TITLE INFORMATIONTHIS PAGE CONTAINS INFORMATION ABOUT

REGION : 3

MARITAL EMPLOYEE GROSS NETSTATUS BRANCH NUMBER PAY PAY DEDUCTIONS

01 04589 313.60 229.69 83.9102 01730 315.20 202.43 112.7703 09481 628.00 411.05 216.9503 05914 313.60 222.61 90.9903 01549 329.00 230.17 98.3304 12829 365.60 238.04 127.56

M 2265.00 1533.99 731.01

01 12403 197.60 145.51 52.0901 05807 253.26 213.76 39.5001 04132 736.00 429.62 306.3802 12641 313.60 219.91 93.6902 09609 310.40 215.91 94.4902 07231 1004.00 685.23 318.7702 05805 174.15 134.03 40.1202 01743 250.40 187.40 63.0003 07781 310.40 224.36 86.0403 03936 324.00 242.25 81.7503 03890 386.40 272.53 113.8704 12318 282.40 195.13 87.27

- 54 -

Page 55: Easy Tri Eve Plus

EASYTRIEVE PLUS

04 08262 376.00 215.95 160.05S 4918.61 3381.59 11537.02

7183.61 4915.58 2268.03

10/23/87 EASYTRIEVE PLUS CONTROL EXAMPLE TWONOTICE THE FOLLOWING VARIABLE TITLE INFORMATIONTHIS PAGE CONTAINS INFORMATION ABOUT

REGION : 3

MARITAL EMPLOYEE GROSS NETSTATUS BRANCH NUMBER PAY PAY DEDUCTIONS

01 05482 183.75 141.47 42.2802 09764 121.95 96.64 25.3103 11211 424.00 282.45 141.5504 10260 591.20 459.57 131.63

M 11320.90 980.13 340.77

01 10961 329.20 291.70 107.5001 05525 460.80 279.56 181.2402 06239 712.80 451.92 260.8803 10949 804.80 560.63 244.1703 04935 125.00 25.00 100.00

S 2502.60 1608.81 893.79

3823.50 2588.94 1234.56

- 55 -

Page 56: Easy Tri Eve Plus

EASYTRIEVE PLUS

SUMMARY

SUMMARY produces a summary report that contains only total lines.

SUMSPACE

SUMSPACE increases the print size of the fields on the total line to accommodate a total value which may be larger than the individual field size. SUMSPACE is added to the length of the field (in digits) to give the print size for total fields (default of 3). It is not necessary to account for additional commas in SUMSPACE

TALLYSIZE

TALLYSIZE sets the print size for the field TALLY on a line. The total of TALLYSIZE and SUMSPACE is the sizer for TALLY on a summary line. The default for TALLYSIZE is 2.

SUMFILE

SUMFILE generates a summary file. A summary file is a file that contains the values for all control and summed fields at each minor break. You can request the summary file by defining the file in the library and then creating it via the REPORT SUMFILE parameter.

The summary file can be processed by subsequent JOB activities.

The summary file example on the next page demonstrates the use of SUMFILE in an EASYTRIEVE PLUS program.

SUMFILE Example 1

The summary file has three parts :

1. Control Fields - the fields which appear on the CONTROL statement. i.e. COMPANY, DIVISION. The control fields must have the same attributes as the input file.

2. The value TALLY is defined as 10 P 03. Summed Fields - the fields on which totals are calculated. All total fields must have

attributes of 10 P

- 56 -

Page 57: Easy Tri Eve Plus

EASYTRIEVE PLUS

SUMFILE data :

---CONTROL FIELDS ----------------------------------------ACCUMULATORS-------------CONTROL CONTROL SUM SUMFIELD-1 … FIELD-N TALLY FIELD-1 … FIELD-N

FILE PAYROLLNAME 17 16 AADDRESS 57 20 ASTREET 37 20 ADEPT 98 3 ACOMPANY 1 1 NNET 90 4 P 2DIVISION 2 2 NGROSS 94 4 P 2

* FILE SUMMED F ( 33 ) * JOB INPUT PAYROLL NAME CREATE-SUMFILE

PRINT REPORT 1 REPORT REPORT1 SUMFILE SUMMED

SEQUENCE DEPT COMPANY DIVISIONCONTROL COMPANY DIVISIONTITLE 'THIS IS A SUMMARY REPORT'LINE COMPANY DIVISION NAME ADDRESS GROSS NET

* * THE RECORD LAYOUT FOR SUMMED WOULD BE AS FOLLOWS : * COMPANY 1 1 N < ------ 1 * DIVISION 2 2 N * TALLY 4 10 P O < ------ 2 * GROSS 14 10 P 2 < ------ 3 * NET 24 10 P 2

- 57 -

Page 58: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example 2

FILE PERSNL FB ( 150, 1800)REGION 1 1 NBRANCH 2 2 NGROSS 94 4 P 2

*FILE SUMMED F (23)

S-REGION * 1 NS-BRANCH * 2 NS-TALLY * 10 P 0S-GROSS * 10 P 2

*JOB INPUT PERSNL NAME GEN-SUMFILE

IF REGION = 3 4PRINT REGION-LISTING

END-IFREPORT REGION-LISTING LINESIZE 80 SUMFILE SUMMED

SEQUENCE REGION BRANCHCONTROL REGION BRANCHTITLE 1 'TOTAL YTD REPORT'LINE 1 REGION BRANCH GROSS

*JOB INPUT SUMMED NAME SUM0JOB

PRINT SUM-REPORT*REPORT SUM-REPORT LINESIZE 80

TITLE 1 'INTERMEDIATE TOTALS'LINE S-REGION S-BRANCH S-GROSS S-TALLY

The first report in this program produces a listing of gross salaries with totals at each REGION and BRANCH control break. The second report is a summary of this report and is reproduced below :

6/06/88 INTERMEDIATE TOTALS PAGE 1

S-REGION S-BRANCH S-GROSS S-TALLY3 01 1500.46 43 02 2367.75 63 03 2291.40 63 04 1024.00 34 01 1043.75 34 02 834.75 24 03 1353.80 34 04 591.20 1

- 58 -

Page 59: Easy Tri Eve Plus

EASYTRIEVE PLUS

FILE Directing Parameters

PRINTER Parameter

The PRINTER parameter directs the report's printed to a different file.

Default is SYSPRINT/SYSLST

Multiple Reports

Several reports can be produced simultaneously with one pass of the input file. Multiple reports in the same run can be directed to the same printer or different printers.

Same Printer

You need not use special coding for multiple reports on the same printer. Reports are spooled (sent) to a work file (temporary storage area) when the printer is busy. Spooling is automatic Any field, with the exception of S working storage, referenced in a REPORT

subactivity will be spooled

Separate Printers

When using separate printers, you must define printer files in the library section with FILE statements containing the PRINTER parameter.

The REPORT statement must identify the file-name with the PRINTER parameterFILE PAYFILE

NAME 17 16 AADDRESS 57 20 ASTREET 37 20 AEMP-NUMBER 9 5 N

*FILE SPFORM PRINTER*JOB INPUT PAYFILE NAME MULT-PRINTERSIF EMP-NUMBER LE 12345

PRINT ALBEL-REPORTPRINT NORM-REPORT

END-IF*

1 ------- > REPORT LABEL-REPORT LABELS PRINTER SPFORMSEQUENCE EMP-NUMBERLINE 1 NAMELINE 3 STREETLINE 5 ADDRESS

2 -------- > REPORT NORM-REPORT

- 59 -

Page 60: Easy Tri Eve Plus

EASYTRIEVE PLUS

LINE 1 NAME ADRESS EMP-NUMBERThis exhibit shows an EASYTRIEVE PLUS program that produces the following reports.

1. The first report subactivity produces a label report on the printer designated SPFORM in the second file statement

2. The second report subactivity produces a standard report. It will be output to the printer you normally use with other EASYTRIEVE PLUS programs

Report Procedures (PROCs)

Report Procedures (PROCs) are routines that are automatically invoked within a report subactivity to perform special data manipulation not included in the Logic subactivity. There are seven report PROCs in EASYTRIEVE PLUS.

You code report procedures immediately after the last LINE statement of each report in your program

Syntax

REPORT statementLINE statement

REPORT-INPUT. PROCBEFORE-BREAK PROCAFTER-BREAK PROCBEFORE-LINE PROCAFTER-LINE PROCENDPAGE PROCTERMINATION PROC

** procedure logic **END-PROC

You must code END-PROC at the end of each procedure You code the logic to be executed in a report PROC the same way you code

logic in a JOB activity No I/O is permitted Although you may code these procs in any order, each proc may only be used

once per report

- 60 -

Page 61: Easy Tri Eve Plus

EASYTRIEVE PLUS

REPORT-INPUT. PROC

The REPORT-INPUT. PROC allows for final screening and modification of report input data. It is performed for each record selected for the report that contains the PROC

You must execute a SELECT statement in the PROC to cause data to continue to the report

If a report has been SEQUENCEd, this procedure is invoked after each record is output from the sort

Example

FILE PERSNL** field definition **

TOT-NET S 5 P 2PCT-NET-TO-TOT W 3 P 1*JOB INPUT PERSNL NAME RPTINPT

TOT-NET = TOT-NET + PAY-NETPRINT PCT-RPT

*REPORT PCT-RPT LIMIT 20

SEQUENCE BRANCH EMP#CONTROL FINAL NOPRINT BRANCH NOPRINTTITLE 1 'EXAMPLE OF REPORT-INPUT PROC'LINE 1 BRANCH NAME EP# PAY-NET PCT-NET-TO-TOT

*------- > REPORT-INPUT. PROC

PCT-NET-TO-TOT = PAY-NET / TOT-NET * 100 + .05SELECT

END-PROC

- 61 -

Page 62: Easy Tri Eve Plus

EASYTRIEVE PLUS

OUTPUT

9/06/85 EXAMPLE OF REPORT-INPUT PROC PAGE 1

EMPLOYEE NETBRANCH EMPLOYEE NAME NUMBER PAY PCT-NET-TO-TOT1 BRANDOW LYDIA 02200 554.31 4.4

HUSS PATTI 11376 223.71 1.8WIMN GLORIA 12267 251.65 2.0

2 NAGLE MARY 00370 340.59 2.7KRUSE MAX 03571 182.09 1.5BERG NANCY 11473 547.88 4.4POWELL CAROL 11710 167.96 1.3

3 PETRIK KATHY 00577 154.70 1.2CORNING GEORGE 02688 103.43 .8DENNING RALPH 02765 109.60 .9FORREST BILL 03416 13.19 .1MCMOHAN BARBARA 04234 283.19 2.3MANHART VIRGINIA 11602 250.89 2.0

4 POST JEAN 00445 206.60 1.7ARNOLD LINDA 01963 356.87 2.9LARSON RODNEY 11357 215.47 1.7BYER JULIE 11467 259.80 2.1TALL ELAINE 11931 355.19 2.8

5 VETTER DENISE 01895 189.06 1.5LOYAL NED 04225 230.50 1.8

- 62 -

Page 63: Easy Tri Eve Plus

EASYTRIEVE PLUS

BEFORE-BREAK. PROC

The BEFORE-BREAK. PROC allows for modification of totals and special annotation before total line printing caused by the CONTROL statement.

LEVEL is a system-defined field and can be used to determine the appropriate break :

LEVEL = 1 for minor break= 2 for next break= N + 1 for final totals (N is the number of control fields)

Example

FILE PAYROLLEMP# 9 5 N HEADING ('EMPLOYEE' 'NUMBER')NET 90 4 P 2 HEADING ('NET' 'PAY')DEPT 98 3 NGROSS 94 4 P 2 HEADING ('GROSS' 'PAY')DED W 3 P 2PCT W 4 N 2

JOB INPUT PAYROLLL NAME CORRECT-PCTIF DEPT = 911 914 921

DED = GROSS - NETPCT = DED / GROSS * 100PRINT PCT-REPORT

END-IFREPORT PCT-REPORT LINESIZE 73

SEQUENCE DEPTCONTROL DEPT NOPRINTTITLE 1 'THIS REPORT WILL ILLUSTRATE USE OF'TITLE 2 'BEFORE-BREAK PROCEDURE'LINE DEPT EMP# GROSS NET DED PCT

BEFORE-BREAK. PROCPCT = DED / GROSS * 100IF LEVEL = 1

DISPLAY SKIP 1 'DEPARTMENT' DEPT POS 3 GROSS POS 4 NET + POS 5 DED POS 6 PCTDISPLAY SKIP 1

END-IFEND-PROC

- 63 -

Page 64: Easy Tri Eve Plus

EASYTRIEVE PLUS

OUTPUT

8/20/85 THIS REPORT WILL ILLUSTRATE USE OF PAGE 1BEFORE-BREAK PROCEDEURE

EMPLOYEE GROSS NETDEPT NUMBER PAY PAY DED PCT

911 00445 292.00 206.60 85.40 29.2411710 243.24 167.96 75.24 30.9311357 283.92 215.47 68.45 24.1001963 445.50 356.87 88.63 19.8909764 121.95 96.64 25.31 20.7504589 313.60 229.69 83.91 26.7505805 174.15 134.03 40.12 23.0303890 386.40 272.53 113.87 29.4612461 313.60 219.91 93.69 29.8712829 365.60 238.04 127.56 34.8901730 315.20 202.43 112.77 35.7703571 242.40 182.09 60.31 24.88

DEPARTMENT 911 3497.52 2522.26 975.26 27.88 < ---

914 07231 1004.00 685.23 318.77 31.7508262 376.00 215.95 160.05 42.5610961 399.20 291.70 107.50 26.9211602 344.80 250.89 93.91 27.2300185 279.36 189.06 90.30 32.32

DEPARTMENT 914 2403.36 1632.83 770.53 32.06 < ---

921 00577 220.80 154.70 66.10 29.9311376 360.80 223.71 137.09 37.9905482 183.75 141.47 42.28 23.00

DEPARTMENT 921 765.35 519.88 245.47 32.07 < ---

6666.23 4674.97 1991.26 29.87

The BEFORE-BREAK. PROC caused the DEPARTMENT annotation at each of the breaks and modified the total in PCT to be the percent based on total amounts.

- 64 -

Page 65: Easy Tri Eve Plus

EASYTRIEVE PLUS

AFTER-BREAK. PROC

The AFTER-BREAK. PROC allows for specified annotation after control break lines are printed.

LEVEL can be tested here also.

BEFORE-LINE. PROC

The BEFORE-LINE. PROC allows for special annotation before each detail line is printed.

ENDPAGE. PROC

The ENDPAGE. PROC is invoked whenever end of page is detected. It allows for page totals or footer information on the bottom of each page.

TERMINATION. PROC

The TERMINATION. PROC is invoked at the end of the report. It allows for report footer information only on the last page of the report.

- 65 -

Page 66: Easy Tri Eve Plus

EASYTRIEVE PLUS

EXERCISE

Using the necessary fields from the PERSNL file layout, code an EASYTRIEVE PLUS program, with one JOB activity, to produce the reports found on this page and the next page.

4/24/86 SUMMARY EXAMPLE REPORT

NET GROSS NUMBER OFDEPT PAY PAY EMPLOYEES

911 2522.26 3497.52 12912 230.50 295.20 1914 1632.83 2403.36 5915 103.43 146.16 1917 355.19 492.26 1918 778.67 1115.04 2919 109.60 135.85 1920 222.61 313.60 1921 519.88 765.35 3923 403.31 560.80 2924 255.17 454.00 2931 13.19 13.80 1932 259.80 396.68 1935 751.64 1182.40 2940 1349.64 1991.66 4942 647.05 995.20 2943 1290.64 1736.80 3944 521.81 784.80 2

11967.10 17280.48 46

- 66 -

Page 67: Easy Tri Eve Plus

EASYTRIEVE PLUS

4/24/86 REPORT PROCS EXAMPLE REPORT

SOCIALEMPLOYEE EMPLOYEE SECURITY GROSS

DEPT NAME NUMBER NUMBER PAY

911 ARNOLD LINDA 01963 281-36-2873 445.50GREEN BRENDA 12820 208-28-2315 365.60HAFER ARTHUR 09764 104-20-0956 121.95ISAAC RUTH 12641 418-46-1872 313.60KRUSE MAX 03571 284-36-5652 242.40LAROSN RODNEY 11357 554-70-3189 283.92POST JEAN 00445 190-32-2101 292.00POWELL CAROL 11710 579-50-4818 243.20REYNOLDS WILLIAM 05805 051-30-8680 174.15SMOTH CINDY 01730 578-38-7587 315.20STRIDE ANN 03890 467-56-4149 386.40YOUNG JANE 04589 118-34-8805 313.60

DEPT 911 TOTAL 3497.52

914 CROCI JUDY 08262 577-16-2985 376.00GRECO LESLIE 07231 388-18-6119 1004.00MANHART VIRGINIA 11602 298-34-4755 344.80RYAN PAMELA 10961 558-44-7609 399.20VETTER DENISE 01895 235-72-1049 279.36

DEPT 914 TOTAL 2403.36

FINAL TOTALS 5900.88

- 67 -

Page 68: Easy Tri Eve Plus

EASYTRIEVE PLUS

LIBRARY

FILE Statement

The FILE statement describes an input or output file and is coded in the Library section of an EASYTRIEVE PLUS program. The syntax of the FILE statement is determined by the types of system you are using to run EASYTRIEVE PLUS programs.

OS FILE Statement Syntax

FILE ddname +

file IStype VS ( [ES] [F] [PASSWORD] 'literal' ] )

device [CARD] +type

F lreclV maxlrecl + 4

record U blksizeformat FB (lrecl) blksize )

FULLTRK

VB (maxlrecl + 4 maxblksize + 4 )

FULLTRK

VBS (maxlrecl + 4 maxblksize + 4 )

FULLTRK

- 68 -

Page 69: Easy Tri Eve Plus

EASYTRIEVE PLUS

DOS FILE Statement Syntax

FILE dlblnameTlblname +

[SYSxxx] +

file IStype VS ( [ES] [F] [PASSWORD] 'literal'] )

device DISK [device-type]type REWIND

TAPE ( [NL [ # reels ] ] UNLOAD )NORWD

CARD

F lreclV maxlrecl + 4

record U blksizeformat FB (lrecl) blksize )

FULLTRK

VB (maxlrecl + 4 maxblksize + 4 )

FULLTRK

VBS (maxlrecl + 4 maxblksize + 4 )

FULLTRK

- 69 -

Page 70: Easy Tri Eve Plus

EASYTRIEVE PLUS

Virtual File Manager (VFM)

VFM provides an easy method for establishing temporary work files without special job control or file allocation statements. VFM is a sequential access method for program work files. It dynamically allocates space in memory for work files when sequencing a report or when producing multiple reports

When a virtual file is read back into the program, space is released and becomes available for reuse unless you code RETAIN on the statement

If the area in memory (default is 64K) is exhausted, VFM writes the excess data to a single spill area on disk

Syntax

FILE file-name F (lrecl) VIRTUAL [RETAIN]

F (lrecl)

F (lrecl) designates the record length

VIRTUAL

VIRTUAL causes the file to be created and maintained by the VFM

RETAIN

RETAIN causes VFM files to be retained for the duration of the EASYTRIEVE PLUS program execution

- 70 -

Page 71: Easy Tri Eve Plus

EASYTRIEVE PLUS

COPY Statement

The COPY statement duplicates the field definitions of a named file. You can code an unlimited number of COPY statements for any one file

Syntax

COPY (file-name)

When the same field-name is used in more than one file in the same activity, you must qualify duplicate field-name by adding the file-name as a prefix separated by a colon. Example : OUTFILE:NAME

Example

FILE INONEFLD-ONE 10 1 AFLD-TWO 11 3 N

FILE INTWO----- > COPY INONE

JOB INPUT INTOW NAME COPY-EXAMPLEIF INTWO : FLD-ONE** Logic **

EXIT Parameter

The EXIT parameter on the FILE statement invokes a user routine for every input or output operation for that file.

You use EXIT to access a routine that converts non-standard data files that EASYTRIEVE PLUS does not process directly.

EXIT is not valid for VFM, IMS/DLI or IDMS

Syntax

FILE file-name [EXIT (program-name [NR] +

USING ( field-name … ) [MODIFY] ) ] 'literal'

NR

NR has meaning only in DOS; NR indicates that the program is non-relocatable

- 71 -

Page 72: Easy Tri Eve Plus

EASYTRIEVE PLUS

USING

USING specifies the parameters to be passed. It is limited to working storage system, defined fields, and card literals

MODIFY

MODIFY specifies that the exit can inspect and modify each record after input or before output

ACTIVITY

CALL Statement

The CALL statement invokes an external subprogram. Usually, the CALLed program is an existing program in another language that performs a function otherwise unsupported by EASYTRIEVE PLUS

Syntax

CALL program-name [NR] USING ( field-name-1 … ) +

'literal'

[RETURNS field-name-2

MOVE Statement

You use the MOVE statement to transfer data from one location to another. MOVE is useful for moving data without conversion and for moving character strings with variable lengths.

You can move a field or literal to a field or move a file to a file A sending field longer than a receiving field is truncated on the right A longer receiving field is padded on the right with spaces or an alternate

fill character Spaces or zeroes can be moved to one or many fields

- 72 -

Page 73: Easy Tri Eve Plus

EASYTRIEVE PLUS

Syntax

The MOVE statement syntax has two formats

Format I

MOVE file-name-1 [send-length] TO file-name-2field-name-1 field-name-2literal

[receive-length] [FILL literal ]

When you specify Format 1, data moves from one field to another filling on the right. The FILL parameter allows you to place characters in the unused spaces of the new field (the default is space)

Example

MOVE NAME 20 TO HOLS-NAMEMOVE NAME CTR TO HOLD-NAME FILL '*'

Format 2

SPACESPACES

MOVE ZERO TO fiels-name-1 field-name-nZEROSZEROES

You can use Format 2 to initialize the receiving field.

Example

MOVE SPACES TO NAME, HOLD-NAME, HOLD-DIV

- 73 -

Page 74: Easy Tri Eve Plus

EASYTRIEVE PLUS

MOVE LIKE

MOVE LIKE moves the value of fields with identical names from one file to another while converting numeric data-types from one format to another

The rules for the assignment statement also apply to MOVE LIKE Because the same field-name can be used in more than one file, you must qualify

duplicate field-name by prefixing the field-name with the file-name and a colon

Syntax

MOVE LIKE file-name-1 to file-name-2

Example

FILE INFILENAME 17 20 ADEPT 98 3 NAMT 90 4 P 2

FILE OUTFIL1AMT 1 7 N 2NAME 8 20 A

JOB INPUT INFILE1 NAME MOVE-LIKE-EXAMPLE[logic]

*---- > MOVE LIKE INFILE1 TO OUTFIL1

** Logic **

User-Procedures (PROCs)

A user PROC is a group of user-written EASYTRIEVE PLUS statements designed to accomplish a task. You use a user PROC when identical logic is needed in several places in the activity

A user PROC must be invoked in the activity with a PERFORM statement

PERFORM Syntax

PERFORM proc-name

The proc-name may be one to forty characters long and must begin with a letter

You code the procedure at the end of the activity in which it is PERFORMed

- 74 -

Page 75: Easy Tri Eve Plus

EASYTRIEVE PLUS

PROC Syntax

proc-name** Logic **

END-PROC

Proc-name

Proc-name is the same name as in the PERFORM statement and is followed by a period, a space, and the keyword PROC

END-PROC

Every PROC must have an END-PROC. At END-PROC, control is returned to the statement following the PERFORM statement that invoked the PROC

Example

IF CODE = 1---- > PERFORM CODE1-RTN

ELSEPERFORM CODE2-RTN

END-IF** Logic **

----- > CODE1-RTN PROCORDER = 'NO'

END-PROCCODE2-RTN PROC

ORDER = 'YES'END-PROC

- 75 -

Page 76: Easy Tri Eve Plus

EASYTRIEVE PLUS

Nesting PROCs

A PERFORM statement within a procedure can invoke another procedure

Example

IF DEPT = 911PERFORM PROCA

END-IF

** Logic **PROCA PROC

IF ST = 'NY'PERFORM PROCB

ELSE---------- > TAX = GROSS * .05

END-IFEND-PROCPROCB PROC

TAX = GROSS * .1END-PROC

START/FINISH Parameters

You use the optional START and FINISH parameters of the JOB statements to automatically incorporate procedures into processing activities

Syntax

JOB INPUT file-name [NAME job-name][ START proc-name ] [FINISH proc-name ]

START Parameter

You use START to identify a procedure to be executed during initiation of the JOB activity

The procedure is invoked automatically after the file is opened but prior to reading the first input record

A typical START procedure might initialize working storage fields or establish a position in a keyed sequenced file

- 76 -

Page 77: Easy Tri Eve Plus

EASYTRIEVE PLUS

FINISH Parameter

You use FINISH to identify a procedure to be executed during the normal termination of the JOB activity

The procedure is invoked after the last input record is processed but before any files are closed

A typical FINISH procedure displays control information accumulated during execution of the JOB activity.

A FINISH proc is invoked if a STOP is encountered but it is not invoked if a STOP EXECUTE is encountered

GOTO Statement

You use the GOTO statement to modify the natural top-to-bottom logic flow in a program.

Syntax

GOTO labelGO TO JOB

GOTO

EASYTRIVE PLUS accepts either GOTO or GO TO

Label

Label refers to statement labels. A label can be up to 40 characters long. The first character must be alphabetic. GOTO label transfers control immediately to the first statement following the named label statement. (The label statement must be in the same activity or procedure)

JOB

GOTO JOB transfers control to the top of current JOB activity

ExampleJOB INPUT PERSNL NAME DIV-LIST

IF DIV = 'A'------------ > GOTO JOB

END-IFIF DIV = 'B'

- 77 -

Page 78: Easy Tri Eve Plus

EASYTRIEVE PLUS

------------ > GOTO CHECK-REG-ROUTINEEND-IF

** Logic **CHECK-REG-ROUTINE

DO WHILE/END-DO Statements

You use the DO WHILE and END-DO statements to provide a controlled loop for repetitive program logic

The logic between DO WHILE and END-DO is executed until the conditional expression on the DO WHILE statement is false

Conditional expressions follow the rules of IF statements

Syntax

DO WHILE conditional-expression

** Logic **END-DO

Example

JOB INPUT PERSNL NAME DO-EX-1CTR = 0

---- > DO WHILE CTR LT 10CTR = CTR + 1

** Logic **

END-DOIF …

Nesting Example

You can nest DO WHILE statements. (The inner logic loop must be completely within the outer logic loop)

JOB INPUT PAYROLL NAME DO-EX-2CTR1 = 0DO WHILE CTR1 LT 10

CTR2 = 0DO WHILE CTR2 LT 5CTR2 = CTR2 + 1

** Logic **

END-DOCTR1 = CTR1 + 1

- 78 -

Page 79: Easy Tri Eve Plus

EASYTRIEVE PLUS

** Logic **

END-DO

SORT

SORT is an activity that sequences an input file on fields specified as keys. SORT uses the interface to your system sort. You can sort on as many fields as your system allows.

Syntax

SORT file-name-1 TO file-name-2 +

USING (field-name [D] … ) +

NAME sort-name

File-name-1

File-name-1 is the input file to be sorted

File-name-2

File-name-2 is the output file

USING

USING field-name identifies those fields from file-name-1 that you use as sort keys. Specify sort keys in major to minor order

D

D optionally sorts the field contents in descending order (default = ascending order)

NAME sort-name

NAME sort-name identifies the sort activity for documentation purposes

Example

FILE PERSNL FB ( 150 1800 )NAME 1 10 ADEPT 11 5 NGROSS-PAY 16 4 P 2

FILE PAYSORT FB( 150 1800 )--- > SORT PERSNL TO PAYSORT

- 79 -

Page 80: Easy Tri Eve Plus

EASYTRIEVE PLUS

USING (DEPT GROSS-PAY) +NAME SORT-EXAMPLE-1

SORT Procedure

You use SORT procedure to select only certain records for sorting and/or to modify the contents of records before a sort

A SORT procedure immediately follows the SORT statement You invoke a SORT procedure with the BEFORE parameter The SORT procedure executes for each record from file-name-1 prior to passing

the record to the sort

Syntax

SORT file-name-1 TO file-name-2 +USING (field-name [D] … ) +NAME sort-name +[BEFORE proc-name]

BEFORE

BEFORE proc-name identifies the procedure

When you use BEFORE, you must execute a SELECT statement for each record that you want to sort to the output file

A SELECTed record outputs only once, even if SELECTed more than once in the procedure

Any record not SELECTed does not go to the sorted file

- 80 -

Page 81: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example

This example illustrates the use of the SORT activity and SORT procedures

FILE PERSNL FB( 150 1800)NAME 1 10 ADEPT 11 5 NGROSS-PAY 16 4 P 2

FILE PAYSORT F ( 19 ) VIRTUALSORT-NAME 1 10 ASORT-DEPT 11 5 NSORT-GROSS-PAY 16 4 P 2

JOB INPUT PERSNL NAME ACT-1PRINT RPT1

REPORT RPT1LINE 1 NAME DEPT GROSS-PAY

-------- > SORT PERSNL TO PAYSORT USING (DEPT + GROSS-PAY D)BEFORE SELECT-REC NAME SORT-ACTIVITYSELECT-REC. PROC

IF GROSS-PAY GE 500SELECT

END-IFEND-PROCJOB INPUT PAYSORT NAME PROCESS-SORTED-FILE ** Logic **

- 81 -

Page 82: Easy Tri Eve Plus

EASYTRIEVE PLUS

FILE PROCESSING

EASYTRIEVE PLUS can process files or data bases from the simplest to the most complex. File types include sequential access method (SAM) indexed sequential access method (ISAM), virtual storage access method (VSAM), virtual file manager (VFM) files, IMS/DLI, and IDMS data bases

You can let EASYTRIEVE PLUS do all your file processing automatically, or you can control some or all of the operations yourself

Automatic I/O (under system control) includes the files specified for input on the JOB and SORT statements, and the files specified for output on the SUMMARY parameter of the REPORT statement

Programmer controlled I/O includes the GET, POINT, and READ statements for input, and the PUT, WRITE, PRINT, DISPLAY, and SORT statements for output

You can not have automatic file access and programmer controlled file access to the same file within the same activity except when using the POINT command

This Student Guide discusses all file types except ISAM. If you need information about ISAM files, ask your instructor.

GET Statement

The GET statement retrieves the next record of the named file into the file input area.

Syntax

GET file-name

file-name - identifies the input file

(EOF) - Test for end-of-file (EOF) when using the GET command

- 82 -

Page 83: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example

FILE MASTER FB ( 150 1800 )EMP# 9 5 NNAME 17 16 AGROSS 94 4 P 2

JOB INPUT NULL NAME READ-SEQ-MAN------- > GET MASTER

IF EOF MASTERSTOP

END-IFIF GROSS > 500

PRINT RPT1END-IF

REPORT RPT1LINE 1 EMP# NAME GROSS

You use NULL in the JOB statement to inhibit automatic input

PUT Statement

The PUT statement outputs a file sequentially

Syntax

PUT outfile [FROM file-name]

Example 1

FILE PERSNL FB ( 150 1800 )EMP# 9 5 NNAME 17 16 AGROSS 94 4 P 2

FILE NEWPAY2 F (20) VIRTUAL RETAINNAME 1 16 AGROSS 17 4 P 2

JOB INPUT PERSNL NAME PUT-EXAMPLE** Logic **

MOVE LIKE PERSNL TO NEWPAY2------------- > PUT NEWPAY2

- 83 -

Page 84: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example 2

FILE MASTER FB ( 150 1800 )EMP# 9 5 NNAME 17 16 AGROSS 94 4 P 2

FILE OUTMAST FB ( 150 1800 )JOB INPUT MASTER NAME CREATE-SEQ

IF GROSS > 500*

---------- > PUT OUTMAST FROM MASTER*

END-IF

- 84 -

Page 85: Easy Tri Eve Plus

EASYTRIEVE PLUS

VSAM

VSAM File Statement

You use the following parameters when working with VSAM files

Syntax

FILE {file-name} VS ( [ES] [F] [PASSWORD] 'literals' ] +[CREATE RESEST ] [UPDATE] )

VS

VS designates a VSAM file. Default parameters for VSAM file processing are Key Sequenced Data Sets (KSDS) or Relative Record Data Set (RRDS) with records of undefined length

ES

Code ES to indicate an Entry Sequenced Data Set (ESDS)

F

Code F if all records in the file are of the same length. This improves the efficiency of SORT activities and SEQUENCE statement

PASSWORD literal

Literal is the optional one to eight character password for the VSAM file. You can specify the password as either an alphabetic literal or a hexadecimal literal. Enclose these literals in apostrophes

CREATE

Use the CREATE option to load a VSAM file.

RESET

You can reload an existing VSAM file by coding the RESET option with CREATE. RESET assumes that the file was defined by IDCAMS with the VSAM attributes REUSE

- 85 -

Page 86: Easy Tri Eve Plus

EASYTRIEVE PLUS

UPDATE

Code the UPDATE option if you wish to update the file with the WRITE or PUT statement

VSAM File Creation (Loading)

The FILE statement and the PUT statement are used to create (load) VSAM files. The PUT statement provides for sequential file output to VSAM files

Example

FILE MASTER FB ( 150 1800 )EMP# 9 5 NNAME 17 16 AGROSS 94 4 P 2

-------------- > FILE OUTMAST VS (CREATE RESET)JOB INPUT MASTER NAME CREATE-VSAM

-------------- > PUT OUTMAST FROM MASTER STATUSIF OUTMAST : FILE-STATUS NOT ZERO

DISPLAY 'LOAD ERROR STATUS IS : ' +OUTMAST : FILE-STATUS

STOPEND-IFPRINT RPT1

REPORT RPT1LINE 1 EMP# NAME GROSS

STATUS

When you specify STATUS, VSAM return codes are returned to the system defined field FILE-STATUS.

FILE-STATUS

FILE-STATUS is a system defined field which you can test to identify the result of a VSAM input/output operation

- 86 -

Page 87: Easy Tri Eve Plus

EASYTRIEVE PLUS

VSAM Input

VSAM input can be sequential or random. Sequential input can be automatic or

programmer-controlled

Example - Automatic Sequential

FILE MASTER VSEMP# 9 5 NNAME 17 16 AGROSS 94 4 P 2

---------- > JOB INPUT MASTER NAME READ-VSAM-AUTOIF GROSS > 500

PRINT VSAM-REPORTEND-IF

REPORT VSAM-REPORTLINE 1 EMP# NAME GROSS

- 87 -

FILE-STATUSValue

MEANING

0 Operation performedSuccessfully

4 End-of-file duringGET

8 (a) Duplicate key fora record being output with PUT or WRITE(b) Additional records withthe same key exist alternate index duringa GET operation.

12 Keys not 1n sequence duringPUT operation

16 Record not found duringREAD operation

Page 88: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example - Programmer Controlled Sequential

You use the GET statement for programmer controlled input

FILE MASTER VSEMP# 9 5 NNAME 17 16 AGROSS 94 4 P 2

JOB INPUT NULL NAME READ-VSAM-MAN---------- > GET MASTER STATUS

IF EOF MASTER OR FILE-STATUS NOT ZEROSTOP

END-IFIF GROSS > 500

PRINT VSAM-REPORTEND-IF

REPORT VSAM-REPORTLINE 1 EMP# NAME GROSS

- 88 -

Page 89: Easy Tri Eve Plus

EASYTRIEVE PLUS

POINT Statement

You use the POINT statement to establish a position in a keyed file. (Key is the key defined to VSAM and not necessarily to EASYTRIEVE PLUS)

Data becomes available only after the next successful sequential retrieval either by an automatic file input or a GET statement

Syntax

EQPOINT file-name = field-name STATUS

GE literal> =

File-name

File-name must be the same as on a FILE statement that describes an indexed, keyed, or relative-record file

Field-name or Literal

Any valid field-name or literal can be used as a key value for the POINT statement

Example

FILE VSIN VSDEPT 9 5 N

JOB INPUT VSIN START POINT-PROC NAME POINT-EX

** Logic **

POINT-PROC. PROC---------- > POINT VSIN GE 300 STATUS

IF EOF VSIN OR FILE-STATUS NOT ZEROSTOP

END-IFEND-PROC

- 89 -

Page 90: Easy Tri Eve Plus

EASYTRIEVE PLUS

READ Statement

The READ statement provides random access to keyed VSAM and to relative-record VSAM files.

Syntax

field-nameREAD file-name KEY 'literal' STATUS

File-name

File-name is the VSAM file-name

Field-name / Literal

Field-name contains the value of the VSAM key to be found. This key value can also be expressed as a literal

Example : Programmer Controlled Random

FILE PAYROLLEMP-NO 1 3 N

FILE DNAME VSEMP-NAME 40 10 A

*JOB INPUT PAYROLL NAME READ-EXAMPLE

------- > READ DNAME KEY EMP-NO STATUSIF DNAME : FILE-STATUS NOT ZERO

DISPLAY ERRRPT 'ERROR READING VSAM +FILE WITH KEY : EMP-NO +

FILE-STATUS IS DNAME : FILE-STATUSGOTO JOB

END-IF

- 90 -

Page 91: Easy Tri Eve Plus

EASYTRIEVE PLUS

WRITE

You use the WRITE statement to add a new record, update an existing record, or delete a record from a VSAM file

When you use WRITE you must specify the UPDATE parameter on the FILE statement

Before you can issue a WRITE to delete or update, you must have the record in the buffer area

Syntax - Format 1

You use Format 1 when adding or updating a VSAM record

WRITE file-name-1 UPDATE [ FROM file-name-2 ] STATUSADD

Example

FILE TRANSDEPT 12 3 NGROSS 15 4 P 2

*FILE PAYVS VS (UPDATE)

GROSS 15 4 P 2*JOB INPUT TRANS NAME UPDATE-PGMREAD PAYVS KEY DEPT STATUSIF PAYVS : FILE-STATUS = 16 * RECORD NOT FOUND

--------- > WRITE PAYVS ADD FROM TRANS STATUSPERFORM ADD-STATUS-CHKGOTO JOB

END-IFIF PAYVS : FILE-STATUS = 0 * RECORD NOT FOUND

MOVE LIKE TRANS TO PAYVS--------- > WRITE PAYVS UPDATE STATUS

PERFORM UPDATE-STATUS-CHKGOTO JOB

END-IF

- 91 -

Page 92: Easy Tri Eve Plus

EASYTRIEVE PLUS

Syntax - Format 2

You use Format 2 for deleting a VSAM record

WRITE file-name-1 DELETE STATUS

Example

FILE TRANSTRANS-KEY 14 3 ATRANS-CODE 17 1 A * TRANS-CODE value of

means Delete*FILE PAYVS VS (UPDATE)JOB INPUT TRANS NAME VSAM-DELETEIF TRANS-CODE = 'D'

READ PAYVS KEY TRANS-KEY STATUSIF FILE-STATUS = 0

---------- > WRITE PAYVS DELETE STATUSPERFORM WRITE-STAT-CHECK

ELSEDISPLAY 'ERROR IN STATUS CHECK'

END-IF

Synchronized File Processing

The Synchronized File Processing (SFP) facility can be used with one file or multiple files.

Single-File Keyed Processing - one file Synchronized File Input - multiple files

Single-File Keyed Processing

Using Synchronized File Processing on a single file allows you to compare the contents of a key field or fields from one record to the next and to use IF tests to group records according to keys. The file name is coded on the JOB INPUT statement as follows :

JOB INPUT (filename KEY (keyfield…) )

- 92 -

Page 93: Easy Tri Eve Plus

EASYTRIEVE PLUS

Single-file keyed processing lets you use IF tests to determine where a current key ends and a new key starts. For example :

IF FIRST-DUP filename OR NOT DUPLICATE filename.

The above IF statement determines the start of a new key.

IF LAST-DUP filename OR NOT DUPLICATE filename

The above IF statement determines the end of the current key

Note that the file must be in ascending order by its key value(s)

Synchronized File Input

Synchronized file input is a method of coordinating the input of multiple fields. EASYTRIEVE PLUS automatic input includes a universally adaptable match/merge algorithm. Special conditional expressions help to determine simple, yet precise file relationships.

The match/merge algorithm is based on the following assumptions and rules :

Any number of files are capable of being processed Keys may be any defined field in the library section of an EASYTRIEVE PLUS

program as long as they are of like data types. Each file must have the same number of keys

Keys and files are major to minor Duplicate records are exhausted from the most minor to the major file START, FINISH, and NAME parameters can be included on the JOB statement Processing continues until end-of-file is encountered on all files

Syntax

The JOB statement now looks like this.

JOB INPUT (file-1 KEY (field-1-a field-1-n … ) + file-2 KEY (field-2-a field-2-n … ) + file-n KEY (field-n-a field-n-n … ) )NAME jobname

The INPUT parameter designates files and their keys for synchronized file input.

- 93 -

Page 94: Easy Tri Eve Plus

EASYTRIEVE PLUS

Representation of Synchronized Input Flow

The following discussion illustrates how EASYTRIVE PLUS presents records for processing.

Three Data Files (in order by key)

The JayMat Corporation has a chain of three stores and each store maintains its credit card purchases on a separate file. The following chart shows the data in these files. The data is arranged in this format :

Account # / Account ID / Purchase Amount

Store 1 Store 2 Store 3

1020 P 23.50 1023 P 103.45 1020 P 45.681023 P 127.89 1027 M 12.90 1027 P 11.681027 M 38.83 1027 S 9.35 1029 P 129.461027 S 323.92 1029 M 138.44 1031 P 4.881075 M 22.88 1029 S 3.00 1053 P 64.331075 S 221.79 1052 P 29.89 1075 M 30.641077 P 57.84 1053 P 18.99 1075 S 388.03

Example

This example shows the coding required to synchronize these files

FILE STORE1 FB ( 150 1800 )ACCT# 1 4 N

FILE STORE2 VSACCT# 21 4 N

FILE STORE3 F (220)ACCT# 16 4 N

*JOB INPUT (STORE1 KEY ACCT# +

STORE2 KEY ACCT# + STORE3 KEY ACCT# +NAME THREE-FILE-MATCH

- 94 -

Page 95: Easy Tri Eve Plus

EASYTRIEVE PLUS

Record Presentation

STORE1 STORE2 STORE3

ACCT# ID ACCT# ID ACCT# ID1 1020 P -- 1020 P2 1023 P 1023 P --3 1027 M 1027 M 1027 P4 1027 M 1027 S --5 1027 S -- --6 -- 1029 M 1029 P7 -- 1029 S --8 -- -- 1031 P9 -- 1052 P --10 -- 1053 P 1053 P11 1075 M -- 1075 S12 1075 M -- 1075 S13 1075 S -- --14 1077 P -- --15 -- 1080 P --

This chart shows how EASYTRIEVE PLUS presents the records from STORE1, STORE2, and STORE3 for processing. The -- (dashes) indicate that no records from that store are presented for processing at that time.

Special Tests for Synchronized Files

These conditional statements allow you to determine the relationships between the current records.

MATCHED

MATCHED tests to see if keys on all current records are matched

Syntax

IF [NOT] MATCHED [ (file-name-1 file-name-2 … file-name-n) ]

Examples

IF MATCHED ( STORE1 STORE2 )

IF MATCHED

- 95 -

Page 96: Easy Tri Eve Plus

EASYTRIEVE PLUS

Checking for Duplicate Records

Syntax

IF [NOT] DUPLICATE file-nameFIRST-DUPLAST-DUP

DUPLICATE

DUPLICATE tests to see if a duplicate record exists on the same file

FIRST-DUP

FIRST-DUP tests to see if the record is the first in a series of duplicates

LAST-DUP

LAST-DUP tests to see if the record is the last in a series of duplicates

File Presence Test and End of File Test (EOF)

File presence tests to see if there is a record available for processing from a named file or if end-of-file (EOF) has been reached.

Syntax

IF [NOT] [EOF] file-name

- 96 -

Page 97: Easy Tri Eve Plus

EASYTRIEVE PLUS

Possible Tests for Record Pairs

MASTER TRANS TESTS

ACCT# ID ACCT# ID

4741 TLN 4741 CCR IF MATCHEDIF NOT DUPLICATE TRANS

4742 DSD 4742 MGG IF MATCHEDIF DUPLICATE TRANSIF FIRST-DUP TRANS

4742 DSD 4742 MES IF DUPLICATE TRANS4742 DSD 4742 CM IF LAST-DUP TRANS4743 DV 4743 DAP IF MATCHED (MASTER TRANS)4744 JPF 4744 NAM IF DUPLICATE MASTER4744 JPF 4744 TBG IF LAST-DUP TRANS4744 SHG -- IF NOT TRANS4745 TMW -- IF MASTER

-- 4747 PSI IF TRANS4749 JKB -- IF MASTER4749 JKJ -- IF NOT TRANS

-- 4750 EZT IF EOF MASTER

NOTE : When an ID is repeated, it shows that EASYTRIEVE PLUS is holding that record for processing while it brings in duplicate records from the second file. ACCT# is the key in this example.

- 97 -

Page 98: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example 1 - Output to Two Files

Input Files

In this example the MASTER file contains one record for each valid account number. The STORE1 file contains one record for every transaction made within a certain time.

1023 MASTER 1025 P 83.211027 MASTER 1027 S 14.831029 MASTER 1027 S 83.231075 MASTER 1027 S 143.21

Code

The following coding produces two new files from MASTER and STORE1.

FILE STORE1 FB ( 45 900 )ACCT-NO-1 1 3 PACCT-ID 4 1 AACCT-NAME 5 30 APURCHASE AMT 35 3 P 2

FILE MASTER FB ( 30 600 )ACCT-NO-MAST 1 3 P

FILE INVALID FB ( 45 900 )FILE MERGED FB ( 45 900 )JOB INPUT (MASTER KEY ACCT-NO-MAST +

STORE1 KEY ACCT-NO-1) +NAME TWO-FILE-MERGE

IF NOT STORE1GOTO JOB

END-IFIF NOT MASTER

PUT INVALID FROM STORE1GOTO JOB

END-IFIF NOT DUPLICATE STORE1 OR +

LAST-DUP STORE1PUT MERGED FROM STORE1PUT MERGED FROM MASTER

ELSEPUT MERGED FROM STORE1

END-IF

- 98 -

Page 99: Easy Tri Eve Plus

EASYTRIEVE PLUS

Record Presentation for Processing

MASTER STORE1

1020 MASTER 1020 P 53.231021 MASTER --1023 MASTER 1023 M 15.87-- 1025 P 83.211027 MASTER 1027 S 14.831027 MASTER 1027 S 83.231027 MASTER 1027 S 143.211029 MASTER --1075 MASTER --

Representation of Output Files

For a single transactions on an account number EASYTRIEVE PLUS writes a record from the transaction file, then the matching record from the master file. For multiple transactions on a single account number EASYTRIEVE PLUS writes all transactions to the merged file first then the matching record from the master file.

MERGED contains records from both input files for each transaction INVALID contains a record for each invalid transaction from STORE1 file

MERGED INVALID

1020 P 53.23 1025 P 83.211020 MASTER1023 M 15.871023 MASTER1027 S 14.831027 S 83.231027 S 143.211027 MASTER

- 99 -

Page 100: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example 2 - Updating a Master File

Synchronized multifile input and special tests simplify the update. The following example assumes at most one transaction record per master record

FILE PLDMSTR VSMASTER-KEY 1 10 A

*FILE TRANS VS

TRANS-KEY 1 10 A*FILE NEWMSTR FB ( 150 1800 )*IF DUPLICATE TRANS

PRINT DUPLICATE-TRANS-RPTGOTO JOB

END-IF*IF MATCHED

PERFORM MASTER-UPDATEPERFORM WRITE-NEW-MASTERGOTO JOB

END-IF*IF OLDMSTR

PERFORM WRITE-NEW-MASTERGOTO JOB

END-IF*IF TRANS

PERFORM MASTER-CREATEPERFORM WRITE-NEW-MASTERGOTO JOB

END-IF** User PROCs **

- 100 -

Page 101: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example 3 - Testing for Duplicates on One File

FILE PERSNL FB ( 150 1800 )NAME 17 16 AEMP# 9 5 N

FILE ATTEND F (5) CARDMAX-VALUE 1 5 N

FILE PERSSORT F ( 150 ) VIRTUALCOPY PERSNL

SORT PERSNL TO PERSSORT USING (EMP#)JOB INPUT (PERSSORT KEY EMP# +

ATTEN KEY MAX-VALUE +NAME DUP-ON-ONE-FILE

IF DUPLICATE PERSSORTPRINT DUP-EMP#

END-IFREPORT DUP-EMP#

LINE 1 EMP# NAMEEND99999

- 101 -

Page 102: Easy Tri Eve Plus

EASYTRIEVE PLUS

Multiple Job Activities Exercise

Code all required activity statements to match three files by employee number. Create file and field-names where needed. Two files must be sorted first. The following rules apply :

Select the information for a report if all three files match If only the primary and secondary files match print a message to another printer If there are duplicate on the third file use only the first of the duplicates

TABLES/INDEXING/ARRAYS

Tables

A table is a collection of uniform data records in a form suitable for quick reference. Each table entry has :

A search argument (keyword ARG) that uniquely identifies that entry A description (keyword DESC) is the data associated with the argument

The user's objective is to obtain the description from a table of values based on the search argument.

A table file must be arranged in ascending order by argument No duplicate arguments can be placed in the file You can use any number of tables in a job A minimum of three entries is required in a table

ARG DESC____ _____

01 ALABAMA02 ALASKA03 ARIZONA…47 WASHINGTON48 WEST VIRGINIA49 WISCONSIN50 WYOMING

Syntax

- 102 -

Page 103: Easy Tri Eve Plus

EASYTRIEVE PLUS

FILE file-name TABLE INSTREAMLiteral

TABLE

The TABLE parameter is specified on the FILE statement. external table files must be sequentially accessible

INSTREAM

INSTREAM denotes that the table file immediately follows the file description. Data for an INSTREAM table immediately follows the ARG and DESC field definitions

Literal

Literal specifies the number of entries in an external table. Specify a value here only if the number of entries is greater than 256

ENDTABLE must be the last entry in the instream table data and must be coded in column 1 through 8

Instream Example

FILE SATTBL TABLE INSTREAMARG 1 2 NDESC 4 15 A

01 ALABAMA02 ALASKA03 ARIZONA…47 WASHINGTON48 WEST VIRGINIA49 WISCONSIN50 WYOMINGEND TABLE

- 103 -

Page 104: Easy Tri Eve Plus

EASYTRIEVE PLUS

SEARCH Statement

You use the SEARCH statement to perform an in-core binary search of a table. This is a very efficient access method. SEARCH can be :

Coded any place within a JOB activity Issued any number of times against any number of tables

Syntax

SEARCH file-name WITH field-name-1 GIVING field-name-2

File-name is the table name. Field-name-1 is the name of a field which contains a value that is compared to the

search argument. It must be the same length and type as the argument Field-name-2 is the name of a field into which the description is placed if a match

exists between field-name-1 and the search argument. It must be the same length and type as the description

Example - Searching an External Table

FILE PERSNLNAME 17 8 ASTATE 69 2 AZIP 71 5 NGROSS-PAY 94 4 P 2POST-OFFICE-DESC W 20 A

FILE ZIPTABLE TABLE 5000ARG 1 5 NDESC 7 20 A

JOB INPUT PERSNL NAME TABLE-SEARCHIF STATE = 'DC' 'IL'

SEARCH ZIPTABLE WITH ZIP GIVING POST-OFFICE-DESCIF NOT ZIPTABLE

POST-OFFICE-DESC = 'BAD ZIP CODE FOUND'END-IF

PRINT STATE-REPORTEND-IFREPORT STATE-REPORT

SEQUENCE STATECONTROL STATETITLE 1 'REPORT OF EMPLOYEE SALARIES BY STATE'LINE 1 STATE NAME GROSS-PAY ZIP POST-OFFICE-DESC

- 104 -

Page 105: Easy Tri Eve Plus

EASYTRIEVE PLUS

Exercise

Code an EASYTRIEVE PLUS program to accomplish the following :

Read the Personnel sample file and create a report listing the BRANCH-DESC, NAME, and PAY-GROSS fields on each line

Use an instream table of branch name with the following table data : for 01 use NORTH, for 02 use SOUTH and so on through branch 04

Select all records for the report

- 105 -

Page 106: Easy Tri Eve Plus

EASYTRIEVE PLUS

Indexing

Indexing is a technique that you use to maintain control over the relative position of a pointer in an array

Syntax

field-name start-location length type +[decimal-position] OCCURS nn INDEX index-name

OCCURS nn

OCCURS is the number of elements (occurrences of field-name) in the array

INDEX index-name

INDEX index-name is the field containing the displacement for the pointer in an array. The value of index-name controls access to the desired data occurrence. This field is automatically defined and set to zero. You should reset the index to zero before processing each subsequent record.

Arrays

Arrays can be processed sequentially or randomly

Sequential

index-name = index-name + element length

Random

index-name = (occurrence - 1) * element length

- 106 -

Page 107: Easy Tri Eve Plus

EASYTRIEVE PLUS

Examples

If a file contains an array, then you use this method of accessing the information in the array.

Index value |O |3 |6 |9 |12_|_|_|J|A|N|F|E|B|M|A|R|A|P|R|M|A|Y|_|_|_ | | | | | 101 104 107 110 113

Position

The field definition for the array would be :MO-NAME 101 3 A OCCURS 12 INDEX MO-INDEX

MO-NAME is the data to be accessed. The first element in the array starts in location 101 and has a length of 3 bytes.

To process the MO-NAME sequentially use :

MO-INDEX = MO-INDEX + 3

To process the MO-NAME randomly and access the 4th MO-NAME use :

MO-INDEX = ( 4 - 1 ) * 3Or

MO-INDEX = 9

An array can be created in working storage and accessed in this manner.

FILE PERSNL FB(150 1800)REGION 1 1 NDATE-OF-HIRE 103 6 N HEADING ('DATE OF' 'HIRE') MASK '99/99/99MONTH-OF-HIRE DATE-OF-HIRE 2 N HEADING ('NUMERIC' 'MONT')DAY-OF-HIRE DATE-OF-HIRE + 2 2 NYEAR-OF-HIRE DATE-OF-HIRE + 4 2 N

* NAME-LIST W 36 A VALUE 'JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC' * MO-NAME NAME-LIST 3 A OCCURS 12 INDEX MO-INDEX +

HEADING ('ALPHA' 'NAME') * JOB INPUT PERSNL NAME ARRAY-SEARCH IF REGION = 5 MO-INDEX = (MONTH-OF-HIRE - 1) * 3

PRINT NEWREPT END-IF * REPORT NEWREPT LINESIZE 80

LINE MO-INDEX MONTH-OF-HIRE MO-NAME

- 107 -

Page 108: Easy Tri Eve Plus

EASYTRIEVE PLUS

OUTPUT

NUMERIC ALPHAMO-INDEX MONTH NAME

18 07 JUL9 04 APR15 06 JUN6 03 MAR12 05 MAY30 11 NOV33 12 DEC18 07 JUL

01 JAN27 10 OCT3 02 FEB24 09 SEP21 08 AUG30 11 NOV21 08 AUG27 10 OCT

01 JAN33 12 DEC

- 108 -

Page 109: Easy Tri Eve Plus

EASYTRIEVE PLUS

Examples

Refer to the following input in examining the examples presented.

REGION A … REGION B …

R SLS YTD NO OF SLS YTD NO OF … R SLS YTD NO OF …C E MAN SALES $ CUSTS MAN SALES $ CUSTS … E MAN SALES $ CUSTS …O G # # … G #

1 SALES 1 SALES 2 SALES 1

4 REGIONS6 SALESMEN PER REGION

Report 1 - One-dimension Array Processing

1/19/84 YTD SALES TOTALS PAGE 1ONLY REGION A

CO YTD-TOTAL-$

1 43,691.722 37,812.40

(Assumes 4 regions A-D and 6 salesmen per region. )

- 109 -

Page 110: Easy Tri Eve Plus

EASYTRIEVE PLUS

Code for Report 1

FILE SLSMAST*CO 1 1 AREGION 2 1 ASLS-INFO 3 10 A OCCURS 6 INDEX SLS-INDEX

SALESMAN# SLS-INFO 2 AYTD-SALES SLS-INFO + 2 5 P 2NO-OF-CUSTS SLS-INFO + 7 3 N O

*CTR W 2 P 0YTD-TOTAL-$ W 6 P 2JOB INPUT SLSMAST NAME INDEX-1MOVE ZEROES TO CTR, YTD-TOTAL-$, SLS-INDEXDO WHILE CTR LT 6

YTD-TOTAL-$ = YTD-TOTAL-$ + YTD-SALESCTR = CTR + 1SLS-INDEX = SLS-INDEX + 10

END-DOPRINT RPT1REPORT RPT1

TITLE 1 'YTD SALES TOTALS'TITLE 2 'ONLY REGION A'LINE 1 CO YTD-TOTAL-$

- 110 -

Page 111: Easy Tri Eve Plus

EASYTRIEVE PLUS

Subscripts

Subscripts are an alternate method available to select an individual element from an array. The use of subscripts removes from you the requirement of computing the index value, and places it on EASYTRIEVE PLUS.

Example With Subscripts

FILE PERSNL FB(150 1800)REGION 1 1 NDATE-OF-HIRE 103 6 N HEADING ('DATE OF' 'HIRE') MASK '99/99/99MONTH-OF-HIRE DATE-OF-HIRE 2 N HEADING ('NUMERIC' 'MONT')DAY-OF-HIRE DATE-OF-HIRE + 2 2 NYEAR-OF-HIRE DATE-OF-HIRE + 4 2 N*

NAME-LIST W 36 A VALUE 'JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC' *

MO-NAME NAME-LIST 3 A OCCURS 12 +HEADING ('ALPHA' 'NAME')

*JOB INPUT PERSNL NAME ARRAY-SEARCHIF REGION = 5

PRINT NEWREPTEND-IF

*REPORT NEWREPT LINESIZE 80

LINE MONTH-OF-HIRE MO-NAME (MONTH-OF-HIRE)

Output

NUMERIC ALPHAMONTH NAME

07 JUL04 APR06 JUN03 MAR05 MAY

/-------------/-----------/-------------/11 NOV08 AUG10 OCT01 JAN12 DEC

- 111 -

Page 112: Easy Tri Eve Plus

EASYTRIEVE PLUS

Report 2 - Two-dimension Processing

1/19/84 YTD SALES TOTALS PAGE 1BY REGION

CO REGION YTD-TOTAL-$

1 A 43691.72B 47668.79C 45571.10D 30618.75

1 167550.36

2 A 37812.40B 41197.83C 35617.14D 29818.47

2 144445.84….. …..

(Assumes 4 regions (A-D); 6 salesmen per region.)

- 112 -

Page 113: Easy Tri Eve Plus

EASYTRIEVE PLUS

Code for Report 2

FILE SLSMASTCO 1 1 AREG-GROUP 2 61 A OCCURS 4

REGION REG-GROUP 1 ASLS-INFO REG-GROUP + 1 10 A OCCURS 6SALESMAN# SLS-INFO 2 NYTD-SALES SLS-INFO +2 5 P 2NO-OF-CUSTS SLS-INFO +7 3 N O

YTD-TOTAL-$ W 6 P 2REG-SUB W 3 PSLS-SUB W 3 P

JOB INPUT SLSMAST NAME INDEX-2REG-SUB = 1

DO WHILE REG-SUB LE 4MOVE ZEROES TO YTD-TOTAL-$SLS-SUB = 1

DO WHILE SLS-SUB LE 6 YTD-TOTAL-$ = YTD-TOTAL-$ + YTD-SALES(REG-SUB SLS-SUB)

SLS-SUB = SLS-SUB + 1END-DOPRINT SALES-BY-REGIONREG-SUB = REG-SUB + 1

END-DOREPORT SALES-BY-REGIONCONTROL COTITLE 1 'YTD SALES TOTALS'TITLE 2 'BY REGION'LINE CO REGION YTD-TOTAL-$

- 113 -

Page 114: Easy Tri Eve Plus

EASYTRIEVE PLUS

EXCERCISES

SORT/PUT/READ Exercise

Code an activity to create a sorted file of only REGION 4, non-zero GROSS-PAY records, in descending GROSS-PAY order. Taking the sorted records, obtain a job description for the employee from a VSAM file using an employee number as a key. Select records for a report only if a job description is found on the VSAM file. For the missing job descriptions, output a work file containing the employee's NAME, GROSS-PAY, and NUMBER.

FILE PAYFILE . . .. . .REGION 1 1 NEMP-NO 9 5 NEMP-NAME 17 20 AGROSS-PAY 94 4 P 2. . .

FILE EMPINFO VSEMP-KEY 2 5 NDESCRIPTION 30 10 A

Index Exercises

1. Code the same program as the previous SORT/PUT/READ exercise but use a table look-up instead of a READ

2. Code the library and logic to access all 12 occurrences of the following example, accumulating the amounts until one amount has zero or until all 12 have been accessed. At that point, select the information for a report.

- 114 -

Page 115: Easy Tri Eve Plus

EASYTRIEVE PLUS

MACROS

OVERVIEW

In this section you will learn about macros; what they are and how they are used in an EASYTRIEVE PLUS program. You will also see examples of macros. These examples have been provided to simulate your thinking on ways you can use macros. By using macros you can simplify end user programming and you own regular routines.

Objective

Upon completion of this section you will be able to create, test, and invoke macros to simplify routine tasks and meet end user needs.

GENERAL INFORMATION

Macros can be used for any or all places of an EASYTRIEVE PLUS program. You can use macros to provide shortcuts for your end users in many ways. You can also use macros to simplify some of your programming routines.

Macro Applications

The following list is provided to give you ideas on how to use macros :

Data Dictionary - You can store file and field definitions for frequently requested files in a macro. This eliminates the need to code field definitions every time a file is used in an EASYTRIEVE PLUS program.

Commonly Used Routines - If you find that you have certain routines that are used regularly, they can be made into a macro and recoding of these routines can be avoided.

Report Templating - Regularly generated reports can be stored as a macro and recalled as needed.

Simulate Query - In this application an entire EASYTRIEVE PLUS program would be stored in a macro and the end user would code only a single line to produce a report

Logic Templating - Frequently occurring logic patterns may be stored as macros for use in a variety of programs

Simple Presentation of Data - Data description and record presentation from any file structure can be controlled. When this information is placed in a macro the complexity of data structures is hidden from the user.

Control Access to Data - You can limit the fields available for user processing by coding only the fields you want them to have accessible in the macros in the data dictionary.

- 115 -

Page 116: Easy Tri Eve Plus

EASYTRIEVE PLUS

CREATING MACROS

There are two parts to every macro; a prototype statement and the macro code.

Prototype Statement

A prototype statement identifies the code which follows as a macro and sets up substitution parameters if they are to be used. You code the prototype statement first in a macro.

MACRO [n] [positiona] [keyword]

You use MACRO to identify the start of a macro Two types of parameter substitution are available - positional and keyword

Positional - Ordered

– No default substitution– Must be supplied when invoking a macro or will be null (treated as nonexistent)

Keyword - Unordered

– Must supply default values– Useful when default values are needed or for infrequently used parameters– May be supplied or allowed to default when invoking a macro

Note : Quotation marks can be used to delimit parameter values, but the quotes will not be passed.

Macro Code

The second part of a macro consists of the EASYTRIEVE PLUS statements you wish to execute as the macro.

Example

A macro called PAYLIB exists in your library containing :

MACROFILE PAYROLL

NAME 1 20 ADEPT 21 2 AGROSS 23 4 P 2NET 27 4 P 2DEDUCTIONS W 4 P 2

- 116 -

Page 117: Easy Tri Eve Plus

EASYTRIEVE PLUS

Macro Invocation

Once you have created and stored a macro you can use it in any program

Syntax

%macro-name macro-parameters

The % (percent sign) directs EASYTRIEVE PLUS to retrieve a macro with the designated name

Macro-parameters are the parameters you want to be substituted in the macro (positional or keyword)

How to Use in a Program

The PAYLIB macro on the previous page is used in a program in this manner.

%PAYLIBJOB INPUT PAYROLL NAME DEDUCRPTIF DEPT = 911 914 THRU 920

DEDUCTIONS = GROSS - NETPRINT MACRO-EXAMPLE

REPORT MACRO-EXAMPLESEQUENCE DEPT NAMETITLE 1 'EXAMPLE OF USING MACROS'TITLE 2 'IN A PROGRAM'LINE 1 DEPT NAME GROSS NET DEDUCTIONS

Parameter Substitution Examples

These examples show how to use the substitution parameters on the prototype statement.

MACRO(no substitution parameters)

MACRO POS1 POS2(only positional parameters)

MACRO 0 KEY1 VALUE1 KEY2 VALUE2(only keyword parameters)

MACRO 2 POS1 POS2 KEY1 VALUE1(keyword and positional combined)

- 117 -

Page 118: Easy Tri Eve Plus

EASYTRIEVE PLUS

Macro Example with Parameter Substitution

A macro, called CNTLRPT, exists in your library, containing:

MACRO 2 CNTL-FLD VALUE RANGE ' ' HIGH-VALUE ' 'IF &CNTL-FLD = &VALUE &HIGH-VALUE

PRINT RPT1END-IFREPORT RPT1

SEQUENCE &CNTL-FLD NAMECONTROL &CNTL-FLD NEWPAGETITLE 1 'CONTROL REPORT OF NAME WITHIN &CNTL-FLD' +

&CNTL-FLDLINE 1 &CNTL-FLD NAME GROSS-PAY NET-PAY

The ampersand (&) tells EASYTRIEVE PLUS where to substitute parameter values in the macro.

To use CNTLRPT, code:

%PAYLIBJOB INPUT PAYFILE NAME REGPROG%CNTLRPT REGION 516

or

%PAYLIBJOB INPUT PAYFILE NAME REGPROG%CNTLRPT REGION 516 RANGE THRU HIGH-VALUE 520

or

%PAYLIBJOB INPUT PAYFILE NAME REGPROG%CNTLRPT REGION '516 520 525 580'

- 118 -

Page 119: Easy Tri Eve Plus

EASYTRIEVE PLUS

Testing Macros Within a Program

You can use this method of testing a macro you have created before storing it in your library. When this method is used, the macro is coded at the beginning of the program.

Syntax

MSTART macro-nameMACRO [positional] [keyword]

* * Code to be used as macro * *

MEND

MSTART

You use MSTART to indicate the start of a macro to be tested in the program.

MEND

You use MEND to indicate the end of the macro you are testing.

Example

MSTART PAYLIBMACRO O VS ' 'FILE PAYIN &VS

EMP# 9 5 NEMP-NAME 17 20 ASSN 4 5 PNET-PAY 90 4 P 2GROSS-PAY 94 4 P 2

MEND%PAYLIBJOB INPUT PAYIN

….REPORT

….

- 119 -

Page 120: Easy Tri Eve Plus

EASYTRIEVE PLUS

MACRO EXAMPLES

The following examples illustrate some of the uses of macros.

Commonly Used Routines

This macro provides for using SYSDATE for comparison with any other date in a file.

Example

MACRO USER-DATE** GET THE CURRENT DATE AND PUT INTO* USER FIELD (LESS SLASHES)*

DEFINE GETDATE-DATE W 8 ADEFINE GETDATE-FIRST6 GETDATE-DATE 6 NDEFINE GETDATE-LAST5 GETDATE-DATE +3 5 ADEFINE GETDATE-LAST6 GETDATE-DATE +2 6 ADEFINE GETDATE-LAST3 GETDATE-DATE +5 3 ADEFINE GETDATE-LAST2 GETDATE-DATE +6 2 AGETDATE-DATE = SYSDATE * MOVE ALL 8GETDATE-LAST3 = GETDATE-LAST2 *SHIFT LEFT OVER NEXT /GETDATE-LAST6 = GETDATE-LAST5 *SHIFT LEFT OVER FIRST /&USER-DATE = GETDATE-FIRST6 * MOVE TO USER FIELD

The DEFINE Statement allows you to define data fields outside of the library.

- 120 -

Page 121: Easy Tri Eve Plus

EASYTRIEVE PLUS

Data Dictionary

This example illustrates a common data dictionary entry. It contains all the field definitions for the test data base PERSNL.

Example

MACRO** EASYTRIEVE PLUS TEST FILE FIELD DEFINITIONS*REGION 1 1 NBRANCH 2 2 NSSN 4 5 P MASK '999-99-9999' +

HEADING +('SOCIAL' 'SECURITY' 'NUMBER')

EMP# 9 5 N HEADING ('EMPLOYEE' 'NUMBER')NAME 17 16 A HEADING 'EMPLOYEE NAME' NAME-LAST NAME 8 A HEADING ('LAST' 'NAME') NAME-FIRST NAME +8 8 A HEADING ('FIRST' 'NAME')ADDRESS 37 39 AADDR-STREET 37 20 A HEADING 'STREET'ADDR-CITY 57 12 A HEADING 'CITY'ADDR-STATE 69 2 A HEADING 'STATE'ADDR-ZIP 71 5 N HEADING ('ZIP' 'CODE')PAY-NET 90 4 P 2 HEADING ('NET' ' ' 'PAY')PAY-GROSS 94 4 P 2 HEADING ('GROSS' 'PAY')DEPT 98 3 NDATE-OF-BIRTH 103 6 N MASK (Y 'Z9/99/99') +

HEADING ('DATE' 'OF' 'BIRTH')TELEPHONE 117 10 N MASK '(999) 999-9999' +

HEADING ('TELEPHONE' 'NUMBER')SEX 127 1 N HEADING ('SEX' 'CODE)

* 1 - FEMALE* 2 - MALE

MARITAL-STAT 128 1 A HEADING ('MARITAL' 'STATUS')* M - MARRIED* S - SINGLE

JOB-CATEGORY 132 2 N HEADING ('JOB' 'CATEGORY')SALARY-CODE 134 2 N HEADING ('SALARY' 'CODE')DATE-OF-HIRE 136 6 N MASK Y +

HEADING ('DATE' 'OF' 'HIRE')

- 121 -

Page 122: Easy Tri Eve Plus

EASYTRIEVE PLUS

Logic Templating

The example on the next page shows complex logic that most end users would not want to code but would find very useful during budget preparation time - calculating raises. Note that this example illustrates how to test a macro using MSTART and MEND around the macro and an EASYTRIEVE PLUS program after MEND

The advantage to this macro application is that the logic is fixed but the user maintains full control over the final report.

- 122 -

Page 123: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example

MSTART RAISSELMACRO 1 RAISE-PCT SELECT-YEARS-GT '1' REPORT 'UPD-RPT'

DEFINE DATE-OF-HIRE W 6 NDEFINE HIRE-MM DATE-OF-HIRE 2 NDEFINE HIRE-DD DATE OF-HIRE +2 2 NDEFINE HIRE-YY DATE-OF-HIRE +4 2 NDEFINE WEEKLY-PAY W 4 P 2DEFINE NEW-SALARY W 4 P 2

DEFINE RAISE W P 5 VALUE &RAISE-PCT *MUST BE LT 1DEFINE CURR-DATE W 6 NDEFINE CURR-MM CURR-DATE 2 NDEFINE CURR-DD CURR-DATE + 2 2 NDEFINE CURR-YY CURR-DATE + 4 2 NDEFINE SERVICE W 2 N *YEARS OF SERVICE

JOB NAME SELECT-RAISE-BY-YEARS-OF-SERVICE%GETDATE CURR-DATEPERFORM SERVICE-CALCIF SERVICE LT &SELECT-YEARS-GT

GOTO JOBEND-IFNEW-SALARY = PAY-GROSS *RAISE + PAY-GROSS + 0.005PRINT &REPORT

*SERVICE-CALC. PROC

SERVICE = CURR-YY - HIRE-YYIF CURR-MM < HIRE-MM

SERVICE = SERVICE - 1END-IFIF CURR-MM NE HIRE-MM

GOTO QUIT-SERV-CALCEND-IFIF CURR-DD < HIRE-DD

SERVICE = SERVICE - 1END-IFQUIT-SERV-CALC

END-PROCMEND%PERSNL%RAISESEL 0.05 SELECT-YEARS-GT 20REPORT UPD-RPT LINESIZE 80LINE 1 NAME DATE-OF-HIRE PAY-GROSS NEW-SALARY

- 123 -

Page 124: Easy Tri Eve Plus

EASYTRIEVE PLUS

CODING TECHNIQUES

OVERVIEW

This section covers the following topics :

1. System-Defined Fields2. Environment3. Bit Testing.

Under system-defined fields you will learn about eight fields that EASYTRIEVE PLUS supplies automatically. These fields fall into three categories:

General Purpose Fields File Processing Fields Report Processing Fields

In the Environment section you will learn about the PARM statement and how you can use it to alter the defaults of EASYTRIEVE PLUS

Finally, you will learn how to do bit testing on a field

Objectives

After completing this section you will;

1. Know the purpose and use of the following system-defined fields;

SYSDATESYSTIMERETURN-CODETALLYLEVELRECORD-COUNTRECORD-LENGTHFILE-STATUS

2. Understand how the PARM statement with the DEBUG parameter is used to modify the ENVIRONMENT section of an EASYTRIEVE PLUS program.

3. See how you can perform bit testing with EASYTRIEVE PLUS.

- 124 -

Page 125: Easy Tri Eve Plus

EASYTRIEVE PLUS

SYSTEM-DEFINED FIELDS

EASYTRIEVE PLUS automatically provides three categories of system defined fields.

1. General Purpose Fields2. File Processing Fields3. Report Processing Fields

General Purpose Fields

SYSDATE

SYSDATE is a read only eight-byte alphanumeric field which contains the system date at the start of EASYTRIEVE PLUS execution. The DATE option of the Options Table determines the format of the date. A / (slash) separates the month, day and year components of the date (i.e. MM/DD/YY).

SYSTIME

SYSTIME is a read only eight-byte alphanumeric field which contains the system time at the start of EASYTRIEVE PLUS execution. A. (slash) separates the data into hours, minutes, and seconds (i.e. HH/MM/SS)

RETURN-CODE

RETURN-CODE is a four-byte binary field whose contents are returned to the operating system in register 15 when EASYTRIEVE PLUS terminates. RETURN-CODE is initialized to zero, but you can set it to any value. RETURN-CODE applies only to OS systems.

- 125 -

Page 126: Easy Tri Eve Plus

EASYTRIEVE PLUS

File Processing Fields

When you use these fields you will find that each file has its own unique processing fields.

RECORD-LENGTH

RECORD-LENGTH is a two-byte binary field with zero decimal places used for all file types to determine or establish the length of the current data record. For variable-length records, this field contains only the length of the record's data.

RECORD-COUNT

RECORD-COUNT is a read-only four-byte binary field with zero decimal places which contains the number of logical I/O operations performed on a file.

FILE-STATUS

FILE-STATUS is a read-only field which contains the results of the most recent I/O operation on a file.

Report Processing Fields

TALLY

TALLY contains the number of detail records that comprise a control break. You can use TALLY on a LINE statement or you can use it in calculations within report procedures. TALLY is commonly used to determine averages for a control level.

TALLY is a ten-byte packed decimal field with zero decimal places. This definition is used for calculations contained within report procedures. The TALLYSIZE parameter of the REPORT statement defines the number of digits which are printed for TALLY. A TALLY accumulator is created for each control beak level.

LEVEL

LEVEL is a system-defined field provided for determining which control break is currently active. The field is defined as a two-byte binary field. The value in LEVEL indicates the control break level and varies from 0 to n based on the number of field names on the CONTROL statement of the associated report. LEVEL will contain the logical position number of the controlling field name. This value also applies to FINAL whether it is coded or not.

- 126 -

Page 127: Easy Tri Eve Plus

EASYTRIEVE PLUS

Example

LEVEL = 1 on TERRITORY breaksLEVEL = 2 on REGION breaksLEVEL = 3 on AREA breaksLEVEL = 4 on FINAL break

CONTROL FINAL NOPRINT AREA REGION TERRITORY4 3 2 1

CONTROL AREA REGION TERRITORY4 3 2 1

- 127 -

Page 128: Easy Tri Eve Plus

EASYTRIEVE PLUS

ENVIRONMENT

The Environment section of an EASYTRIEVE PLUS program has only one statement associated with it. It is the PARM statement. You use the PARM statement to alter system defaults for the duration of the execution of your EASYTRIEVE PLUS program.

If you use the PARM statement you must code it as the first statement in the program unless MACROs are being tested.

Example

For syntax checking only:

PARM SYNTAX

For increasing VFM's space in memory:

PARM VFM 100

For omitting file statistics and parm values:

PARM LIST (NOFILE NOPARM)

Combination

PARM VFM 100 LIST (NOFILE NOPARM)

For link editing:

PARM LINK (TESTPGM)

- 128 -

Page 129: Easy Tri Eve Plus

EASYTRIEVE PLUS

Debugging

Use the DEBUG parameter of the PARM statement to generate output helpful in analyzing programming errors.

DEBUG Subparameters

DMAP - data definitions for all files and working storage FLDCHK - validates all file/field references FLOW - traces statement logic FLOWSIZ - identifies the number of statements to be kept in a trace table STATE - gives statement number of the current statement executed wen abnormal

termination occurs XREF - produces a cross-reference of field-names, file-names, procedure-names,

and statement-labels where used.

Examples

PARM DEBUG (DMAP FLDCHK NOXREF)PARM DEBUG (DMAP FLOW FLOWSIZE (150) )PARM VFM 200 LIST NOFILE DEBUG (FLDCHK STATE)

- 129 -

Page 130: Easy Tri Eve Plus

EASYTRIEVE PLUS

BIT TESTING

You can test individual bits in a field for an or off condition

Syntax

If field-name-1 [NOT] ON field-name-2OFF literal

Field-name-2 or Literal

Field-name-2 or literal is used to determine the bit pattern which will be compared to the pattern in field-name-1

The length of field-name-1 must be the same length as field-name-2 A bit with a value of 1 is considered to be on A bit with the value of 0 is considered to be off

Examples

IF CODE ON X'FFOO'

The bit pattern value of X'FF00' is compared to the pattern in CODE. If all the bits that are on in X'FF00' are also on in CODE, the condition is true.

IF FLD-HOLD OFF FLD-WORK

The bit pattern created by FLD-WORK is compared to the pattern in FLD-HOLD. If all the bits that are on in FLD-WORK are off in FLD-HOLD, the condition is true.

- 130 -

Page 131: Easy Tri Eve Plus

EASYTRIEVE PLUS

SUMMARY

This concludes Section 6 of the Student Guide. You should now know how to use the following system-defined fields in your EASYTRIEVE PLUS programs.

SYSDATESYSTIMERETURN-CODETALLYLEVELRECORD-COUNTRECORD-LENGTHFILE-STATUS

You should understand how to code the PARM statement to modify the Environment section of an EASYTRIEVE PLUS program.

Finally, you have been introduced to bit testing with EASYTRIEVE PLUS

- 131 -