0

我正在研究 Cobol,但是在读取文件时遇到问题,cobol 将文件的状态返回为 35...我在互联网上查看了这个状态是什么,据我了解是系统确实找不到该文件,但我在与可执行文件相同的目录中创建了该文件,其中包含系统应识别的列...

我该如何解决这个问题?

   IDENTIFICATION DIVISION.
   PROGRAM-ID.    EXCLI.

   ENVIRONMENT DIVISION.
   CONFIGURATION SECTION.
   SPECIAL-NAMES.
      DECIMAL-POINT IS COMMA.

   INPUT-OUTPUT SECTION.
   FILE-CONTROL.
        SELECT ARQCLI ASSIGN TO DISK
        ORGANIZATION            INDEXED
        ACCESS MODE             DYNAMIC
        RECORD KEY              FD-CODIGO
        FILE STATUS             FS.

   DATA DIVISION.
   FILE SECTION.
   FD ARQCLI LABEL RECORD STANDARD
         VALUE OF FILE-ID IS "ARQCLI.DAT".

   01 REG-ARQCLI.
      02 FD-CODIGO.
          03 CODIGO       PIC 9(04).
      02 FD-NOME          PIC X(30).
      02 FD-END           PIC X(30).
      02 FD-BAIRRO        PIC X(20).
      02 FD-CIDADE        PIC X(20).
      02 FD-CEP           PIC 9(05).

   WORKING-STORAGE SECTION.
   77 WS-SPACE            PIC X(40) VALUE SPACES.
   77 FS                  PIC X(02) VALUE SPACES.
   77 WS-FUNC             PIC 9     VALUE ZERO.
   77 MSG                 PIC X(09) VALUE SPACES.
   77 WS-CONF             PIC X     VALUE SPACE.
   01 WS-DATA-SIS.
      02 AA               PIC 9(02) VALUE ZEROS.
      02 MM               PIC 9(02) VALUE ZEROS.
      02 DD               PIC 9(02) VALUE ZEROS.
   01 WS-MENSAGENS.
      02 MENSA1           PIC X(30) VALUE "FUNÇÃO ERRADA - REDIGITE".
      02 MENSA2           PIC X(30) VALUE "CAMPO INVALIDO".
      02 MENSA3           PIC X(30) VALUE "CLIENTE JÁ CADASTRADO".
      02 MENSA4           PIC X(30) VALUE "CLIENTE NÃO CADASTRADO".

   SCREEN SECTION.
   01 TELA1.
      02 BLANK SCREEN.
      02 LINE 01 COLUMN 01 VALUE "EM:".
      02 LINE 01 COLUMN 26 VALUE "CADASTRO DE CLIENTES" REVERSE-VIDEO.
      02 LINE 03 COLUMN 19 VALUE "AUTOR: ALEXANDRE SAVELLI BENCZ".
      02 LINE 06 COLUMN 29 VALUE "FUNÇÃO DESEJADA: < >".
      02 LINE 08 COLUMN 29 VALUE "< 1 > INCLUSÃO".
      02 LINE 10 COLUMN 29 VALUE "< 2 > ALTERAÇÃO".
      02 LINE 12 COLUMN 29 VALUE "< 3 > EXCLUSÃO".
      02 LINE 14 COLUMN 29 VALUE "< 4 > CONSULTA".
      02 LINE 16 COLUMN 29 VALUE "< 5 > FIM".
      05 LINE 21 COLUMN 29 VALUE "MENSAGEM:".

   01 TELA-OPCAO.
      02 LINE 06 COLUMN 39 PIC X(09) USING MSG REVERSE-VIDEO.

   PROCEDURE DIVISION.
   INICIO.          
      OPEN I-O ARQCLI.
      IF FS NOT = "00"
         IF FS = "30"
            CLOSE ARQCLI OPEN OUTPUT ARQCLI CLOSE ARQCLI
            GO TO INICIO
         ELSE
            DISPLAY "FILE STATUS --->" LINE 24 COLUMN 35
            DISPLAY FS LINE 24 COLUMN 52
            STOP RUN
         ELSE
            NEXT SENTENCE.
            ACCEPT WS-DATA-SIS FROM DATE.

   TELA.
      DISPLAY TELA1.

   FIM.   
      STOP RUN.
4

3 回答 3

4

有点晚了,而且有点切题,但这里有一个 OpenCOBOL FILE STATUS 代码列表作为副本文件,并且比数字更容易助记。编辑品尝。

http://opencobol.add1tocobol.com/#isam

   01  status-code           pic x(2) value spaces.
       88  SUCCESS                    value '00'.
       88  SUCCESS_DUPLICATE          value '02'.
       88  SUCCESS_INCOMPLETE         value '04'.
       88  SUCCESS_OPTIONAL           value '05'.
       88  SUCCESS_NO_UNIT            value '07'.
       88  END_OF_FILE                value '10'.
       88  OUT_OF_KEY_RANGE           value '14'.
       88  KEY_INVALID                value '21'.
       88  KEY_EXISTS                 value '22'.
       88  KEY_NOT_EXISTS             value '23'.
       88  PERMANENT_ERROR            value '30'.
       88  INCONSISTENT_FILENAME      value '31'.
       88  BOUNDARY_VIOLATION         value '34'.
       88  NOT_EXISTS                 value '35'.
       88  PERMISSION_DENIED          value '37'.
       88  CLOSED_WITH_LOCK           value '38'.
       88  CONFLICT_ATTRIBUTE         value '39'.
       88  ALREADY_OPEN               value '41'.
       88  NOT_OPEN                   value '42'.
       88  READ_NOT_DONE              value '43'.
       88  RECORD_OVERFLOW            value '44'.
       88  READ_ERROR                 value '46'.
       88  INPUT_DENIED               value '47'.
       88  OUTPUT_DENIED              value '48'.
       88  I_O_DENIED                 value '49'.
       88  RECORD_LOCKED              value '51'.
       88  END_OF_PAGE                value '52'.
       88  I_O_LINAGE                 value '57'.
       88  FILE_SHARING               value '61'.
       88  NOT_AVAILABLE              value '91'.
于 2013-08-20T05:25:36.610 回答
1

更正很简单...我刚刚改了IF...

         IF FS = "35"
            CLOSE ARQCLI OPEN OUTPUT ARQCLI CLOSE ARQCLI
            GO TO INICIO
         ELSE
于 2013-08-20T12:42:17.160 回答
1

你可能想检查你的IF陈述。它的格式错误。尝试使用IF ... END-IF格式使其清晰,而不是使用句号。

我认为这就是你的意思:

  OPEN I-O ARQCLI.
  IF FS NOT = "00"
     IF FS = "30"
        CLOSE ARQCLI OPEN OUTPUT ARQCLI CLOSE ARQCLI
        GO TO INICIO
     ELSE
        DISPLAY "FILE STATUS --->" LINE 24 COLUMN 35
        DISPLAY FS LINE 24 COLUMN 52
        STOP RUN
     END-IF
  ELSE
        ACCEPT WS-DATA-SIS FROM DATE
  END-IF.
于 2013-08-07T15:44:22.430 回答