‎2006 Dec 21 11:01 AM
Hi every body,
I have two steps in my background job. Now I want that if the first step executes successfully then only my second step should start, other wise not.
Can that be possible? if so please let me know how.
thanks in advance,
regards,
mounika.
‎2006 Dec 21 11:05 AM
go to sm37 and there u will find a option - Extended job selection,click on tht..
there u have options like Start Condition,steps n all..
i think there u can set the condition to check the if first step finished successfully or not..
amit
‎2006 Dec 21 11:08 AM
Hi Mounika,
When you Define the background job in SM36, there is a button called "Start Condition". If you click that, then you get a pop up. You can click on the AFTER JOB button.
Give the name of the predecessor job.
and save.
regards,
ravi
‎2006 Dec 21 11:10 AM
Hi ravi,
thanks for your reply but what u r saying is for job to job(i.e, if other job completes then start this job) but i want step to step with in a job(i.e if one step completes then start next step and both steps are from same job).
mounika.
‎2006 Dec 21 11:08 AM
Can this achieved with sm36 & sm37? if so please let me know the procedure?
thanks,
mounika.
‎2006 Dec 21 11:09 AM
yep it is possible ..pls go ahead
and then reward points to us..:-)
‎2006 Dec 21 11:22 AM
u can create 2 jobs having one step each instead of having 2 steps in one job..
‎2006 Dec 21 11:08 AM
Hello Mounika,
yes this possible. If u are scheduling the job through SM36 u can set this up in START condition as After JOB. Enter ur previous job number and this new job will execute only when the previous job finishes.
If u r using ABAP program for this u can have alook at the following code..
Sample Program: Wait for Predecessor Job with JOB_CLOSE
Start at successful completion of predecessor job. In this
example, the user selects the predecessor job from a list of
jobs. The jobs are selected with BP_JOB_SELECT and displayed
for selection to the user with BP_JOBLIST_PROCESSOR.
*
Important: If you specify a predecessor job directly in your
program (not interactively chosen), then be sure that the
predecessor job has the status Scheduled or Released when
you schedule the successor job. Otherwise, the successor
scheduling will fail. That is, a job that is active or
already completed cannot be specified as a predecessor job.
*
Data declarations: BP_JOB_SELECT and BP_JOBLIST_PROCESSOR
DATA JSELECT LIKE BTCSELECT.
DATA SEL_JOBLIST LIKE TBTCJOB OCCURS 100 WITH HEADER LINE.
DATA SELECTED_JOB LIKE TBTCJOB.
Generate list of jobs as with the background processing
management transaction (SM37).
Sample selection criteria
JSELECT-JOBNAME = 'NAME OF JOB'.
JSELECT-JOBCOUNT = '<Job count>'.
JSELECT-USERNAME = SY-UNAME.
CALL FUNCTION 'BP_JOB_SELECT'
EXPORTING
JOBSELECT_DIALOG = BTC_YES " Display list to user
JOBSEL_PARAM_IN = JSELECT " default job selection
" criteria
IMPORTING
JOBSEL_PARAM_OUT = JSELECT " Users job selection
" criteria
TABLES
JOBSELECT_JOBLIST = SEL_JOBLIST
EXCEPTIONS
INVALID_DIALOG_TYPE = 1
JOBNAME_MISSING = 2
NO_JOBS_FOUND = 3
SELECTION_CANCELED = 4
USERNAME_MISSING = 5
OTHERS = 99.
*
Ask the user to pick a job from the list. The selected job is
the predecessor job.
call function 'BP_JOBLIST_PROCESSOR'
exporting
joblist_opcode = btc_joblist_select
" Starts processor in mode which
" allows user to pick a job from
" list. Selected job is returned
" in the joblist_sel_job parameter.
joblist_refr_param = jselect
" User's job selection parameters
" for Refresh function
importing
joblist_sel_job = selected_job
" Returns the job selected from the
" job list by the user.
tables
joblist = sel_joblist
" Input from BP_JOBLIST_SELECT
exceptions
invalid_opcode = 1
joblist_is_empty = 2
joblist_processor_canceled = 3
others = 4.
Schedule job using the predecessor picked by the user.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = SELECTED_JOB-JOBCOUNT
" Job ID from BP_JOBLIST_PROCESSOR
JOBNAME = SELECTED_JOB-JOBNAME
" Job ID from BP_JOBLIST_PROCESSOR
PREDJOB_CHECKSTAT = 'X' " Start job only if
" predecessor job was
" successfully completed.
PRED_JOBCOUNT = SEL_JOBLIST-JOBCOUNT
" ID of predecessor job,
" from BP_JOB_SELECT.
PRED_JOBNAME = SEL_JOBLIST-JOBNAME
IMPORTING
JOB_WAS_RELEASED = JOB_RELEASED
" Check: was job released?
EXCEPTIONS
CANT_START_IMMEDIATE = 1
INVALID_STARTDATE = 2
JOBNAME_MISSING = 3
JOB_CLOSE_FAILED = 4
JOB_NOSTEPS = 5
JOB_NOTEX = 6
LOCK_FAILED = 7
OTHERS = 99.
‎2006 Dec 21 11:13 AM
IN <b>SM36</b> when you Define the background job, there is a button called "Start Condition". Click on this & you will get a pop up. Then click on the AFTER JOB button.
& specify the name of the predecessor job and save.
‎2006 Dec 21 11:19 AM
I think u will find soem useful stuff in the SAP help in section Basis programming interface.
‎2007 Nov 13 4:17 AM
Hi,
I'm trying to schedule a successor jobs. I have created JOB1 and then JOB2, in JOB2 I have set the "After job" condition i.e. after JOB1 is completed JOB2 should run. and also I have scheduled the JOB1 as hourly. but only the first time both the jobs are completing successfully..after 1 hr only the first job is completing but not the successor job and it is not at all showing the JOB2 as successor job for JOB1.
Can you help me out in this.