Serial files must be implemented as IMS™ message queues in IMS/VS. They can be implemented as message queues, OS/VS files, VSAM files, or GSAM files for IMS BMP. Serial files can be implemented as OS/VS files, VSAM files, or GSAM files for z/OS® batch. The following discussion deals with using GSAM files or message queues for serial files.
Online programs that run in IMS/VS implement serial files as IMS message queues. Programs that run as IMS BMP programs can also implement serial files as message queues. You can use the add and get next I/O statements as well as close for output files. If you select IMS/VS or IMS BMP as the target runtime environment, you can define serial or print files as being associated with a message queue. You must associate all serial files and print files with message queues for IMS/VS. Only a single input file can be associated with the message queue.
You must indicate the 1- to 8-character destination ID for printer or serial file data. The name must match the ID of an IMS logical terminal or a transaction code that is defined in the IMS system definition.
The file name is the default resource name for the message queue. You can override this default in the resource association part.
If the PCB that you select is a modifiable alternate or express alternate PCB, you can override the default message queue name at run time by setting a value for sysVar.resourceAssociation for a file or converseVar.printerAssociation for a printer in the program. sysVar.resourceAssociation is treated as a local variable. Setting sysVar.resourceAssociation for a record in one program does not affect sysVar.resourceAssociation in another program. An add statement writes to the message queue identified by the setting of sysVar.resourceAssociation for that program.
For multiple-segment message queues, a series of adds to the serial file is treated as though each add statement were for a segment of a single message. The message is not ended until you issue a close statement or reach a commit point. The generated COBOL program issues an IMS PURG call for the close statement. You can then begin adding segments of another message and close it. Multiple-segment message queues are not valid for printer files.
If you issue a get next statement for a MMSGQ serial file, the generated program issues an IMS get unique call to get the first segment of the message. Additional get next statements result in GN calls to get the remaining segments of the message. At the end of all the segments in a message, the generated COBOL program sets the noRecordFound record state. If you continue scanning, the generated program starts another series of get unique (GU) calls, followed by get next (GN) calls. When no more messages are found, the generated program returns an endOfFile state.
You must also specify a PCB name for the serial file that is associated with a message queue. You must specify the name assigned to the I/O PCB as the PCB name for a serial input file. The I/O PCB is the only message queue used for input. If you use a serial input file, you must use a main batch or called batch program. The generated program handles all I/O PCB logic for main transaction programs.
When you define a serial record to associate with a message queue, you should define only the program data. The generated COBOL program adds the IMS message header (length, ZZ, and transaction code) for an add statement and removes it for a get next statement.
For IMS/VS you must associate printer files with message queues. For IMS BMP, you can associate printer files with message queues. You associate printer files with message queues the same way you associate serial files with message queues, with the exception that SMSGQ is the only valid file type for a resource association whose file name is printer. In your IMS system definition, you must define the message queue name that you use in the runtime environment as a logical terminal. converseVar.printerAssociation can be used to change the printer destination at run time. For example, you could define a table of user IDs and the printer ID that each user normally uses. By setting converseVar.printerAssociation, you can route the printer output to a printer near the program user.
Related concepts
DL/I database support
Record types and properties
Segmentation in text applications
Related reference
add
converse
converseVar.printerAssociation
close
get
sysVar.resourceAssociations
Related tasks
Interacting with terminals in IMS