我正在学习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.
答案 0 :(得分:3)
有点晚了,而且是切向的,但是这里有一个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'.
答案 1 :(得分: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.
答案 2 :(得分:0)
校正非常简单......我刚刚改变了IF ......
IF FS = "35"
CLOSE ARQCLI OPEN OUTPUT ARQCLI CLOSE ARQCLI
GO TO INICIO
ELSE