我正在运行一个正在读取一个VSAM文件的COBOL pgm。 下面是我的pgm中的输入输出部分。
FILE-CONTROL。
SELECT INPUT-FILE ASSIGN TO DDINPUT
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS INPUT-KEY
FILE STATUS IS WS-INPUT-STATUS.
和FD条目如下。
文件部分。
FD输入文件是外部的(因为这是在sub pgm中)当我运行此pgm时,它失败,文件状态代码= 04。 某处我发现在FD中我们只有一条记录,即使文件是VB,它也只是FB。所以FB应该有record contains或Varying子句。
当我将FD更新为。
文件部分。
FD输入文件是外部的 记录的大小从1到215不等。 COPY INPLAYOUT。工作顺利。
我有一个疑问我是否可以将此Varying子句指定为最大长度,就像我将其写为例如从1到2500的RECORD VARYING SIZE那样。那么它会导致任何问题吗?
答案 0 :(得分:4)
假设您的VSAM文件已正确初始化并且您的JCL编码符合您的程序要求,那么应该没有问题。
VARYING子句只是告诉COBOL在缓冲区中保留足够的空间以获得最大预期记录大小,并指示该文件包含从一个I / O调用到下一个I / O调用的大小不同的记录。如果它是FB(固定块),则COBOL期望记录为常量,如果记录偏离预期大小,则将触发状态码04。对于VB(变量块),如果您的记录大小超过最大VARYING定义的限制,则仍可能出现返回码04。
就个人而言,我发现COBOL I / O状态条件有点神秘,无法理解。
这是ANSI COBOL I / O状态代码表,我可以方便地进行文件i / o调试:
0x - Successful Completion
00 - No futher information
02 - Duplicate Key detected
04 - Wrong Length Record
05 - File created when opened. With sequential VSAM 00 is returned.
07 - CLOSE with NO REWIND or REEL for non-tape dataset.
1x - End of File conditions
10 - No futher information
14 - Relative record READ outside boundry.
2x - Invalid Key condition
21 - Sequence Error
22 - Duplicate Key
23 - No Record found
24 - Key outside boundry
3x - Permanent I/O Errors
30 - No further information
34 - Record outside file boundry
35 - OPEN and required file not found.
37 - OPEN with invalid mode
38 - OPEN of file closed with a LOCK
39 - OPEN unsuccessful due to conflicting file attributes
4x - Logic Errors
41 - OPEN of file already open
42 - CLOSE of file not open
43 - READ not executed before REWRITE
44 - REWRITE of different size record
46 - READ after EOF reached
47 - READ attempted for file not opened I-O or EXTEND
48 - WRITE for file not opened OUTPUT, I-O, or EXTEND
49 - DELETE or REWRITE for file not opened I-O
9x - Specific Compiler defined exceptions
90 - No further information
91 - VSAM Password failure
92 - Logic Error
93 - VSAM Resource unavailable
94 - VSAM Sequence record not available
95 - VSAM invalid or incomplete file information
96 - VSAM no DD statement
97 - VSAM OPEN successful, file integrity verified.
答案 1 :(得分:0)
读取可变速记录布局文件的COBOL程序将文件状态代码设置为004.但是在FILE SECTION中指定VARYING子句后,它运行良好。
将文件状态代码设为04的代码:
FD XXXXX-FILE
RECORDING MODE IS V
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS STANDARD.
指定VARYING子句后,文件状态代码为00:
FD XXXXX-FILE
RECORDING MODE IS V
RECORD IS VARYING IN SIZE FROM 01 TO 2598
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS STANDARD.