VSAM 状态代码 04

发布于 2024-12-03 11:31:27 字数 837 浏览 2 评论 0原文

我正在运行一个 COBOL pgm,它正在读取一个 VSAM 文件。 下面是我的 pgm 中的输入输出部分。

文件控制。

 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 输入文件是外部的(因为它位于子 pgm 中)
复制输入记录。

当我运行此 pgm 时,它失败,文件状态代码 =04。 我在某个地方发现,当在 FD 中时,我们只有一条记录,即使文件是 VB,它也会将其视为 FB。所以FB应该有record contains或Varying子句。

当我将 FD 更新为.

文件部分。

FD 输入文件是外部的
记录大小从 1 到 215 不等。 复制输入。

工作进展顺利。

我有一个疑问,我是否可以将此 Varying 子句指定为最大长度,就像我将其写为 RECORD VARYING IN SIZE FROM 1 TO 2500 一样。那么它会导致任何问题吗?

I am running one COBOL pgm which is reading one VSAM file.
Below is ithe input output section in my 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.

and FD entry is as follow.

FILE SECTION.

FD INPUT-FILE IS EXTERNAL (as this is in sub pgm)
COPY INPUTREC.

When I ran this pgm, it failed with file status code =04.
Somewhere I found that when in FD we have only one record even if the file is VB it treats it is FB. So FB should have record contains or Varying clause.

When I updated my FD to.

FILE SECTION.

FD INPUT-FILE IS EXTERNAL
RECORD VARYING IN SIZE FROM 1 TO 215.
COPY INPLAYOUT.

job ran fine.

I have one doubt Can I specify this Varying clause to maximum length, like if I write this as eg RECORD VARYING IN SIZE FROM 1 TO 2500. then will it cause any issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽心 2024-12-10 11:31:27

假设您的 VSAM 文件已正确初始化并且您的 JCL 编码与您的程序要求一致,那么应该没有问题。

VARYING 子句只是告诉 COBOL 在缓冲区中为最大预期记录大小保留足够的空间,并指示该文件包含预期大小在一次 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.

Assuming your VSAM file is properly initialized and your JCL is coded consistently with your program requirements there should be no issue.

The VARYING clause is simply telling COBOL to reserve enough space in the buffer for the maximum expected record size and indicates that the file contains records that are expected to vary in size from one I/O call to the next. If it had been FB (Fixed Block), COBOL expects the record to be a constant size and will trigger the status code 04 if the record deviates from the expected size. For VB (Variable Block) a return code 04 could still occur if your record size exceeds the maximum VARYING defined limit.

Personally I find COBOL I/O Status conditions somewhat cryptic to understand.

Here is a table of ANSI COBOL I/O Status Codes that I keep handy for file i/o debugging purposes:

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.
删除会话 2024-12-10 11:31:27

读取可变记录布局文件的 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.

The COBOL program which reads a varable record layout file gave file status code as 004. But after specifying the VARYING clause in FILE SECTION, it went fine.

Code which gave File status code as 04:

FD  XXXXX-FILE                                 
RECORDING MODE IS V                        
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS STANDARD.   

After specifying VARYING clause, file status code is 00:

FD  XXXXX-FILE             
RECORDING MODE IS V    
RECORD IS VARYING IN SIZE FROM 01 TO 2598
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS STANDARD.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文