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: 

Is it possible to skip a job step?

malcolm_conchie
Explorer
0 Kudos

I need to be able Finish a job without running the remaining steps if certain circumstances are met. I want to put an ABAP it Step 1 that does the checks. If the checks are true then I don't want the rest of the job's steps to run.

I can get the job to Cancel preventing the other steps from running but I want to job to show up in SM37 as FInished not Cancelled.

Is there any way of getting Step 1 to Finish the job ignoring the other steps?

Thanks,

Malc

1 ACCEPTED SOLUTION

Former Member
0 Kudos

I don't know of an easy way to do this. (It was actually very easy to do in the old IBM mainframe days. Jobs were put together using JCL and the JCL could determine the condition code of previous step(s) and control program flow using these condition codes.)

But that doesn't help now.

You could control job step flow if you did some additional programming. Each job step could export a parameter and subsequent steps could import the parameters and decide whether to run or not.

Rob

15 REPLIES 15

Former Member
0 Kudos

Hi

I think u should raise an error message in order to abort the job or u split your job in two jobs: the second starts only if a certain status (for example an event) is set.

Max

0 Kudos

Hi Max,

Can you please brief me on how to raise an error message in order to abort the job.

Do we have to use FM BP_JOB_ABORT to abort the job.

If so then how to get the jobcount of the current running job which has to be passed as the parameter to the FM?

Thanks in Advance,

Rushmi.

0 Kudos

You can abort a job via MESSAGE in the ABAP of one of the Steps, eg

MESSAGE E999(ZZ) WITH 'Job Aborted due to .....'(E01).

or

MESSAGE 'Job Aborted due to .....' type 'A'.

Former Member
0 Kudos

Hi Malc,

Have you got solution to your following query? If yes could you please give me the steps to follow to achieve this? I am facing the same problem and waiting for some helping hand...

I need to be able Finish a job without running the remaining steps if certain circumstances are met. I want to put an ABAP it Step 1 that does the checks. If the checks are true then I don't want the rest of the job's steps to run.

I can get the job to Cancel preventing the other steps from running but I want to job to show up in SM37 as FInished not Cancelled.

Is there any way of getting Step 1 to Finish the job ignoring the other steps?

Thanks,

Deepu

Edited by: Deepu Nair on Jun 1, 2009 3:47 PM

Edited by: Deepu Nair on Jun 1, 2009 3:48 PM

0 Kudos

Hi Deepu,

I've not yet found a solution what does not invlove creating additional check jobs.

Thanks,

Malc

0 Kudos

Hi

You can use the below code as per your requirements. Here first call to function module JOB_SUBMIT

created first job step and second call to JOB_SUBMIT creates second job step.

Say, if you want to skip second step then you can put that in IF ELSE condition.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = wf_jobname

IMPORTING

jobcount = wf_jobcount

EXCEPTIONS

OTHERS = 99.

wf_reportname = wl_progname.

wf_username = sy-uname.

CALL FUNCTION 'JOB_SUBMIT'

EXPORTING

authcknam = wf_username

jobcount = wf_jobcount

jobname = wf_jobname

report = wf_reportname

variant = variant1

EXCEPTIONS

OTHERS = 99.

wf_reportname2 = wl_progname2.

CALL FUNCTION 'JOB_SUBMIT'

EXPORTING

authcknam = wf_username

jobcount = wf_jobcount

jobname = wf_jobname

report = wf_reportname2

variant = variant2

EXCEPTIONS

OTHERS = 99.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobname = wf_jobname

jobcount = wf_jobcount

strtimmed = 'X'

EXCEPTIONS

cant_start_immediate = 1

invalid_startdate = 2

jobname_missing = 3

job_close_failed = 4

job_nosteps = 5

job_notex = 6

lock_failed = 7

invalid_target = 8.

IF sy-subrc NE 0.

MESSAGE i004(zbhi) WITH 'Job failed'.

ENDIF.

raymond_giuseppi
Active Contributor
0 Kudos

Create two jobs

- The first job do the checks and, if ok, raise an event [BP_RAISE_EVENT|https://www.sdn.sap.com/irj/scn/advancedsearch?query=bp_raise_event&cat=sdn_all]

- The second job is scheduled after event

Regards,

Raymond

Former Member
0 Kudos

HI,

you can crate two job, one for your program and when it called after that the next job will run in sm37.

Try this one.

Regards

Sathish

Former Member
0 Kudos

I don't know of an easy way to do this. (It was actually very easy to do in the old IBM mainframe days. Jobs were put together using JCL and the JCL could determine the condition code of previous step(s) and control program flow using these condition codes.)

But that doesn't help now.

You could control job step flow if you did some additional programming. Each job step could export a parameter and subsequent steps could import the parameters and decide whether to run or not.

Rob

0 Kudos

Nitin, et al, I need to avoid creating additional jobs.

Rob Burbank, I have SAP standard code in some of my job steps so can't get them to check if they should run.

Does anyone know if it's possible to increase the Job's step counter? For example if there's 3 steps in the job can step 1 set the step counter to 4 so steps 2 and 3 do not run and job Finishes?

Malc

0 Kudos

I found the answer for my needs.  I changed the code

From this

IF stop_job = 'X'.

   MESSAGE 'Job stopped with Abort' TYPE 'A'.

ENDIF.

To this

IF stop_job = 'X'.

   MESSAGE 'Job stopped with Finish' TYPE 'I'.

   LEAVE TO TRANSACTION SY-TCODE.

ENDIF.

With the second sample code the job ends with status Finish and does not run any further job steps.

0 Kudos

Wow! Perseverance!

0 Kudos

Agreed ,

Update after 4 years on this thread really supports your point

malcolm_conchie
Explorer
0 Kudos

I'd been struggling with this for a while

I recently found OSS 545241 which reports ABAPs calling LEAVE TO TRANSACTION SY-TCODE in jobs not running further steps.  The "issue" was what I needed to force jobs to finish and ignore the later steps.

Malc

0 Kudos

Hello Malc ,

Glad to know that you found a solution at last