Skip to Content
-1

Trigger my job when a job got cancelled

Hi all,

I have 15 jobs which run on periodic basis and i have another job ( which i want to be called when any of those job went to cancelled ). can we use some after job or some event to do it.

so my ultimate goal is to trigger the special job when any of them went to cancelled state.

Regards,

kiran rachamalla.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Jan 22 at 08:17 AM

    Hi

    I would create a "check report" to get the actual job state and trigger a corresponding batch Z-event.

    https://wiki.scn.sap.com/wiki/display/ABAP/Scheduling+background+job+by+triggering+an+event

    This reports is the last step in all 15 monitored jobs.

    The special job will start on the triggered event.

    Useful coding objects:

    CL_BATCH_EVENT=>RAISE( ).
    
        CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
          IMPORTING
            jobcount        = gv_jobcount
            jobname         = gv_jobname
          EXCEPTIONS
            OTHERS          = 1.
    
        CALL FUNCTION 'COMMON_LOG_READ_T100'
          EXPORTING
            logname                       = gv_joblog
          TABLES
            logtable                      = gt_joblog
          EXCEPTIONS
            OTHERS                        = 1.
    
    
        CALL FUNCTION 'BP_JOB_READ'
          EXPORTING
            job_read_jobcount     = gv_jobcount
            job_read_jobname      = gv_jobname
            job_read_opcode       = c_all_job_data
          TABLES
            job_read_steplist     = gt_steplist
          EXCEPTIONS
            OTHERS                = 1.
    
    
            CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
              EXPORTING
                rqident              = gv_rqident
              TABLES
                buffer               = gt_buffer
              EXCEPTIONS
    	    OTHERS               = 1.
    
    

    regards

    Domi

    Add comment
    10|10000 characters needed characters exceeded

    • hi Dominik,

      if i place the steps then 2nd step will not call, if first step got dump right ? the whole job will be in cancelled then how my check report ( i.e., 2nd step) will be called.

      Regards,

      kiran rachamalla.

  • Jan 22 at 08:14 AM

    No. You'll need to do a separate program/job which scans those jobs and do the needful if one failed.

    I don't know how it exactly works and whether it can be used, but for information SAP triggers the event SAP_END_OF_JOB at the end of every job.

    Add comment
    10|10000 characters needed characters exceeded

    • Sandra Rossi kiran rachamalla

      My answer was "No. You'll need to do a separate program/job which scans those jobs and do the needful if one failed." to the question "can we use some after job or some event to do it". To help you create this program, maybe you can use the event SAP_END_OF_JOB. If you don't want to create a program, then ignore my remark and start the job manually if one of the 15 jobs fails.

  • Jan 23 at 01:55 AM

    I thought of an alternative approach

    if this is your custom code then at the end put a check say RUN_NOTSUCCESSFul = X in ABAP table

    And if there is any new entry in that table means the job was failed so the other job should now be run

    I think you can also check in the tables TBTCP and TBTCO which has status of each of the jobs as seen in SM37

    let me know if that helps!

    Add comment
    10|10000 characters needed characters exceeded