10. MODIFICATION › 10.1 Standard Exits › VMTFDEF VMTXMIT File Definition Exit Example 1
VMTFDEF VMTXMIT File Definition Exit Example 1
+----------+
| VMTFDEF | VMTXMIT File Definition Exit Example 1
+----------+
The following code sample illustrates a simple implementation
of the VMTFDEF EXEC. This example is based VM/ESA monitor
data transmission with the following parameters specified:
Data Source : MONWRITE
Transmission Mode : SPOOL
Input data archive : No
Output data duplex : Yes
Other parameters have no bearing on this exit.
VMTFDEF will be called by VMTXMIT as follows:
rc = VMTFDEF(MONXA,INPUT) /* for input FILEDEF */
rc = VMTFDEF(MONXA,DUPLEX) /* for duplex FILEDEF */
rc = VMTFDEF(MONXA,TERMINATE) /* to clean up */
Sample code:
MONXA.INPUT:
monuser = 'MONWRITE' /* data file owner userid */
address = '192' /* data file owner minidisk */
fileid = 'MONITOR DATA' /* data file name */
'GLOBALV PUT FILEID' /* save file name */
'CP LINK' monuser address '345 RR password'
'ACCESS 345 C'
'ESTATE' fileid 'C'
if rc = 0 then 'FILEDEF INPUT DISK' fileid 'C'
else do
say 'VM/ESA monitor data file (' || fileid || ,
') was not found.'
say 'ESTATE failed RC=' || rc
end
exit rc
MONXA.DUPLEX:
'GLOBALV GET FILEID' /* get input data file name */
'ACCESS 301 B' /* our own DUPLEX disk */
'LISTFILE' fileid 'C (NOH LIFO' /* get input size */
if rc ^= 0 then exit rc /* should not happen */
pull . . . . . . orgblks . /* original size */
'QUERY DISK B (LIFO' /* DUPLEX disk statistics */
pull . . . . . . newbsz . . newavail .
pull . /* flush header line
'QUERY DISK C (LIFO' /* input disk statistics */
pull . . . . . . oldbsz . /* input disk block size */
pull . /* flush header line
mult = oldbsz/newbsz
newblks = (orgblks*mult+0.9)%1 /* new blocks required*/
if newavail < newblks then do /* copy disk does not */
/* have enough available space, exit RC=1 to halt */
/* or RC = -1 to continue without DUPLEX */
say 'Duplexing is not available, disk full'
exit 1 /* halt */
end
'FILEDEF DUPLEX DISK' fileid 'B'
exit 0
MONXA.OUTPUT:
/* This routine is not called for Transmission mode SPOOL */
exit 1
MONXA.ARCHIVE:
/* Parameter setup inhibits call to this routine */
exit 1
MONXA.TERMINATE:
'RELEASE C (DET' /* Drop input data disk */
'RELEASE B' /* Drop duplex data disk */
exit 0
COMMENTARY:
MONXA.INPUT determines the name of the input data file. In
this example, the name is fixed, but a routine to dynamically
determine the file name could be used. The GLOBALV command
sets a variable that is used in MONXA.DUPLEX. This sample
allocates the minidisk that contains the VM/ESA monitor data.
If the expected input file is not found, VMTFDEF exits RC=1
to cause VMTXMIT to halt processing. If the file is found, a
FILEDEF is issued.
MONXA.DUPLEX is called because of parameter specifications.
It uses the GLOBALV command to get the input file name. It
then checks the allocation of the input file to determine
whether or not the DUPLEX copy will fit on the DUPLEX disk (B
in this example). If the DUPLEX disk has enough space, a
FILEDEF is issued, otherwise VMTFDEF exits with RC=1, to halt
processing. If duplexing is not critical, this routine could
exit RC=-1 to continue without duplexing. Tape output can be
used for the DUPLEX data file instead of disk.
Note: In this example, the name of the duplex file is the
same as the input file (only the minidisks are different).
This information could be used by another EXEC to erase the
original file, providing more space for new data. The duplex
minidisk could be cleaned up on a periodic basis.
Note: If VMTXMIT is used to transfer data that has been
DUPLEXed (or ARCHIVEd), the Data Source parameter in VMTXMIT
must be changed to FILE.
MONXA.TERMINATE is called to deallocate the input and duplex
minidisks. The input disk is released from CMS and detached
from the virtual machine (because it belongs to another
user). The duplex disk is released from CMS.
The MONXA.ARCHIVE and MONXA.OUTPUT routines are not called by
VMTXMIT because of parameter specifications. They are set to
issue an error return code in case the parameters are changed
and VMTFDEF is not updated.