2011-09-07 88 views
0

我正在運行一個正在讀取一個VSAM文件的COBOL PGM。 下面是我的pgm中的輸入輸出部分。VSAM狀態碼04

文件控制。

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條目如下。

FILE SECTION。

FD輸入文件是外部的(因爲這是在sub pgm中)
COPY INPUTREC。

當我運行此pgm時,它失敗,文件狀態碼= 04。 某處我發現在FD中我們只有一條記錄,即使文件是VB,它也將它視爲FB。所以FB應該有記錄包含或變化條款。

當我更新我的FD到。

FILE SECTION。

FD輸入文件是外部的
記錄的大小從1到215不等。 COPY INPLAYOUT。

工作正常。

我有一個疑問我可以指定這個變化的子句的最大長度,就像我寫這個例如RECORD VARYING IN SIZE從1到2500.那麼它會導致任何問題?

回答

4

假設您的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. 
0

COBOL程序讀取一個varable記錄佈局文件給文件狀態碼但在指定FILE SECTION中的VARYING子句之後,它沒有問題。這給了文件的狀態代碼爲04

代碼:

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

指定變條款後,文件狀態代碼爲00:

FD XXXXX-FILE    
RECORDING MODE IS V  
RECORD IS VARYING IN SIZE FROM 01 TO 2598 
BLOCK CONTAINS 0 RECORDS 
LABEL RECORDS STANDARD.