04-29-2020 10:54 AM
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,
04-29-2020 11:06 AM
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)
04-29-2020 12:50 PM
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?
04-30-2020 2:27 AM
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.
04-30-2020 4:40 AM
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.