Automic Workload Automation

 View Only
Expand all | Collapse all

Job name variable in email

  • 1.  Job name variable in email

    Posted Aug 11, 2014 12:38 PM

    We're generating an email in the post process step upon a jobs failure via the statement below.  Can anyone tell me what is needed to insert the failing jobs name in this email.?   <Failed_Job_Name>  


    :SET &out# = SEND_MAIL(&EMAIL#,,'Failure: &environment# &<Failed_Job_Name>#', 'There was an error deleting the &REGION#  iNVENTORY_CASH_ACTIVITY file.')

    Any help is appreciated as I'm just starting out supporting UC4.


    Thanks,


    Tim




  • 2.  Job name variable in email

    Posted Aug 11, 2014 01:01 PM

     

    I use: &$ALIAS#

    If the object has been assigned an alias name, then you will be given the alias name.  Otherwise it will give you the objects name.



  • 3.  Job name variable in email

    Posted Aug 11, 2014 01:06 PM

    What Version and Product (OM or AM) are you using?  

    When you say "failing jobs name" do you mean the Job object name?   If they are, for your purposes, the same you could use something like the following under OM V8 .

    :SET &job_name = SYS_ACT_ME_NAME()



  • 4.  RE: Job name variable in email

    Posted Oct 12, 2020 10:06 AM
    Hello Expert , 

    We have similar kind of requirement whenever job failed in failure notification SAP Job name (name is displaying in SM37) should appear instead of WLA JOBS object name.  

    Our WLA JOBS object name is : JOBS.SAP_ABAP_TIME_CHECK but in SAP job name field we have mentioned job name as a "test ". 


    Once job will fail notification we will trigger with subject name WLA JOBS object "JOB failed :'JOBS.SAP_ABAP_TIME_CHECK"  

     
    Now I am not sure what WLA variable we have to mentioned in notification object process tab to display SAP job name (SM37 name )  in subject line. 


    Note : We are using SLO object to monitor failed job so WLA variable should be required to update in notification object. 
    And  @Pete Wirfs do we have any other option instead of updating alias name in JOBS object as since beginning we have configured all the jobs without using alias field.  

    Regards,
    Viral  




  • 5.  RE: Job name variable in email
    Best Answer

    Posted Oct 12, 2020 10:54 AM
    Hi @viral pabari,

    Try this:

    :pset &JobName# = get_att(JOB_NAME)

    or (from):
    https://docs.automic.com/documentation/webhelp/english/ALL/components/DOCU/12.3/Automic%20Automation%20Guides/help.htm#AWA/Variables/Variables_ObjectAttributes.htm?Highlight=JOB_NAME

    Name: Job name
    Variable name: &$JOB_NAME#
    Description: The name that is used to execute the job in the destination system
    Attribute: JOB_NAME, JN
    Object type: JOBS (BS2000, OS400, SAP, VMS, ZOS)
    Security level: 2



    Cheers
    Christoph ​

    ------------------------------
    ----------------------------------------------------------------
    Automic AE Consultant and Trainer since 2000
    ----------------------------------------------------------------
    ------------------------------



  • 6.  RE: Job name variable in email

    Posted Oct 22, 2020 07:29 AM
    Hello Christoph , 

    We tried to use JOB_NAME variable but getting an error its not allowed to use in object type "call"  

    ERROR


    Could you please let us know what is wrong here. 

    Apologies for multiple screenshot .Due to restriction unable to copy paste content from Citirx.


  • 7.  RE: Job name variable in email

    Posted Oct 22, 2020 11:29 AM
    Edited by Pete Wirfs Oct 22, 2020 11:30 AM
    I think you are mis-using the GET_ATT() function.  You need to code it exactly the way Christoph did.

    https://docs.automic.com/documentation/webhelp/english/ALL/components/DOCU/12.3/Automic%20Automation%20Guides/help.htm#Script/Reference/GET_ATT.htm

    ------------------------------
    Pete Wirfs
    SAIF Corporation
    Salem Oregon USA
    ------------------------------



  • 8.  RE: Job name variable in email

    Posted Oct 22, 2020 01:45 PM
    Hello Pete , 

    Thanks for an update but error is not to pointing GET_ATT() function .Because I tried to use same code provided by Christoph however ended with same error.

    Error

    Attribute JOB_NAME is not allowed for object type "CALL"


    Regards,
    Viral 



  • 9.  RE: Job name variable in email

    Posted Oct 23, 2020 01:22 PM

    Hello

    Not sure how read function work so i don't know how to get you JOBS's JOB_NAME from your CALL object whithout getting it beforehand in the JOBS's post-process

    but if you use Christoph's suggestion

    :pset &SAP_JobName# = get_att(JOB_NAME)

    or

    :pset &SAP_JobName# = &$JOB_NAME#

    in your JOBS post-process and use the inherited variable &SAP_JobName# in your CALL object, it should work.

    I'm new here so i hope i'm not mistaken. 

    Regards,

    Stéphane




  • 10.  RE: Job name variable in email

    Posted Oct 26, 2020 09:42 AM
    Hello Stephane , 

    I have placed :pset &SAP_JobName# = &$JOB_NAME#   in JOB object's post-process step but I am not sure how can I pass variable value &SAP_JobName# in CALL object. 


    I tried to print value of variable &SAP_JobName# in CALL object but got an error 






  • 11.  RE: Job name variable in email

    Posted Oct 26, 2020 10:47 AM

    Hello

    Contrary to SET command, PSET is here to define the variable for the entire process (so, normally it's inherited by the objects starded either in post process or in an action "Return code handling" in the general tab) 

    How do you start your CALL object?

    1. action "Return code handling"?

    2. started in post-process?
    3. Other mean?
    Personnaly i tried both 1 and 2 and it worked
    Here is my CALL
    the following screenshot is the CALL's report after starting the JOBS
    Regards

    Stéphane



  • 12.  RE: Job name variable in email

    Posted Oct 28, 2020 10:42 AM
    Hello Stéphane ,

    Thank you for taking time and checking in your system. 

    Your suggestion is working fine. I think this will helpful when we limited number of jobs.  

    But as I have mentioned in beginning we are using SLO object to monitor the jobs and we have thousand of jobs.

    Whenever job will get failed SLO object will trigger notification so we don't have to write any code in JOB object. 

    Generic notification object has all coding. 

    As you can see in line no 22, I want to add there SAP job name using &SAP_JOBname# variable (which I have passed in job object ) in subject line but its not working. 
    Notification object will only understand variable passed by SLO object so I am still struggling on how to pass here JOB_NAME attribute.  
    ​​
    Appreciate any lead to resolve this. 

    Regards,
    Viral 



  • 13.  RE: Job name variable in email

    Posted Oct 28, 2020 12:16 PM

    Well sorry, I never used SLO

    I have another suggestion but it's not very...elegant

    use a SQL request with a SQLI (or SEC_SQLI) object, the SAP Job Name is in JBA table -> JBA_REST but in a string whith other parameters

    JBA_REST result should be the following string :

    8='01'C='C'E='1'A=''9='TEST'B=''I='0'e='0'u=''v=''w='0'x='0'y='0'z='0'X='0'Y=''Z=''1='0'L='0'

    Here is the request (use it in a SQLI or a SEC_SQLI, depending on your security parameters) 

    SELECT OH_NAME, JBA_REST
    FROM JBA, OH
    WHERE JBA_OH_IDNR = OH_IDNR
    AND OH_NAME = &uc_slm_service_name#
    AND OH_Client = &$CLIENT#
    AND OH_DeleteFlag = 0


    And the code to get the result (split with quote separators)

    : SET &HND0# = PREP_PROCESS_VAR(VARA.SQLI_SAPJOBNAME)
    : PROCESS &HND0#
    :    SET &CONTENT# = GET_PROCESS_LINE(&HND0#,3)
    :    DEFINE &STRING1#, string, 15
    :    FILL &STRING1#[] = STR_SPLIT(&CONTENT#, "'")
    :    SET &SAP_JobName# = &STRING1#[10]
    : ENDPROCESS &HND0#
    : CLOSE_PROCESS &HND0#

    not really clean but that's all i can think of.

    If this doesn't work, i'm really out of ideas, sorry




  • 14.  RE: Job name variable in email

    Posted Nov 10, 2020 03:29 AM
    Hello Stephane , 

    We found another workaround , fortunately we used to keep WLA JOB object name "SAP_JOB#S4.Test"  here "test" name will appear in SAP SM37. 

    So we tried to search string with below logic 

    :set &Job_name# = &uc_slm_service_name#
    :SET &SEARCH#="."
    :SET &POS#=STR_FIND_REVERSE(&Job_name#,&SEARCH#)
    :PRINT &POS#
    :set &pos1# = add(&POS#,1)
    :print &pos1#
    :set &pos2# =substr(&Job_name#,&pos1#)
    :print &pos2#

    : put_att SUBJECT = "Job Failed '&pos2#' 

    I know this will not help everyone however it's to good to share. 

    Thank you so much for your guidance.  

    Regards,
    Viral