On Mon, Aug 21, 2017 at 7:40 AM, scott Ford <[email protected]> wrote:
> Guys/Gals: > > I need some help on a error I am not real familiar with in Cobol. > I need write a generalized file-handler for files. Where do I start ? > These are mostly QSAM files.. but i have to deal with Open/close/empty > files, wrong length records...I have seen U1035 or similar errors and have > done some reading in the manuals. Whats the easiest most effective method > to handle file errors ? > We generally use the FILE STATUS clause https://www.ibm.com/support/knowledgecenter/en/SS6SG3_4.2.0/com.ibm.entcobol.doc_4.2/PGandLR/ref/rliossta.htm SELECT SOMEFILE ASSIGN TO UT-S-DDNAME FILE STATUS IS WS-SOMEFILE-STATUS WS-SOMEFILE-STATUS2 ... 77 WS-SOMEFILE-STATUS PIC 99. 01 WS-SOMEFILE-STATUS2. 05 WS-SOMEFILE-VSAM-RC PIC S99 BINARY. 05 WS-SOMEFILE-VSAM-FC PIC S99 BINARY. 05 WS-SOMEFILE-VSAM-FB PIC S99 BINARY. The WS-SOMEFILE-STATUS2 only applies to VSAM data sets. This will handle _most_ of the I/O "problems" which you may encounter. One thing you need to remember is that a COBOL definition cannot handle a "generic" situation. In particular, if you are reading an FB type data set, then the FD for that data set _must_ have the proper record length. If it does not, you CANNOT open it successfully. The above FILE STATUS will let you "trap" the problem and report a failure. But that is _all_ that it can do. A single FD simply cannot read both an FB/80 and an FB/90 (for example) file. Another thing to look is the the DECLARITIVES section. https://www.ibm.com/support/knowledgecenter/en/SS6SG3_4.2.0/com.ibm.entcobol.doc_4.2/PGandLR/ref/rlpdsdec.htm This section can handle most error situations on a file. The last thing that I will mention is not really a COBOL language facility, but an LE facility. That is the LE abend handler, CEEHDLR. https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.1.0/com.ibm.zos.v2r1.ceea300/clchdlr.htm Being LE in nature, it is not as easy to understand as COBOL. But it is LE's version of an ESTAE. > Regards, > Scott > > -- > > > > *IDMWORKS * > > Scott Ford > > z/OS Dev. > > > > > “By elevating a friend or Collegue you elevate yourself, by demeaning a > friend or collegue you demean yourself” > > > > www.idmworks.com > > [email protected] > > Blog: www.idmworks.com/blog > > > > > > *The information contained in this email message and any attachment may be > privileged, confidential, proprietary or otherwise protected from > disclosure. If the reader of this message is not the intended recipient, > you are hereby notified that any dissemination, distribution, copying or > use of this message and any attachment is strictly prohibited. If you have > received this message in error, please notify us immediately by replying to > the message and permanently delete it from your computer and destroy any > printout thereof.* > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to [email protected] with the message: INFO IBM-MAIN > -- If you look around the poker table & don't see an obvious sucker, it's you. Maranatha! <>< John McKown ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
