Saturday, 10 August 2013

Easytrieve JOB Statement: INPUT, NAME, and Examples

JOB INPUT PERSNL NAME PAYJOB starts an Easytrieve activity that reads PERSNL automatically. The statements after JOB run once for each record until end of file. That single line defines the activity's input method and gives the activity a name.

Easytrieve JOB statement automatic input record processing flow
JOB INPUT connects a file to the logic that Easytrieve runs for each record.

What is the Easytrieve JOB statement?

The Easytrieve JOB statement begins a JOB activity. A source member can contain one or more activities, and each activity contains executable logic. With automatic input, Easytrieve opens the named file, reads a record, makes its fields available, runs the activity statements, and repeats that cycle through end of file.

This page covers JOB activity control. For the surrounding program sections, use the Easytrieve Plus tutorial. The Easytrieve basic reporting guide concentrates on FILE, REPORT, TITLE, and LINE statements.

Basic JOB statement forms

FormPurposeProcessing responsibility
JOB INPUT file-nameProcess a sequential automatic input fileEasytrieve handles the normal read and end-of-file cycle
JOB INPUT file-name NAME activity-nameName the automatic-input activityEasytrieve reads; activity logic handles each record
JOB INPUT NULLRun without automatic inputThe program controls GET, loops, termination, or non-file work
JOB INPUT (file-name KEY(key-field))Request keyed synchronized processingEasytrieve coordinates records according to the keyed input definition
Check the installed release and site standards: Easytrieve syntax and permitted file operations can depend on release, compatibility mode, and option-table settings. Compile the example in the same environment that will run it.

How automatic input works

Automatic input is the simplest pattern for a single pass through a file. Broadcom describes the INPUT parameter as the automatic-input choice: Easytrieve controls the routine open, read, end-of-file, and close work. The JOB activity is entered for each available record.

  1. Easytrieve opens the referenced input file.
  2. It reads the next record into the file area.
  3. The statements following JOB run against that record.
  4. Control returns for the next automatic read.
  5. At end of file, normal activity termination and report processing occur.

Fields used in the activity must match the FILE definition. See Easytrieve field definitions for start position, length, data type, decimal positions, HEADING, and MASK.

Automatic-input report example

This program reads an 80-byte employee file. Records for department 910 are printed; other records pass to the next automatic read.

FILE PERSNL FB(80 800)
  EMPNO       1  5 N
  EMPNAME     6 20 A
  DEPT       26  3 N
  GROSS      29  7 P 2

JOB INPUT PERSNL NAME PAYJOB
  IF DEPT EQ 910
    PRINT PAYRPT
  END-IF

REPORT PAYRPT LINESIZE 80
  TITLE 1 'DEPARTMENT 910 PAYROLL'
  LINE EMPNO EMPNAME DEPT GROSS

The JOB statement does not define the file layout; the FILE statement does that. JOB selects PERSNL as the automatic input and associates the following logic with the activity. The Easytrieve IF and ELSE guide owns the separate condition-testing topic.

Match the file name to the JCL DD name

On z/OS, a FILE name commonly corresponds to a DD statement in the execution JCL. If the Easytrieve source says FILE PERSNL, the job normally needs a PERSNL DD unless SYSNAME or another installation-specific mapping changes the external name.

//PERSNL   DD DSN=TRAINING.PAYROLL.INPUT,DISP=SHR
//SYSPRINT DD SYSOUT=*
//EZTVFM   DD UNIT=SYSDA,SPACE=(CYL,(1,1))

A missing DD, an incorrect record format, or a record length that disagrees with the FILE declaration can fail before the JOB logic processes a record. Compare the execution messages, JCL allocation, and FILE statement together.

Use JOB INPUT NULL for controlled processing

JOB INPUT NULL disables automatic input. The activity can run once, perform calculations, retrieve records under explicit control, or manage a file loop with GET. The source must provide a termination path; Broadcom specifically warns that an INPUT NULL activity needs a STOP when automatic input is not supplying end-of-file termination.

FILE PERSNL F(80)
  EMPNO       1  5 N
  EMPNAME     6 20 A

JOB INPUT NULL NAME REREAD
  DO UNTIL EOF PERSNL
    GET PERSNL
    IF NOT EOF PERSNL
      DISPLAY EMPNO EMPNAME
    END-IF
  END-DO
  STOP
Avoid the endless INPUT NULL activity: when no automatic file drives termination, confirm that every loop can reach EOF or another explicit STOP path.

When controlled input is useful

  • The same file must be read more than once in one activity.
  • Input comes from a database request rather than a simple sequential pass.
  • The activity performs initialization, display, or calculation work with no input file.
  • Several files require explicit GET sequencing that automatic input does not express.

Broadcom's reread example uses JOB INPUT NULL, a GET loop, CLOSE, and a second loop. CLOSE support varies by Easytrieve release and compatibility mode, so verify that pattern before adopting it. For VSAM-specific GET, READ, PUT, and status handling, see Easytrieve VSAM file handling.

What NAME does on the JOB statement

NAME PAYJOB identifies the activity as PAYJOB. Named activities are useful when a PROGRAM activity executes JOB activities explicitly, and they make compiler listings clearer when a member contains several activities.

PROGRAM NAME PAYRUN
  EXECUTE PAYJOB
  STOP

JOB INPUT PERSNL NAME PAYJOB
  PRINT PAYRPT

Use a stable, descriptive activity name. Do not confuse the Easytrieve activity name with the z/OS job name on the JCL JOB card; they serve different purposes.

Multiple JOB activities

A source member can define more than one JOB activity. Normal STOP processing ends the current activity and permits the next activity to begin. This supports separate passes or outputs, but each JOB still needs a clear input and termination design.

JOB INPUT PERSNL NAME WRITERPT
  PRINT PAYRPT

JOB INPUT NULL NAME FINALMSG
  DISPLAY 'PAYROLL REPORT COMPLETE'
  STOP

When two activities write different files or reports, define each output and its JCL DD explicitly. The Easytrieve report calculation guide covers working fields and totals that belong in report logic.

STOP, STOP EXECUTE, GO TO JOB, and FINISH

Statement or phraseEffectUse carefully when
STOPEnds the current JOB through normal activity terminationA later JOB activity should still run
STOP EXECUTEEnds execution immediatelyReports or FINISH processing still need to occur
GO TO JOBReturns control to the JOB cycleA label near the end of automatic-input logic must remain inside the activity
FINISH procedure-nameNames end-of-activity logic for normal completionThe procedure depends on current input-record data at EOF

Broadcom documents a compile error case where a label appeared after the implied return to JOB. Adding an explicit GO TO JOB, or branching directly to JOB, kept the label inside the valid activity flow. Keep labels and procedures in their required Easytrieve regions rather than treating the source like unrestricted procedural code.

Keyed automatic input

Parenthesized JOB INPUT syntax supports keyed synchronized processing. A basic form is:

JOB INPUT (TRANS KEY(ACCOUNT-NO))

The key field must be valid for the input definition. Broadcom notes that an indexed, varying, or subscripted field cannot be used as the JOB INPUT key in Easytrieve 11.6 because its record location can change. Keyed processing deserves test data for missing keys, duplicates, first records, and final records. Use Easytrieve sorting when the source file must be ordered before key-sensitive processing.

Common JOB statement errors

SymptomLikely check
No records reach the activityConfirm the input DD, data set, FILE name, and whether the file is empty
INPUT NULL activity repeats or never endsCheck GET/EOF logic and the explicit STOP path
Report output is missing after STOP EXECUTEUse normal STOP when report finalization and FINISH processing must run
EZTC0168E says a label is not definedCheck whether an implied return to JOB placed the label outside the activity
JOB INPUT key is rejectedDo not use an indexed, varying, or subscripted key field
Update file fails to openCheck FILE UPDATE coding and the site's Easytrieve option-table permissions

Easytrieve JOB statement checklist

  • Choose automatic input for a routine single pass through a file.
  • Use INPUT NULL only when the activity controls input or needs no input.
  • Match FILE names to the allocated JCL DD names.
  • Add NAME when an activity will be executed by name or needs clearer identification.
  • Give INPUT NULL logic an explicit and reachable STOP path.
  • Preserve normal termination when reports or FINISH procedures must run.
  • Test EOF, empty-file, first-record, final-record, and error paths.

Official Broadcom references

Easytrieve JOB statement FAQ

What does JOB INPUT do in Easytrieve?

JOB INPUT names the automatic input file for an activity. Easytrieve handles the normal open, record-read, end-of-file, and close cycle, and runs the activity logic once for each input record.

When should I use JOB INPUT NULL?

Use JOB INPUT NULL when the activity must control input itself or has no automatic input file. The program must issue its own GET or other processing statements and must provide a STOP path.

What is NAME on an Easytrieve JOB statement?

NAME assigns an activity name, such as PAYJOB. A PROGRAM activity can execute that named JOB activity, and the name also makes listings easier to read when a source member contains several activities.

What is the difference between STOP and STOP EXECUTE?

STOP ends the current JOB activity through normal termination processing. STOP EXECUTE ends execution immediately, so later JOB activities and normal FINISH processing are not performed.

For automatic input, read the JOB line as an execution contract: Easytrieve owns the record loop, while the statements below JOB own the work performed for each record.

No comments:

Post a Comment

New In-feed ads