[AWA] How to write scripts that auto cancel manually job with status "Waiting for host"

Document ID : KB000113322
Last Modified Date : 12/09/2018
Show Technical Document Details
Introduction:
Recently one of server down which caused agent inactive, but our Jobs with that agent still pending with "Waiting for the host" After 2 days we noticed of this, we had to cancel it manually. We want to check if possible that after certain period those jobs with "Waiting for the host" will be auto ended. How should we set up for this.
Instructions:
SOLUTION 1:
You can use another Jobs run in another agent that active right after the main jobs (jobs that you want to cancel manually when Waiting for host status appear) active.
As you can see in the images, I use JOBS.WIN.NEW.4 to monitor JOBS.WIN.NEW.5.
- Put a script to active Jobs4 at the end of Jobs5 process

User-added image
- Put in Jobs4 wait command for amount of time

- Put in Jobs4 post process the scripts that monitoring the Jobs5 status, and cancel Jobs5 when it has "waiting for host" status.

User-added image


SOLUTION 2:
You can use a set of SQL VARA and a script object to perform cancel action. You can run the script every time you have "Waiting for host" job.

The SQL VARA statement is:
select EH_Ah_Idnr from EH where EH_status='1696'
User-added image

The Script content is:
:SET &HND#=PREP_PROCESS_VAR(VARA.SQL.NEW.1)
:PROCESS &HND#
:SET &VK#=GET_PROCESS_LINE(&HND#,1)
! :   SET &VALUE# = GET_PROCESS_LINE(&HND#,2)
:SET &ACTION#=CANCEL_UC_OBJECT(&VK#,"ENDED_CANCEL")
:PRINT "&VK# &ACTION#"
:ENDPROCESS
User-added image
 
Additional Information:
Script to active another job in main job process
:SET &JNR# = ACTIVATE_UC_OBJECT(JOBS,JOBS.WIN.NEW.4)

Scripts to cancel manually job with "Waiting for host" status:
:SET &RUNNR# = GET_UC_OBJECT_NR(JOBS.WIN.NEW.5)
:SET &STATUS# = GET_UC_OBJECT_STATUS(JOBS,&RUNNR#)
:IF &STATUS# = "1696"
:SET &ACTION# = CANCEL_UC_OBJECT(&RUNNR#, "ENDED_CANCEL")
:ENDIF