加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

关于COBOL文件返回码的处理.

(2012-05-19 20:53:57)
标签:

杂谈

分类: 大型机
  由于本人目前也还是处于菜鸟一枚,当然,在编写COBOL程序的时候,避免不了存在各种代码的规范的问题.对文件返回码的处理,就是这规范当中一条不可或缺的规则.一个好的,有经验的COBOL程序员,必定是能对文件的各种返回码处理的有条不紊.
  cobol的文件返回码有很多,个人绝的,你要是去死记硬背的话,估计是有的一背了,反正笔者的记忆力是已经不行了,基本上都是看文档.话说回来,这东西其实完全不需要去记,用多了,那些文件的返回码简直就是小菜一碟啊,文档什么的,根本不需要,不就是几个数字么,一共就没那么些状态,还能有很多中组合不成?下面是一些文件的返回码,大家可以参考参考:
  00
  Successful completion
  02
     ndexed files only. Possible causes:
  For a READ statement, the key value for the current key is equal to the value of that same key in the next record in the current key of reference.
  For a WRITE or REWRITE statement, the record just written created a duplicate key value for at least one alternate record key for which duplicates are allowed.
  04
  The length of the record being processed does not conform to the fixed file attributes for that file.
  05
  The referenced optional file is not present at the time the OPEN statement is executed.
  06
  Attempted to write to a file that has been opened for input.
  07
  Sequential files only. For an OPEN or CLOSE statement with the REEL/UNIT phrase the referenced file is a non-reel/unit medium.
  08
  Attempted to read from a file opened for output.
  09
  No room in directory or directory does not exist.
  10
  No next logical record exists. You have reached the end of the file.
  12
  Attempted to open a file that is already open 
  13
  File not found.
  14
  Relative files only. The number of significant digits in the relative record number is larger than the size of the relative key data item described for that file.
Too many files open simultaneously (Micro Focus).
  15
  Too many indexed files open (Micro Focus)
  16
  Too many device files open (Micro Focus).
  17
  Record error: probably zero length (Micro Focus).
  18
  Read part record error: EOF before EOR or file open in wrong mode (Micro Focus).
  19
     Rewrite error: open mode or access mode wrong (Micro Focus).
  20
  Device or resource busy (Micro Focus).
  21
     Sequentially accessed files only. Indicates a sequence error. The ascending key requirements of successive record key values has been violated, or, the prime record key value has been changed by a COBOL program between successful execution of a READ statement and execution of the next REWRITE statement for that file.
  22
     Indexed and relative files only. Indicates a duplicate key condition. Attempt has been made to store a record that would create a duplicate key in the indexed or relative file OR a duplicate alternate record key that does not allow duplicates.
  23
     Indicates no record found. An attempt has been made to access a record, identified by a key, and that record does not exist in the file. Alternatively a START or READ operation has been tried on an optional input file that is not present.
  24
     Relative and indexed files only. Indicates a boundary violation. Possible causes:
Attempting to write beyond the externally defined boundaries of a file
Attempting a sequential WRITE operation has been tried on a relative file, but the number of significant digits in the relative record number is larger than the size of the relative key data item described for the file.
  30
     The I/O statement was unsuccessfully executed as the result of a boundary violation for a sequential file or as the result of an I/O error, such as a data check parity error, or a transmission error.
  32
     Too many Indexed files opened. This can also happen when a sequential file is open for input and an attempt is made to open the same file for output.(Run Time System (RTS) message by Micro Focus).
  34
     The I/O statement failed because of a boundary violation. This condition indicates that an attempt has been made to write beyond the externally defined boundaries of a sequential file.
  35
     An OPEN operation with the I-O, INPUT, or EXTEND phrases has been tried on a non-OPTIONAL file that is not present. Trying to open a file that does not exist.
May need to map the COBOL file name to the physical file name. (Micro Focus, refer to the ASSIGN(EXTERNAL) directive)
  37
     An OPEN operation has been tried on a file which does not support the open mode specified in the OPEN statement.
  38
     An OPEN operation has been tried on a file previously closed with a lock.
  39
  A conflict has been detected between the actual file attributes and the attributes specified for the file in the program.This is usually caused by a conflict with record-length, key-length, key-position or file organization.
Other possible causes are:
1. Alternate indexes are incorrectly defined (Key length or position, duplicates or sparse parameters).
2. The Recording Mode is Variable or Fixed or not defined the same as when the file was created..
  41
     An OPEN operation has been tried on file already opened.
  42
     A CLOSE operation has been tried on file already closed.
  43
  Files in sequential access mode. The last I/O statement executed for the file, before the execution of a DELETE or REWRITE statement, was not a READ statement.
  44
     A boundary violation exists. Possible causes:
   Attempting to WRITE or REWRITE a record that is larger than the largest, or smaller than the smallest record allowed by the RECORD IS VARYING clause of the associated file
   Attempting to REWRITE a record to a file and the record is not the same size as the record being replaced.
  46
     A sequential READ operation has been tried on a file open in the INPUT or I-O mode but no valid next record has been established.
  47
     A READ or START operation has been tried on a file not opened INPUT or I-O. 
  48
     A WRITE operation has been tried on a file not opened in the OUTPUT, I-O, or EXTEND mode, or on a file open I-O in the sequential access mode.
  49
     A DELETE or REWRITE operation has been tried on a file that is not opened I-O.
  其实,文件返回码有很多种哈,可以自己去查阅相关的文档,这里只是列举了其中的一部分.其实,一般需要处理的那就是35,一般情况下,都是找不到文件,返回值为35.
       那么怎么捕获文件的返回码呢?方法很简单,你只需要在FILE-CONTROLs声明文件的时候,加上个FILE STATUS IS XXXXX,然后在数据部吧XXXXX定义就OK,看了上面列举的返回码,你就应该知道,XXXXX一定是计算型的数据类型了,而且至少是两位,在数据布申明的时候,那就千万别把它整成字符型什么的.用个例子说明下吧:
  ...............................
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
                SELECT IN-FILE ASSIGN TO IN-FILE
                FILE STATUS IS  IN-FILE-STATUS.
       ................................
       ................................
       DATA DIVISION.
       ................................
       ................................
      WORKNG-STORAGE SECTION.
      77 IN-FILE-STATUS PIC 99.
       ................................
       ................................
       PROCEDURE DIVISION.
       ...............................
       ...............................
       003-OPEN-PART.
                 OPEN INPUT IN-FILE.
                 IF IN-FILE STATUS  NOT = 0
                     PERFORM 004-END-PART.
       004-END-PART.
                 STOP RUN.
       ..............................
       .............................
       看到这里,我笔者相信大家对文件的返回码,以及如何处理这些文件的返回码应该是有很一定的了解了.赶快打开终端,敲个简单的程序练练手吧.http://www/uc/myshow/blog/misc/gif/E___6702EN00SIGG.gif
  最后再附加两个有用的东东吧:
  1.解决
  HHCCP011I CPU0000: Disabled wait state
  PSW=000A0000 81007A7A
  如果你在启动hercules 的时候,遇到了这个问题,那你就真中枪了,因为你的卷坏了,有备份的,重新考过来覆盖吧,没有的话,重下吧(有空没空就备份下你的卷吧,以免出现各种情况啊)
  2.解决编译COBOL时的错误:
   Multiple "EVALUATE" objects were not separated by "ALSO".
   EVALUATE 句子里面 如有计算语句,加上COMPUTE语句。

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有