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

SET TYPE K
SET EXT (1000 RECS, 2000 RECS)
SET REC 200
SET BLOCK 2048
CREATE $COBOL.PROGS.JAKE
Creating and Using Queue Files
A queue file is an indexed file (and therefore, a key-sequenced file) that can function as a queue.
Processes can queue and dequeue records in a queue file.
Queue files contain variable-length records that are accessed by values in designated key fields.
Unlike other key-sequenced files, queue files have prime keys but cannot have alternate keys. The
prime key for a queue file includes an 8-byte timestamp; you can add a user key if desired. The
disk process inserts the timestamp when each record is inserted into the file, and maintains the
timestamp during subsequent file operations.
For more information about queue files, see the Enscribe Programmer’s Guide.
Creating a Queue File
Before you can use a queue file, you must create it (with the FUP CREATE command, for example).
Its prime key must have at least 8 bytes (for the timestamp). If you want to add a user key, describe
it before describing the timestamp, as in Example 284.
Example 284 Creating a Queue File With a Timestamp and a User Key
SELECT queue-file ASSIGN to queuef
ORGANIZATION IS INDEXED
ACCESS MODE IS SEQUENTIAL
RECORD KEY IS queue-key
FD queue-file
RECORD IS VARYING FROM 10 TO 100 CHARACTERS
DEPENDING ON rec-len.
01 queue-rec.
02 queue-key.
03 user-key PIC XX.
03 timestamp PIC X(8).
02 the-rest PIC X(90).
Opening a Queue File
Open a queue file for shared access and SYNCDEPTH 0; for example:
OPEN queue-file INPUT SHARED SYNCDEPTH 0
Reading a Queue File
When you read a record of a queue file, you have a choice of:
Removing the Record From the Queue
Leaving the Record in the Queue
Removing the Record From the Queue
To read a record and remove it from the queue, use the READ ... NEXT WITH LOCK statement.
The compiler translates the READ ... NEXT WITH LOCK statement to a call to the Guardian routine
READUPDATELOCK[X].
Leaving the Record in the Queue
To read a record but leave it in the queue, use the READ ... NEXT statement (without LOCK). The
compiler translates the READ ... NEXT statement to a call to the Guardian routine READ[X].
868 Disk Input and Output