Skip to main content

How can I find out how a file was opened?

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

Is there a variable (or function), similar to file status code, that can be queried to find out if a file was opened for input / i-o etc ?

Resolution:

You can use the "fcdreg" compiler directive, the "FH--FCD" special register and the "xfhfcd.cpy" copy book to gain access to the "fcd" file descriptions compiled into your program.

Define your "fcd" in your linkage section (1   myFcd.) followed by a copy statement retrieving the "xfhfcd.cpy" COBOL copy book delivered with your development system. In your procedure division set addressability to your "fcd" in your linkage section with a set statement. Compile your program with the "fcdreg" and "qual" compiler directives.

000010$ set fcdreg qual

000020 file-control.

000030     select myLogicalFile assign 'MYDATA.DAT' ...

000040 linkage section.

000050 1  myfcd.

000060     copy xfhfcd.cpy.

000070 procedure division.

000080     set address of myFcd to address of FH--FCD of myLogicalFile.

In the "fcd" at offset 6 there is an "FCD-ACCESS-MODE" item that indicates sequential (0), random (4) or dynamic (8). At offset 7 there is an "FCD-OPEN-MODE" item that indicates input (0), output (1), i-o (2), extend (3) or closed (128).

The copy book should be in your source directory and detailed definitions for each item defined in the copy book can be found in an article titled "File Control Description (FCD)" in Net Express Help.

Attachments:

fcdreg.zip

Old KB# 7088

#COBOL
#RMCOBOL
#ServerExpress
#netexpress
#AcuCobol