MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to monitor if a JCL submitted under REXX is completed

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
ankushw
Beginner


Joined: 14 Mar 2005
Posts: 2
Topics: 2

PostPosted: Mon Mar 14, 2005 6:01 am    Post subject: How to monitor if a JCL submitted under REXX is completed Reply with quote

I need to monitor a JCL that I'm submitting thru my REXX code, and make my further REXX code wait and execute only after successful completion of this JCL.
Can someone pls help !
Back to top
View user's profile Send private message MSN Messenger
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Wed Mar 30, 2005 9:12 am    Post subject: Reply with quote

I'm thinking that a combination of the TSO "STATUS" and "OUTPUT" commands ought to work.
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Wed Mar 30, 2005 10:30 am    Post subject: Reply with quote

And search for how to use the USS sleep command. You don't want to just sit in a tight loop looking at the queues.

It is also possible to see what is running in the system by chasing control blocks, but finding the job number is not easy so if there is a possibility of multiple (Sequential) jobs running with the same name, you'll need to search for the job number as well as the name per Kevin's suggestion.
Back to top
View user's profile Send private message Visit poster's website
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Wed Mar 30, 2005 10:31 am    Post subject: Reply with quote

actually, you have to use Status because you can't tell by looking at control blocks if the job is still waiting to start.
Back to top
View user's profile Send private message Visit poster's website
acevedo
Beginner


Joined: 03 Dec 2002
Posts: 127
Topics: 0
Location: Europe

PostPosted: Mon Apr 04, 2005 2:25 pm    Post subject: Reply with quote

In some cases another option is run the job in foreground...of course it depends on number of steps, how long it's gonna take... but it's just another option.
Back to top
View user's profile Send private message
stefan
Beginner


Joined: 20 Nov 2003
Posts: 41
Topics: 2
Location: Germany

PostPosted: Tue Apr 05, 2005 1:24 am    Post subject: Reply with quote

You should catch the job name and job number by using x = OUTTRAP('trap.') before the SUBMIT command and x = OUTTRAP('OFF) after it. The stem variable "trap." will contain all lines written to your terminal, thus the line "IKJ56250I JOB USERIDX(JOB49616) SUBMITTED". After that you should code a loop using "address syscall 'sleep' 1;x=OUTTRAP('trap.');address tso 'status' jobname;x=OUTTRAP('OFF')". These lines cause your program to wait for 1 second and query the status of all jobs with the specified jobname. The output will be written once again to your terminal and thus trapped by the OUTTRAP function into the stem variable trap.

But although it seems quite easy to get this information, I think it is poor design to loop in an online application to wait for the result of a asynchronously running batch task. I would always prefer a solution as acevedo has outlined.
Back to top
View user's profile Send private message
Ramkumar
Beginner


Joined: 04 Apr 2005
Posts: 19
Topics: 10

PostPosted: Fri Apr 08, 2005 6:48 am    Post subject: Reply with quote

Hi stefan,
I tried that 'STATUS' option. But it will give only the info whether the job is over or not. From that we won't get any thing like whether it was successful or not. We will get the return code from 'OUTPUT' option. But i was not able to trap that one. Is there any solution for this?
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Fri Apr 08, 2005 7:33 am    Post subject: Reply with quote

Ramkumar,

Please search before posting. Trapping the return code is already discussed here. check this link

http://www.mvsforums.com/helpboards/viewtopic.php?t=44&highlight=return+code

Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Fri Apr 08, 2005 8:06 am    Post subject: Reply with quote

I setup a quick feasability test:
Code:

/* REXX */                                                             
Queue "//SUPERK# JOB (.....),'',CLASS=T,MSGCLASS=X,"                   
Queue "//       MSGLEVEL=(1,1)"                                       
Queue "//*"                                                           
Queue "//STEP0001 EXEC PGM=IEFBR14"                                   
Queue "//*"                                                           
Queue Left("$$",80)                                                   
o = OUTTRAP("output.",,"CONCAT")                                       
"SUBMIT * END($$)" /* Submit JCL */                                   
o = OUTTRAP(Off)                                                       
msg = Strip(output.2)                                                 
Parse Var msg msgid 'JOB' jobname '(' jobid ')' .                     
Do Forever                                                             
  o = OUTTRAP("output.",,"CONCAT")                                     
  "STATUS "Strip(jobname)"("Strip(jobid)")"                           
  o = OUTTRAP(Off)                                                     
  Parse Var output.1 msgid 'JOB' jobname '(' jobid ')' msg             
  If msg = "ON OUTPUT QUEUE" Then Leave                               
End                                                                   
dsname = Strip(jobname)||"."||Strip(jobid)||".OUTLIST"                 
"OUTPUT "Strip(jobname)"("Strip(jobid)") PRINT("dsname")",     
 "BEGIN HOLD KEEP"     
Exit


This gives me a dataset 'userid.JOBNAME.JOB#####.OUTLIST' with all of the runtime statistics.
Back to top
View user's profile Send private message
iklingen
Beginner


Joined: 11 Feb 2005
Posts: 5
Topics: 2

PostPosted: Mon Apr 11, 2005 8:00 am    Post subject: Reply with quote

My solve is below.
Notes:
1) I've run the rexx from batch;
2) you must have a NETRC dataset in your 'home';
3) FTP server must be running with JESINTERFACELEVEL = 2.

Code:

//XXXXXXX JOB ,'MY NAME',CLASS=A,REGION=4M,MSGCLASS=X
/*JOBPARM SYSAFF=*
//MAKEPDS  EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT2   DD UNIT=SYSALLDA,DISP=NEW,SPACE=(TRK,(10,10,1)),
//            DCB=(RECFM=VB,LRECL=256,DSORG=PO),DSNTYPE=PDS
//SYSUT1   DD DATA,DLM='$$'
/*REXX*/
/*** MAIN **************************************************************/

USERPREF = SYSVAR('SYSPREF')
USERID   = SYSVAR('SYSUID')

Jobname  = 'Your_Job_Name'

say 'Your USERID  =' USERID
say 'Your USERPREF=' USERPREF

/*** Submit JCL and get it JobID  ***/
drop FTP_INP.
FTP_INP.1 = "SITE FILETYPE=JES"
FTP_INP.2 = "PUT 'YOUR.PDS.WITH(JCL)'"
FTP_INP.3 = "QUIT"

call FTP

if DATATYPE(FTP_OUT.0) <> 'NUM' then do
    say "Invalid OUTPUT to submit: "FTP_OUT.0
    exit 16
end

do i = 1 to FTP_OUT.0 until JobID <> ''
    parse var FTP_OUT.i '250-It is known to JES as ' JobID .
end

if JobId = '' then do
    say 'Could not get JobID from the following FTP output:'
    do i = 1 to FTP_OUT.0
        say FTP_OUT.i
    end
    exit 16
end

/*** Wait of ending our JCL ***/
drop FTP_INP.
FTP_INP.1 = "SITE FILETYPE=JES JESJOBNAME="Jobname" JESSTATUS=ALL"
FTP_INP.2 = "DIR"
FTP_INP.3 = "QUIT"

Job_RC = ''

t = TIME('R')

do while TIME('E') < 1800.0

    call FTP
    if DATATYPE(FTP_OUT.0) <> 'NUM' then do
        say "Invalid OUTPUT to wait: "FTP_OUT.0
        exit 16
    end

    do i = 1 to FTP_OUT.0 until Status <> ''
        parse var FTP_OUT.i . (Jobname) . (JobID) (USERID) Status . 'RC=' Job_RC .
    end

    if Status = 'OUTPUT' then do
        leave
    end

end

if Status <> 'OUTPUT' then do
    say 'Could not wait of the ending of the 'JobID
    say 'FTP output:'
    do i = 1 to FTP_OUT.0
        say FTP_OUT.i
    end
    exit 16
end

say JobID' was ended with RC='Job_RC', execution time 'TIME('E')

/*** Capture sysout for our job ***/
drop FTP_INP.
FTP_INP.1 = "SITE FILETYPE=JES JESJOBNAME="Jobname" JESSTATUS=ALL"
FTP_INP.2 = "GET "JobID" 'PDS.FOR.YOUR(SYSOUT)'"
FTP_INP.3 = "QUIT"

call FTP

if DATATYPE(FTP_OUT.0) <> 'NUM' then do
    say "Invalid OUTPUT to capture: "FTP_OUT.0
    exit 16
end

/*** Purge sysout ***/
drop FTP_INP.
FTP_INP.1 = "SITE FILETYPE=JES JESJOBNAME="Jobname" JESSTATUS=ALL"
FTP_INP.2 = "DELETE "JobID
FTP_INP.3 = "QUIT"

call FTP

exit

/*---------------------------------------------------------------------*/

dd_alloc: procedure
    arg definition

    rc = bpxwdyn( 'ALLOC 'definition )
    if rc <> 0 then do
        say 'ERROR 'D2X(rc)'ON DYNAMIC ALLOCATION DD:'
        say definition
        exit 16
    end
return

dd_free: procedure
    arg definition

    rc = bpxwdyn( 'FREE 'definition )
    if rc <> 0 then do
        say 'ERROR 'D2X(rc)'ON DYNAMIC ALLOCATION DD:'
        say definition
        exit 16
    end
return

FTP: procedure expose USERPREF FTP_INP. FTP_OUT.

    /* OUTPUT DD for the FTP client is statcic */
   
    call dd_alloc 'DD(INPUT) NEW RECFM(FB) LRECL(80) UNIT(SYSDA)'
    call dd_alloc 'DD(NETRC) DSN('USERPREF'.NETRC) SHR'

    "EXECIO * DISKW INPUT ( STEM FTP_INP. OPEN FINIS )"

    "FTP localhost"

    call dd_free 'DD(NETRC)'
    call dd_free 'DD(INPUT)'

    DROP FTP_OUT.

    "EXECIO * DISKR OUTPUT ( STEM FTP_OUT. OPEN FINIS )"

    if RC <> 0 then do
        say "Could not read FTP output, EXECIO.RC="rc
        say "Input FTP commands were:"
        do i = 1 while FTP_INP.i <> 'FTP_INP.'i
            say FTP_INP.i
        end
        exit 16
    end

return

/***********************************************************************/
$$
//SYSIN    DD *
     GENERATE MAXNAME=1
       MEMBER NAME=MAIN
/*
//*
//*  MAIN script
//*
//MAIN     EXEC PGM=IKJEFT01,PARM='MAIN'
//SYSEXEC  DD DSN=*.MAKEPDS.SYSUT2,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD DUMMY
//* temporary dataset to FTP output:
//OUTPUT   DD DISP=NEW,DCB=(LRECL=256,RECFM=VB,DSORG=PS),
//            SPACE=(TRK,(10,10)),UNIT=SYSDA


Thanks,
Igor
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group