Skip to Content
-1

Trigger my job when a job got cancelled

Jan 22 at 07:41 AM

166

avatar image

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.

10 |10000 characters needed characters left characters exceeded

Why do you need this?

0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Domi Bigl Jan 22 at 08:17 AM
0

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

Show 3 Share
10 |10000 characters needed characters left characters exceeded

hi Dominik bigl,

According to your saying => for 15 jobs i need to create another 15 jobs to check the status of job of each program.

i mean 1 have 1st job runs at 6 PM ( may be finished successfully - this time that job should not trigger ).

2nd job runs at 7 PM ( may be finished successfully - this time that job should not trigger ).

3rd job runs at 8 PM ( may be finished unsuccessfully - this time that job should trigger ).

if i use SAP_END_OF_JOB then for 15 jobs i need to create another 15 jobs but my aim is to complete by 16 jobs ( i.e., 15 jobs + 1 extra job (that which need to be called if one of the 15 job got cancelled ) ).

Regards,

kiran rachamalla.

0

Hi

you don't have to create new jobs - just add the new check report as 2nd step in the actual jobs.

I also would create a custom batch event - SAP_END_OF_JOB may be triggered by many other standard function...

regards

Domi

0

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.

0
Sandra Rossi Jan 22 at 08:14 AM
0

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.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

hi Sandra Rossi,

If i Use SAP_END_OF_JOB this event then for 15 jobs i need to create another 15 jobs to check the status of job of each program.

i mean 1 have 1st job runs at 6 PM ( may be finished successfully - this time that job should not trigger ).

2nd job runs at 7 PM ( may be finished successfully - this time that job should not trigger ).

3rd job runs at 8 PM ( may be finished unsuccessfully - this time that job should trigger ).

if i use SAP_END_OF_JOB then for 15 jobs i need to create another 15 jobs but my aim is to complete by 16 jobs ( i.e., 15 jobs + 1 extra job (that which need to be called if one of the 15 job got cancelled ) ).

Regards,

kiran rachamalla.

0
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.

0
Vinita Kasliwal Jan 23 at 01:55 AM
0

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!

Show 2 Share
10 |10000 characters needed characters left characters exceeded

hi Vinita,

but my aim is to trigger it automatically ( i mean the job ) of course in the triggered job i will check which job got dump etc details. my main moto is not to check which job got cancelled , but how to trigger the specified job if any one of the 15 jobs got cancelled.( if all 15 jobs were sucess that job should not be called at all ).

Regards,

kiran rachamalla.

0

Hi kiran

Refer this link there is an option in SM36 when you click on start conditon there you need to choose 'After Job' option

and the correct way to do is mentioned in the link below :

let me know if that is what you are looking for ?

http://www.sapyard.com/how-to-schedule-dependent-batch-job-in-sequence-in-sm36/

regards

vinita

0