扩展开放 (COBOL)
我最近接到一项任务,要求使用“EXTEND OPEN”命令将数据添加到现有文件中。虽然我以为我明白它的作用,但我发现我的程序遇到了障碍,给我这个错误:“148 错误的打开模式或写入访问模式”。这是一个简单的程序,旨在仅将一个新的条目文件添加到主文件中,但我不太明白它。这就是我所拥有的:
DATA DIVISION.
FILE SECTION.
FD OLD-MASTER-IN.
01 OLD-MASTER-REC-IN.
05 O-STATE-ABREV-IN PIC XX.
05 PIC X.
05 O-STATE-NAME-IN PIC X(17).
FD TRANS-FILE-IN.
01 TRANS-REC-IN.
05 N-STATE-ABREV-IN PIC XX.
05 PIC X.
05 N-STATE-NAME-IN PIC X(17).
WORKING-STORAGE SECTION.
01 ARE-THERE-MORE-RECORDS PIC X(3) VALUE 'YES'.
PROCEDURE DIVISION.
100-MAIN.
OPEN INPUT OLD-MASTER-IN
EXTEND TRANS-FILE-IN
PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO '
READ OLD-MASTER-IN
AT END
MOVE 'NO' TO ARE-THERE-MORE-RECORDS
NOT AT END
PERFORM 200-REGULAR-UPDATE
END-READ
END-PERFORM
CLOSE OLD-MASTER-IN
TRANS-FILE-IN
STOP RUN.
200-REGULAR-UPDATE.
WRITE OLD-MASTER-REC-IN FROM TRANS-REC-IN.
任何帮助将不胜感激。
I recently got an assignment to use the "EXTEND OPEN" command to add data to an already existing file. While I thought I understood what it did I find that my program is hitting a snag, giving me this error: "148 Wrong open mode or access mode for write". It is a simple program, meant to only add one new file of entries to a master file, but I can't quite get it. Here is what I have:
DATA DIVISION.
FILE SECTION.
FD OLD-MASTER-IN.
01 OLD-MASTER-REC-IN.
05 O-STATE-ABREV-IN PIC XX.
05 PIC X.
05 O-STATE-NAME-IN PIC X(17).
FD TRANS-FILE-IN.
01 TRANS-REC-IN.
05 N-STATE-ABREV-IN PIC XX.
05 PIC X.
05 N-STATE-NAME-IN PIC X(17).
WORKING-STORAGE SECTION.
01 ARE-THERE-MORE-RECORDS PIC X(3) VALUE 'YES'.
PROCEDURE DIVISION.
100-MAIN.
OPEN INPUT OLD-MASTER-IN
EXTEND TRANS-FILE-IN
PERFORM UNTIL ARE-THERE-MORE-RECORDS = 'NO '
READ OLD-MASTER-IN
AT END
MOVE 'NO' TO ARE-THERE-MORE-RECORDS
NOT AT END
PERFORM 200-REGULAR-UPDATE
END-READ
END-PERFORM
CLOSE OLD-MASTER-IN
TRANS-FILE-IN
STOP RUN.
200-REGULAR-UPDATE.
WRITE OLD-MASTER-REC-IN FROM TRANS-REC-IN.
Any Help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想通了。我现在真是傻了。看来我扩展/读取了错误的文件。愚蠢的我。该代码应该如下所示:
I figured it out. I really stupid now. Seems I extended/read the wrong file. Silly me. The code is suppose to look like this:
如果您使用现代编译器编写代码,那么您的代码可能看起来不像是在 70 年代编写的。
以下是您可以执行的操作的示例:
当然,这里没有错误检查,但这是一个很大的主题。
If you are writing with a modern compiler your code could be written to not look like it was written in the 70's.
Here is an example of what you could do:
Of course, there is no error checking in here but that is a large topic.