A small Easytrieve report can read a personnel file, select the records you want, and print a clean listing with just a few statements. The core flow is FILE, field definitions, JOB INPUT, PRINT, REPORT, and LINE.
What is Easytrieve basic reporting?
Easytrieve basic reporting means reading input records and sending selected fields to a report layout. It is often used for quick batch listings, reconciliation reports, extract checks, and one-time analysis jobs where a full COBOL program would take longer to write.
The report definition controls how the output looks. The job activity controls what records are read and when the report is printed.
Basic Easytrieve report flow
| Part | Purpose |
|---|---|
FILE |
Names the input file and describes the physical record. |
| Field definitions | Define field name, starting position, length, and data type. |
JOB INPUT |
Reads the input file automatically for the job activity. |
PRINT |
Sends the current record to a named report. |
REPORT |
Starts the report layout definition. |
TITLE, HEADING, LINE |
Define headings and printed report fields. |
Define the input file
The FILE statement names the file used by the program. The fields below it describe positions inside each input record. In this example, PERSNL is a fixed-length personnel file.
FILE PERSNL FB(150 1800)
EMPNO 9 5 N
DEPT 1 3 N
NAME 17 20 A
GROSS 94 4 P 2
The format depends on your site standards and product release, but the idea is stable: Easytrieve must know where each field starts and how to treat the data.
JOB INPUT and PRINT
JOB INPUT PERSNL tells Easytrieve to read the input file for the job activity. The PRINT statement prints the current record using the report definition named after it.
JOB INPUT PERSNL
IF DEPT = 910
PRINT DEPTRPT
END-IF
This example prints only department 910. Without the IF, every input record would be printed.
REPORT, TITLE, and LINE example
The REPORT statement starts the layout. TITLE prints report titles. LINE lists the fields that should appear on each detail line.
REPORT DEPTRPT LINESIZE 80
TITLE 1 'DEPARTMENT 910 REPORT'
LINE DEPT EMPNO NAME GROSS
Broadcom examples use this same report pattern: read input, issue PRINT, define REPORT, add a TITLE, and place fields on the LINE statement.
Use HEADING for readable columns
Default column headings are not always friendly. Use HEADING to print useful column names. Broadcom documents the syntax as a field name followed by one or more heading literals.
REPORT DEPTRPT LINESIZE 80
TITLE 1 'DEPARTMENT 910 REPORT'
HEADING EMPNO ('EMPLOYEE' 'NUMBER')
HEADING GROSS ('GROSS' 'PAY')
LINE DEPT EMPNO NAME GROSS
Keep the field name outside the parentheses. Putting the field name inside the parentheses is a common syntax error.
LINESIZE and line overflow
LINESIZE controls the maximum report line width. If the fields on a LINE statement exceed the report width, Easytrieve can issue a line overflow error. Broadcom has a DB2 sample where long fields caused a report line overflow, and the fix was to reduce field sizes or increase the report line size to match the report design.
REPORT DEPTRPT LINESIZE 132
TITLE 1 'WIDER PERSONNEL REPORT'
LINE DEPT EMPNO NAME GROSS
For printed batch output, choose a line size that matches the report destination. Do not make every report 300 columns wide unless the output target can use it.
Full beginner report example
This example pulls the basic pieces together. It reads a personnel file, selects one department, and prints a short detail report.
FILE PERSNL FB(150 1800)
DEPT 1 3 N
EMPNO 9 5 N
NAME 17 20 A
GROSS 94 4 P 2
JOB INPUT PERSNL
IF DEPT = 910
PRINT DEPTRPT
END-IF
REPORT DEPTRPT LINESIZE 100
TITLE 1 'DEPARTMENT 910 EMPLOYEE LIST'
HEADING EMPNO ('EMPLOYEE' 'NUMBER')
HEADING GROSS ('GROSS' 'PAY')
LINE DEPT EMPNO NAME GROSS
Syntax notes from the original post
The original post listed syntax characters. These are still useful when reading Easytrieve code.
- A blank separates statement parts.
- Parentheses group heading literals and sub-parameters.
- A colon qualifies a non-unique field name, such as
PERSNL:NAME. - A comma is optional in many report lists and is often used for readability.
- Single quotation marks enclose literals, such as
'TEXAS'. - An asterisk in the first non-blank position marks a comment.
- A plus sign can continue a long statement to the next line.
Common mistakes
Printing before fields are defined
If a field is not defined correctly under the input file, the report may print blanks, wrong values, or data from the wrong byte position.
Letting identifier fields total or wrap
Employee number, department number, and account code may be numeric, but they are identifiers. Keep them as display fields and review report width before adding more columns.
Ignoring output width
A report that looks fine in source can fail or wrap badly when the output file has a smaller line size. Check LINESIZE with the fields on the LINE statement.
Related Easytrieve guides
For nearby topics, read Easytrieve Basic Report Field Definition, Easytrieve Basic Report Edit Field Definition, Easytrieve Basic Conditions, Easytrieve Report Calculation, Easytrieve Sorting, and Easytrieve VSAM File Handling.
External references
Technical notes in this refresh were checked against Broadcom Easytrieve report sample code, Broadcom report line overflow guidance, Broadcom HEADING syntax guidance, and Broadcom FILE and JOB INPUT notes.
FAQ
What statements are needed for a basic Easytrieve report?
A small report usually needs a FILE statement, field definitions, JOB INPUT, PRINT, REPORT, TITLE, and LINE.
What does JOB INPUT do in Easytrieve?
JOB INPUT names the automatic input file for the job activity. Easytrieve reads that file and runs the job logic for each record.
What does LINE do in an Easytrieve report?
LINE lists the fields and spacing that should print on each report detail line.
How do I avoid Easytrieve report line overflow?
Set a suitable LINESIZE, limit the number of fields on the LINE statement, and shorten fields that are wider than the report destination can hold.
No comments:
Post a Comment