These excerpts from EGL programs show interaction with IMS™ terminals, message queues, and serial files.
//define PSB
Record addToQueue type PSBRecord { defaultPSBName="MYTRXCD1" }
// three PCBs required for CBLTDLI on IMS
iopcb IO_PCBRecord { @PCB { pcbType = TP } };
elaalt ALT_PCBRecord { @PCB { pcbType = TP } };
elaexp ALT_PCBRecord { @PCB { pcbType = TP } };
// other database PCBs
...
end
Record myTransactionPart type serialRecord
{ fileName="MYMSGQUE" }
...
end
program addtrans type textUIProgram
{ alias = "MYTRXCD1", // IMS requires pgm to match PSB name
segmented = yes,
@DLI { psb = "mypsb" }}
use MYFORMS; // MYFORMS is a formGroup containing FORM1
// declare variables
myTransaction myTransactionPart; // serial record for message queue
mypsb addToQueue; // psb
function main()
...
converse FORM1;
// do whatever processing is necessary
move FORM1 to myTransaction byName;
add myTransaction;
...
end
end
<ResourceAssociations name="IMS_RESOURCE_ASSOCIATION">
<association fileName="MYMSGQUE">
<imsvs>
<smsgq systemName="NEXTTRX" pcbName="elaalt"/>
</imsvs>
</association>
<association fileName="MYINQUE">
<imsvs>
<smsgq systemName="NEXTTRX" pcbName="iopcb"/>
</imsvs>
</association>
</ResourceAssociations>
Because addtrans is a textUI program, EGL generates control logic to interface to the IMS environment. IMS programs are expected to read the input message queue until the queue is empty. Therefore, EGL generates logic into the program so that once the program responds to the current user (using a converse or show statement) or transfers the responsibility for responding (using a transfer to transaction statement), the program loops to read the next input message from the queue. For an overview, see Interacting with terminals in IMS; for more information, see "Multiple users and message queues" in this topic.
You can also create a program to process the messages that program addtrans writes to the message queue. The program must be a basic program that gets records from a serial file and associates the serial file with the I/O PCB.
//define PSB
Record getFromQueue type PSBRecord { defaultPSBName="MYTRXCD2" }
// three PCBs required for CBLTDLI on IMS
iopcb IO_PCBRecord { @PCB { pcbType = TP } }
elaalt ALT_PCBRecord { @PCB { pcbType = TP } };
elaexp ALT_PCBRecord { @PCB { pcbType = TP } };
// other database PCBs
end
program gettrans type basicProgram
{ alias = "MYTRXCD2"
@DLI { psb = "mypsb" }}
// declare variables
myTransaction myTransactionPart // serial record for message queue
{fileName="MYINQUE"};
mypsb getFromQueue; // psb
function main()
while (myTransaction not endOfFile)
get next myTransaction;
// do whatever processing is necessary
end
end
end
When you generate the program for either the IMS/VS or the IMS BMP environments, you must also specify a resource association part that associates the serial file with a message queue, as well as the name of the PCB to use. In this case, the I/O PCB is used for input, as shown in the ResourceAssociations part in the previous section. The systemName property is optional. The program reads the message queue associated with the transaction that started the program, based on the IMS system definition. EGL sets sysVar.transactionID based on the IMS transaction id in the input message.