我有以下easytrieve加代码:
*
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
此安装时的此代码无错误地工作,在另一个安装下给出了消息:
68 *******A010 INVALID FILE REFERENCE - ENTRADA
输入文件看起来如下:
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
和ouptut文件:
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.
在不起作用的安装中,EasyTrive步骤以条件代码0016结束,但会产生一个输出文件(它只是不会处理最后一个记录):
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.
它给出的错误是:
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)
我无法访问EasyTrieve Plus,因此如果不围绕边缘编译,请提前道歉。
简化程序:
FILE ENTRADA
INPUT-DATA-PART 1 16 A
FILE SALIDA
C1-JOBNAME 1 16 A
C1-MENSAGEM 22 31 A
W-INREC1 W 16 A
W-INDIC1 W-INREC1 1 A
W-INREC2 W 16 A
W-INDIC2 W-INREC2 1 A
W-MSG1 W 31 A VALUE 'INSERIR PARAMETROS CA-VIEW. '
W-MSG2 W 31 A VALUE 'PARÂMETROS CORRECTOS. '
W-MSG3 W 31 A VALUE 'PARÂMETROS INCORRECTOS. '
W-COUNT W 8 N VALUE 0
W-COUNT-VAL W 8 N VALUE 0
JOB INPUT NULL
PERFORM READ-INPUT
IF EOF ENTRADA
DISPLAY "No input and some other useful text, like name"
RETURN-CODE = 20
STOP EXECUTE
END-IF
W-INREC1 = INPUT-DATA-PART
DISPLAY "First record read"
DO WHILE NOT EOF ENTRADA
IF W-INDIC1 EQ 'J'
PERFORM READ-INPUT
DISPLAY 'W-COUNT 1: ' W-COUNT
W-INREC2 = INPUT-DATA-PART
IF W-INDIC2 EQ 'J'
PERFORM NEXT-WAS-J-STORE-IT
ELSE
PERFORM NOT-J-PROCESS-AND-READ
END-IF
END-IF
PUT SALIDA
END-DO
STOP
READ-INPUT. PROC
GET ENTRADA
W-COUNT = W-COUNT + 1
W-COUNT-VAL = W-COUNT
END-PROC
NEXT-WAS-J-STORE-IT. PROC
C1-MENSAGEM = W-MSG1
C1-JOBNAME = W-INREC1
DISPLAY 'CJ-JOBNAME:' C1-JOBNAME
W-INREC1 = W-INREC2
END-PROC
NOT-J-PROCESS-AND-READ. PROC
IF W-INREC2 EQ 'F RF CNF CH '
C1-MENSAGEM = W-MSG3
C1-JOBNAME = W-INREC1
DISPLAY 'CF3-JOBNAME:' C1-JOBNAME
END-IF
IF W-INREC2 EQ 'F RF CH '
C1-MENSAGEM = W-MSG2
C1-JOBNAME = W-INREC1
DISPLAY 'CF2-JOBNAME:' C1-JOBNAME
END-IF
PERFORM READ-INPUT
DISPLAY 'W-COUNT 2: ' W-COUNT
W-INREC1 = INPUT-DATA-PART
END-PROC
如果您查看简化的控制逻辑,您会发现,如果在DO-LOOP中读取一对记录中的第二个记录,那是文件上的最后一个记录(例如,使用您的示例数据),然后将执行另一个获取(给您eof),然后您的程序仍将尝试从记录区域访问输入data-part,easytrive plus将为您提供A0016,无效的文件参考(和文件的名称)。
随着显示的数据,该程序将始终失败。如果数据以孤独的Jobname记录结束,则该程序将"成功"。
,不,您不应该仅通过对EOF进行测试来"修复"它。您应该重组逻辑。
始终如一地使用凹痕。
在库中,您无需指定定义。您只需要定义在作业或类似中定义数据。
移动不像COBOL移动那样工作。它会绊倒你。使用大多数事物的作业(文件除外,或者如果您想要可变长度移动)。
由于您已经使用了作业,所以我建议在IF中使用等式,只是为了获得一些差异。
您只需要定义所需的数据。
改善您的名字。
不要进行大规模的嵌套结构,用表演分解事物。
并且在此处发布代码时不要使用选项卡。当别人带您的代码查看时,可能会很痛苦。