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: 

if first job is completed , next job has to run

Former Member
0 Kudos

hi pals,

This is requirement of my client.

if first job is not completed successfully, next job has not to run. we may use

FM .

<b>JOB_CLOSE</b>

<b>import paratmeter : PRED_JOBCOUNT = 'X' .</b>

but it seems ,it is not working.

please suggest me.

Thanks in advance.

T.Balaji.

9 REPLIES 9

Former Member
0 Kudos

Hi Balaji.

The next job which is supposed to run should have the settings in SM36 -> Define job.

i.e. : it should be stated there that this job should run after "JOB1" has finished.

Also check the status-dependent flag.

Now, in code, you have to pass values of PRED_JOBCOUNT, PRED_JOBNAME, and PREDJOB_CHECKSTAT.

Hope it solves.

Regards.

Samant

0 Kudos

Hi samant ,

Thank you for your quick response. infact , earlier itself, we tried with this one ,it is not working .

say some clear suggestion, with some example

<b>Please execute with 2 jobs using function modules</b>

we are not using SM36, SM37. We want to use Function modules.

Thank you lot.

balaji.<u></u>

Former Member
0 Kudos

if you are creating your jobs via SM36, you should be able to to create the second job using 'After Job' option with the 'Start Status Dependent' checkbox switched on. This way the second job will not start unless the first job finishes successfully.

Hope this helps ...

andreas_mann3
Active Contributor
0 Kudos

Hi,

you can check state of your job with table

Andreas

Former Member
0 Kudos

If I understood you correctly, you <b>don't</b> want to run the next job if the previous one failed. If that is the case, why can't you define one job and have multiple steps? The logic is as follows:

Create the job using JOB_OPEN.

Create the steps one after the other using JOB_SUBMIT.

After all the steps are inserted, close the job using JOB_CLOSE.

If this is not an option, and you want to create multiple jobs and want to wait until the first one is successfully completed, then you need to create a wait logic in your program, to wait until the job status of the first job is complete or aborted or cancelled. You can get the status of the job using BP_JOB_CHECKSTATE.

Regards,

Srinivas

0 Kudos

srinivas,

Thank you for your advice .

how much time it will be in the loop with wait statement. suppose ,if it is happens so, system will hang after certain time in back ground(i think so).

please suggest .

Balaji.

0 Kudos

That is the problem you will face if you are creating both the jobs from within the program separately, and you want to wait to start the second job until the first job finishes correctly.

As I mentioned, you can just create one job with multiple steps, then your program need not wait, but the second job step will wait until the first job step is completed successfully.

Srinivas

0 Kudos

You need not code for wait logic in your program. Suppose you have JOB1 & JOB2 . Define JOB1 using the three Function modules JOB_OPEN .. JOB_SUBMIT.. JOB_CLOSE. For JOB2 pass predecessor job as JOB1 in the parameter PRED_JOBNAME and also pass an "X" in the parameter PREDJOB_CHECKSTAT in the function JOB_CLOSE.

Your JOB2 will only start after JOB1 has succesfully completed . The will be taken care by background job processing daemon .

Cheers

Former Member
0 Kudos

Hi Balaji,

you might want to check out the new Job Scheduling capabilities of SAP NetWeaver. You can find more information about this on SAP Service Marketplace under quick-link job-scheduling (http://service.sap.com/job-scheduling).

Kind regards,

Edwin Esser