COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

The FILE_PURGE_ procedure accepts the internal form of a file name as a parameter. To determine
whether the purge operation was successful, call the HP COBOL routine COBOLFILEINFO with the
file name as its parameter. COBOLFILEINFO returns an error value. If the purge operation was
successful, the error value is zero.
One common reason for a purge operation to fail is that the process’s accessor ID was not
authorized to purge the file according to the security attributes of the file.
Example 288 Purging a File From an HP COBOL Program
WORKING-STORAGE SECTION.
01 FS-ERROR NATIVE-2
01 EXTERNAL-NAME PIC X(30).
01 INTERNAL-NAME.
03 VOL-NAME PIC X(8).
03 SUBVOL-NAME PIC X(8).
03 FILE-NAME PIC X(8).
01 PURGE-RESULT PIC S9(4) COMP.
88 PURGED-OK VALUE ZERO.
...
PROCEDURE DIVISION.
...
MOVE "$FIFTY.NIFTY.SHIFTY" TO EXTERNAL-NAME.
MOVE "$FIFTY" TO VOL-NAME.
MOVE "NIFTY" TO SUBVOL-NAME.
MOVE "SHIFTY" TO FILE-NAME.
ENTER "FILE_PURGE_" USING EXTERNAL-NAME (1:19)
GIVING FS-ERROR.
ENTER TAL "COBOLFILEINFO" USING INTERNAL-NAME PURGE-RESULT
IF PURGED-OK
...
If the reason you want to purge a file is that you want to have a temporary file for the duration of
a single process and the name of the file is not of any real interest, use the special name #TEMP
in the ASSIGN clause of the file-control entry at compilation time (or in a TACL ASSIGN command
at execution time). When you specify #TEMP, the run-time routines create a temporary file on the
process’s default volume.
You can also create a temporary file on a specific volume by just assigning the HP COBOL file to
the volume name, specifying spaces. It is often useful to locate a temporary file on a different
volume to improve performance.
The TACL ASSIGN command enables you to allocate specific primary and secondary extents for
temporary and permanent disk files that a process is to create. If you do not specify extents, the
run-time routines use a primary extent size of 4 disk pages (each page holds 2048 bytes) and a
secondary extent size of 20 disk pages.
Unless the CLEARONPURGE flag is set for a file, purging the file does not obliterate the data on
the disk. If security is a major consideration, use one of these to set the CLEARONPURGE flag:
The FUP SECURE command with the CLEARONPURGE option
The SETMODE routine
For more information about the FILE_PURGE_ and SETMODE routines, see the Guardian Procedure
Calls Reference Manual.
Purging the Contents of a File From an HP COBOL Program
It is sometimes convenient to purge the contents of a file but keep the file in the directory for later
use. The HP COBOL run-time routines do this when you open a file for output (if you have read
access to the file). You might choose (for security) to purge the contents of a temporary work file
Using Enscribe and Operating System Routines 885