Page 1 of 1

Waiting for submitted job to complete

PostPosted: Wed Aug 12, 2009 9:02 pm
by pcs2smf
I'm trying to submit a job from a rexx routine. It takes about 20 seconds to run, then when it completes browse the output dataset.
so far I have:
DUMMY = OUTTRAP("OUTLINE.","*")
"SUBMIT * END(GO)"
SAY "OUTPUT DATASET : "||DSNAME1
SAY " "
SAY "THIS MAY TAKE A MINUTE"
SAY "PLEASE WAIT UNTIL JOB COMPLETES"
SAY OUTLINE.2
JOBNAME = SUBWORD(OUTLINE.2,2,1)
JOBNAME = STRIP(SUBSTR(JOBNAME,1,8))

/* WAIT UNTIL THE JOB COMPLETES. */
I = 1
DO FOREVER
FINALMSG = OUTLINE.I
JB = SUBWORD(FINALMSG,4,1)
IF JB = JOBNAME THEN exit
I = I + 1
END
DUMMY = OUTTRAP("OFF")
'DELSTACK'
ADDRESS ISPEXEC "BROWSE DATASET("DSNAME1")"
EXIT

so far I will get the following:
OUTPUT DATASET : PRODWORK.PCS2SMF.ESP.REPORT

THIS MAY TAKE A MINUTE
PLEASE WAIT UNTIL JOB COMPLETES
JOB PPCS2SMF(JOB59492) SUBMITTED
11.29.38 JOB59492 $HASP165 PPCS2SMF ENDED AT UPSRRCH MAXCC=0 CN(INTERNAL)

unfortunately it never exits after job completes. Anyone have any ideas?

Re: Waiting for submitted job to complete

PostPosted: Wed Aug 12, 2009 9:42 pm
by MrSpock
Honestly, what you're doing doesn't sound like a good idea (what if the job doesn't or can't run?). Why can't you create the required dataset in the foreground?

Anyway, I don't see any logic in the looping structure where you can check for the status of the job (you need to read up on what messages are and are not trappable via the Outtrap command). You might want to use the TSO OUTPUT command and keep waiting until the job is on the output queue. Or, make calls to your spool interface tool (SDSF, IOF, Sysview, etc.) and query on the status that way.

Re: Waiting for submitted job to complete

PostPosted: Wed Aug 12, 2009 9:44 pm
by MrSpock
Or, you could just keep trying to allocate the dataset (DISP=OLD) until you're successful.

Re: Waiting for submitted job to complete

PostPosted: Thu Aug 13, 2009 11:52 am
by expat
This has been discussed quite a few times on the main forum and every time the response is Do NOT do this

You lock up a terminal preventing any other work being done from that terminal until such time as the job completes and your program continues.

It is a bad idea.