Monitor exit program examples
If an output queue monitor finds PGM123 in the User data (USRDTA) spooled file attribute of the
spooled file, but you want Content Manager OnDemand to use the application name INVOICES instead of
PGM123, the content of your user exit program might contain a line similar to the following line:
CHGVAR VAR(&APP) VALUE(’INVOICES’)
A more complex example involves
processing multiple spooled files, some of which must be archived under the same application and
application group. Others must be archived under a different application and application group. A
portion of the spooled file name attribute of the input spooled file determines which application
and application group to use. If the User data (USRDTA) spooled file attribute value is the same for all of the input spooled files, you can create a monitor exit program that is named the same as the value found in the USRDTA spooled file attribute. You would need to specify *USERDATA as the first value of the APPGRPSRC or APPSRC parameter of the STRMONOND command.
In the exit program, you can check the spooled file name, and then change the report name to whatever it should be.
For
example,
IF COND(&SPLFNAME = 'FRAS120') THEN(DO)
CHGVAR VAR(&APP) VALUE('VSAR')
CHGVAR VAR(&APPGRP) VALUE('VSARGRP')
RETURN
ENDDO
You
need one IF statement per report. If a portion of the spooled file name is the same (such as the first three positions as shown) and the application and application group are the same for some of the input files, you can still use the monitor exit program.
For
example:
IF COND(%SST(&SPLFNAME 1 3) = 'FRA') THEN(DO)
CHGVAR VAR(&APP) VALUE('VSAR')
CHGVAR VAR(&APPGRP) VALUE('VSARGRP')
RETURN
ENDDO
As another example, you can use a universal directory monitor exit program to modify the
application group name. If the exit program is called for the application group, set the application
group name by appending part 3 of the file name to part 2 of the file name with a dash separating
the parts.
IF COND(&CALLEDFOR = GROUP) THEN(CHGVAR +
VAR(&APPGRP) VALUE(&P2 *TCAT '-' *TCAT &P3))
In another universal directory monitor exit program, if the exit program is called for the
application, set the application name by appending the first 5 characters of part 4 of the file name
to the application name determined by the APPSRC
parameter.
IF COND(&CALLEDFOR = APP) THEN(DO)
/* Extract the first 5 characters from part 4. */
CHGVAR VAR(&STRING) VALUE(%SST(&P4 1 5))
/* Check that the first 5 characters have not already */
/* been appended to the application name. */
CHGVAR VAR(&EXISTS) VALUE(%SCAN(&STRING &APP) > 0)
IF COND(&EXISTS) THEN(GOTO CMDLBL(EXIT))
CHGVAR VAR(&APP) VALUE(&APP *TCAT '-' *TCAT &STRING)
ENDDO
EXIT: RETURN