Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Condition Based to Skip Remaining Steps in a Background Job

suwandi_cahyadi
Contributor
0 Kudos

Hi,

Is there a correct way to skip remaining background job if a condition is met?

For example: I have a background job with 2 steps, the first step will check a condition, if it is met, it will not run the remaining steps. I found in note 545241, with statement LEAVE TO TRANSACTION SY-TCODE the job will finish and not execute the remaining steps. Another way is to issue 'E' or 'A' but background job status will be as 'Cancelled'.

Thank you,

4 REPLIES 4

jakob_steen-petersen
Active Participant

Hi

I don´t think so. But a workaround could be to use Events to start the jobs.

So: job1 starts af certain program. job2 starts on Event "eventxxx".

In program of job1 you of course needs to program the condition in order to raise the event.

Bu haven´t heard of any "generic" conditions in order to finish a job (besides E and A message)

Sandra_Rossi
Active Contributor
0 Kudos

You gave two possible solutions which have different effects as you have explained. What is your requirement? That the job terminates with status "finished" or that the job terminates with status "aborted". Can you tell us why none of them satisfy you?

suwandi_cahyadi
Contributor
0 Kudos

Hi,

Actually I am ok with the result of LEAVE TO TRANSACTION SY-TCODE, but as in note 545241, seems this is like something need to be avoided. Not sure if there might be some unwanted effect if we use this method or might be it does not work sometime, etc. Therefore, I would like to search first for a more proper solution if available.

Thank you.

Sandra_Rossi
Active Contributor
0 Kudos

I see. I guess SAP see the steps of a job as to be isolated from each other. In that case, the only solution left is to dispatch the steps on two jobs, and the first job decides to start the second job or not, as explained by Jakob.