I have the following Easytrieve Plus code:
*
FILE ENTRADA
INPUT-REC1 1 132 A
*
*
FILE SALIDA
C1-JOBNAME 1 16 A
C1-FILLER 17 5 A
C1-MENSAGEM 22 31 A
*
DEFINE WS-INREC1 W 132 A
*
DEFINE WS-INDIC1 WS-INREC1 1 A
*
DEFINE WS-INPUT1 WS-INREC1 16 A
*
*
DEFINE WS-INREC2 W 132 A
*
DEFINE WS-INDIC2 WS-INREC2 1 A
*
DEFINE WS-INPUT2 WS-INREC2 16 A
*
DEFINE WS-MSG1 W 31 A VALUE 'INSERIR PARAMETROS CA-VIEW. '
*
DEFINE WS-MSG2 W 31 A VALUE 'PARÂMETROS CORRECTOS. '
*
DEFINE WS-MSG3 W 31 A VALUE 'PARÂMETROS INCORRECTOS. '
*
DEFINE WS-COUNT W 8 N VALUE 0
*
DEFINE WS-COUNT-VAL W 8 N VALUE 0
*
* PROCESO
*
JOB INPUT NULL
DO WHILE NOT EOF ENTRADA
IF WS-COUNT = 0
GET ENTRADA
MOVE INPUT-REC1 TO WS-INREC1
WS-COUNT = WS-COUNT + 1
END-IF
IF WS-INDIC1 = 'J' AND NOT EOF ENTRADA
GET ENTRADA
WS-COUNT = WS-COUNT + 1
WS-COUNT-VAL = WS-COUNT
DISPLAY 'WS-COUNT: ' WS-COUNT
MOVE INPUT-REC1 TO WS-INREC2
IF WS-INDIC2 = 'J'
MOVE WS-MSG1 TO C1-MENSAGEM
MOVE WS-INPUT1 TO C1-JOBNAME
DISPLAY 'CJ-JOBNAME:' C1-JOBNAME
MOVE WS-INREC2 TO WS-INREC1
ELSE
IF WS-INPUT2 = 'F RF CNF CH '
MOVE WS-MSG3 TO C1-MENSAGEM
MOVE WS-INPUT1 TO C1-JOBNAME
DISPLAY 'CF3-JOBNAME:' C1-JOBNAME
END-IF
IF WS-INPUT2 = 'F RF CH '
MOVE WS-MSG2 TO C1-MENSAGEM
MOVE WS-INPUT1 TO C1-JOBNAME
DISPLAY 'CF2-JOBNAME:' C1-JOBNAME
END-IF
GET ENTRADA
WS-COUNT = WS-COUNT + 1
DISPLAY 'WS-COUNT2: ' WS-COUNT
MOVE INPUT-REC1 TO WS-INREC1
END-IF
END-IF
PUT SALIDA
END-DO
STOP
This code at one installation works without error and at another installation gives the message:
68 *******A010 INVALID FILE REFERENCE - ENTRADA
The input file looks like the following:
JOBNAME:ADJADP0
F RF CH
JOBNAME:ADJBDK1
F RF CH
JOBNAME:BMRPNN2
JOBNAME:BMRP1N1
F RF CNF CH
JOBNAME:BMRP1N2
F RF CNF CH
JOBNAME:IU3A02J4
F RF CH
JOBNAME:IU3A02J5
F RF CH
And the ouptut file:
JOBNAME:ADJADP0 PARÂMETROS CORRECTOS.
JOBNAME:ADJBDK1 PARÂMETROS CORRECTOS.
JOBNAME:BMRPNN2 INSERIR PARAMETROS CA-VIEW.
JOBNAME:BMRP1N1 PARÂMETROS INCORRECTOS.
JOBNAME:BMRP1N2 PARÂMETROS INCORRECTOS.
JOBNAME:IU3A02J4 PARÂMETROS CORRECTOS.
JOBNAME:IU3A02J5 PARÂMETROS CORRECTOS.
At the installation where it doesn't work, the Easytrieve step ends with Condition Code 0016 but produces an output file (it just doesn't process the last record):
JOBNAME:ADJADP0 PARÂMETROS CORRECTOS.
JOBNAME:ADJBDK1 PARÂMETROS CORRECTOS.
JOBNAME:BMRPNN2 INSERIR PARAMETROS CA-VIEW.
JOBNAME:BMRP1N1 PARÂMETROS INCORRECTOS.
JOBNAME:BMRP1N2 PARÂMETROS INCORRECTOS.
JOBNAME:IU3A02J4 PARÂMETROS CORRECTOS.
The error that it gives is:
68 *******A010 INVALID FILE REFERENCE - ENTRADA
FILE STATISTICS - E Z T PLUS 5.2D- 3/07/17-19.42-JSN00036
ENTRADA 13 INPUT SAM FIX BLK 132 2
SALIDA 6 OUTPUT SAM FIX BLK 132 3
*******A014 PREMATURE TERMINATION DUE TO PREVIOUS ERROR(S)
I don't have access to Easytrieve Plus, so apologies in advance if it doesn't compile around the edges.
A simplification of your program:
If you look at the simplified control-logic, you'll see that if the second of a pair of records is read with the first GET in the DO-loop, and that is the last record on the file (like with your sample data), then will will do another GET (giving you EOF) and then your program will then still attempt to access INPUT-DATA-PART from the record area, and Easytrieve Plus will give you the A0016, invalid file reference (and the name of the file).
With the data shown, the program will always fail. If the data instead ends with a lonely JOBNAME record, the program will "succeed".
And No, you shouldn't "fix" it by just banging in a test for EOF. You should restructure the logic.
Use indentation, consistently and correctly.
Inside the Library, you don't need to specify DEFINE. You only need DEFINE if defining data in a JOB or a SORT.
MOVE does not work like a COBOL MOVE. It'll trip you. Use assignments for most things (except files, or if you want a variable-length MOVE).
Since you already use assignments, I'd suggest using EQ in IFs, just to get some differentiation.
You only need to define the data you need.
Improve your names.
Don't go for massive nested structures, break things down with PERFORMs.
And don't use Tabs when posting code here. It can be a pain when someone else takes your code to look at.