ESP Workload Automation

 View Only
  • 1.  Need to Schedule a job with tricky requirements

    Posted Nov 22, 2024 10:57 AM

    I have a request to schedule JOBB that follows JOBA (which has a datset trigger) such that 

    1. JOBB runs after JOBA only if JOBA completes after 7:30 PM 
    2. JOBB is Completed, Abandoned or Bypassed (not run) if JOBA completes before 7:30PM

    this is the rabbit trail I've gone down so far...   Any ideas/suggestions would be GREAT!  

    Thanks all!

    JOB JOBA
    RUN DAILY 
    RELEASE JOBALNK
    ENDJOB
     
    JOB JOBALNK LINK
    IF ESPAHH >  '19' AND ESPAMM > '30' +  
       THEN COMPLETE JOBB  +                                                         
       ELSE RELEASE JOBB
    ENDJOB
     
    JOB JOBB HOLD
    RUN DAILY
    AFTER JOBALNK
    ENDJOB

    Roger Webster

    State of Oregon



  • 2.  RE: Need to Schedule a job with tricky requirements

    Broadcom Employee
    Posted Nov 25, 2024 06:47 AM
    Edited by Jonas Dusil Nov 25, 2024 06:58 AM

    Hi Roger,

    there are probably many ways how to achieve this and your idea with logic in the link would be possible as well.

    I would consider following approach:
    Utilizing on-request job for JOBB. Two self-completing tasks (similar to links, but more reliable in some edge scenarios) would be used to 

    1. REQUEST the JOBB at specified time
    2. Cleanup the first task if the request is not needed after JOBA run fine before the deadline (this is not to produce unnecessary error messages)

    APPL TEST                                                                                                     
                                                                            
    JOB JOBA                                                                
    RUN ANY                                                                 
    MEMBER LONGJOB                                                          
    RELEASE ADD(JOBB,COMPREQ)                                               
    ENDJOB                                                                  
                                                                            
    JOB COMPREQ TASK SELFCOMPLETING                                         
    /* completes REQB task,                                                 
    /* not to produce 2820E JOB JOBB HAS BEEN ALREADY BEEN BYPASSED         
    /* from the REQUEST command                                             
    /* if the error on the console and the log is not a problem,            
    /* this job can be omitted                                              
    ESPNOMSG AJ REQB COMPLETE APPL(%ESPAPPL..%ESPAPGEN)                    
    RUN ANY                                                                 
    ENDJOB                                                                  
                                                                            
    JOB REQB TASK SELFCOMPLETING                                            
    /* using DELAYSUB statement postpones REQUEST of the JOBB to 7:30       
    DELAYSUB 7:30                                                           
    ESPNOMSG AJ JOBB REQUEST APPL(%ESPAPPL..%ESPAPGEN)                      
    RUN ANY                                                                 
    ENDJOB                                                                  
                                                                            
    JOB JOBB REQUEST                                                        
    /* JOBB is defind as REQUEST job and will be bypassed unless REQUESTed  
    RUN ANY                                                                 
    MEMBER IEFBR14                                                          
    ENDJOB                                                                  



    This is how the run before time X would look like:

    COMPREQ  COMPLETED AT 
    JOBA     COMPLETED AT 
    JOBB     BYPASSED                    
    REQB     COMPLETED(F) AT 


    And this is after time X:

    COMPREQ  COMPLETED AT   
    JOBA     COMPLETED AT 
    JOBB     COMPLETED AT  
    REQB     COMPLETED(F) AT 



    Please take this only as a suggestion of how I would approach the problem. There might be other / better ways as well.

    Regards



    ------------------------------
    Jonáš Dusil
    Product Owner | ESP Workload Automation | Mainframe Software Division
    ------------------------------



  • 3.  RE: Need to Schedule a job with tricky requirements

    Broadcom Employee
    Posted Nov 25, 2024 08:36 AM
    Edited by Lucy Zhang Nov 25, 2024 03:13 PM

    Hi Jonas,

    I like your idea of defining JOBB as a REQUEST JOB.

    Following is another solution:
    APPL  . . . 
    .....
    SYMBOL %
    CHKTIME=''

    JOB JOBA
    RUN DAILY 
    RELEASE JOBALNK
    ENDJOB
     
    JOB JOBALNK TASK SELFCOMPLETING
    /* SELFCOMPLETING TASK will make sure the AJ command finishes before release JOBB*/
    /* this will generate the current real time*/

    GENTIME NW REALNOW 
    CHKTIME='%NWHH%NWMN%NWSS'
    /* REQUEST JOBB if it's after 7.30PM*/

    IF %CHKTIME GE '19.30.00' THEN  DO
         ESPNOMSG AJ JOBB REQUEST APPL(%ESPAPPL..%ESPAPGEN)   
    ENDDO 
    RUN DAILY                                           
          
    ENDJOB
     
    JOB JOBB REQUEST
    RUN DAILY
    AFTER JOBALNK
    ENDJOB




  • 4.  RE: Need to Schedule a job with tricky requirements

    Posted Nov 25, 2024 11:09 AM
    Thank you both so much!
    I like both ideas and tried Lucy's first. The real puzzling thing now is - though I copied it directly and it simulates exactly right - when it runs it gets an error saying the CHKTIME is not defined.
    Simulate:
    INVOKE SYSXR.CAESP.TET.APPLLIB(JOEJOBS)
    APPL JOEJOBS
    JCLLIB 'SYSXN.TESTE.SCHEDJCL'
    JOB JOBA
    RUN DAILY
    RELEASE JOBALNK
    ENDJOB
    JOB JOBALNK TASK SELFCOMPLETING
    GENTIME NW REALNOW
    CHKTIME='%NWHH%NWMN%NWSS'
    IF %CHKTIME GE '19.30.00' THEN DO
    ENDDO
    ENDJOB
    JOB JOBB REQUEST
    RUN DAILY
    AFTER JOBALNK
    ENDJOB
    SIMULATION OF EVENT TECH.JOEJOBT AT 07.37.28 ON MONDAY NOVEMBER 25TH, 2024
    JOBS: JOBA, JOBB
    2 JOBS SELECTED FOR SUBMISSION

    JOB TYPE-JOBNAME---HC-RELEASES
    JOB JOBA 0 JOBB
    REQUEST JOBB 1 (NONE)

    Trigger
    ESTETST0528E ERROR OCCURRED PROCESSING EVENT TECH.JOEJOBT IN APPL JOEJOBS.40
    ESTETST0027E IF %CHKTIME GE '19.30.00' THEN DO
    ESTETST0013E VARIABLE CHKTIME NOT DEFINED

    How can it not be defined when it's defined in the previous statement?
    Sorry, this just threw me for a loop - what am I missing?




  • 5.  RE: Need to Schedule a job with tricky requirements

    Broadcom Employee
    Posted Nov 25, 2024 11:32 AM

    Hi Roger,

    This is possible if the variable introducer is NOT %.

    You can add below in the ESP Proc to overwrite the one defined in ESPPARM:
    SYMBOL %

    Hope this helps,

    Lucy




  • 6.  RE: Need to Schedule a job with tricky requirements

    Broadcom Employee
    Posted Nov 25, 2024 03:15 PM

    Just FYI.

    I updated my above solution, sorry that I didn't fully test it.

    Lucy