不同安装中的相同Easytrieve代码会产生不同的结果

时间:2017-03-07 18:54:43

标签: easytrieve

我有以下Easytrieve Plus代码:

*
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.              

在安装不起作用的情况下,Easytrieve步骤以条件代码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)               

1 个答案:

答案 0 :(得分:0)

我无法访问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循环中的第一个GET读取一对记录中的第二个,那就是文件中的最后一个记录(和你的样本数据一样),然后会做另一个GET(给你EOF),然后你的程序仍然会尝试从记录区访问INPUT-DATA-PART,而Easytrieve Plus会给你A0016,无效的文件参考(以及文件的名称)。

显示数据后,程序将始终失败。如果数据以一个孤独的JOBNAME记录结束,程序将会成功#34;。

不,你不应该修理"只需敲打EOF测试。你应该重构逻辑。

始终如一地正确使用缩进。

在图书馆内,您不需要指定DEFINE。如果在JOB或SORT中定义数据,则只需要DEFINE。

MOVE不像COBOL MOVE那样工作。它会绊倒你。使用大多数事物的分配(文件除外,或者如果你想要一个可变长度的MOVE)。

由于你已经使用了作业,我建议在IFs中使用EQ,只是为了获得一些区别。

您只需要定义所需的数据。

改善你的名字。

不要使用大型嵌套结构,用PERFORMs来解决问题。

在此处发布代码时不要使用Tabs。当别人拿你的代码看时,这可能会很痛苦。