2009 Feb 19 8:08 AM
Hi experts,
i have an issue regarding background job.i have to run multple programs in background one after another in one program.so i am using function modules job_open,submit and job_close.
my problem all the jobs are statrting at same time .but i want to run after completion of first job second job should start.
please guide me
Thanks
sai
Edited by: Julius Bussche on Feb 19, 2009 9:36 AM
Please use meaningfull subject titles
2009 Feb 19 9:09 AM
Hi thomas,
thanks for ur reply.but i already did as u sais.u can check my code.but still i am getting error as invalid ob start.
first job is execution successfully.but when cursor comes to second job_close function it was giving dump error.
Thanks
sai
Hi experts,
i have an issue regarding background job.i have to run multple programs in background one after another in one program.so i am using function modules job_open,submit and job_close.
my problem all the jobs are statrting at same time .but i want to run after completion of first job second job should start.
please guide me
Thanks
sai
Edited by: Julius Bussche on Feb 19, 2009 9:36 AM
Please use meaningfull subject titles
2009 Feb 19 8:17 AM
hi....
this link will help you definatly ....
i have checked in
http://help.sap.com/saphelp_46c/helpdata/en/fa/096ce5543b11d1898e0000e8322d00/frameset.htm
regards
2009 Feb 19 8:33 AM
You can schedule the jobs in a chain through sm37 where jobs will be run one after the other only on successful completion.
2009 Feb 19 8:34 AM
Easiest way is to create only one job with multiple steps : JOB_OPEN, SUBMIT, SUBMIT, .... JOB_CLOSE, then each report will execute after the previous one, any error/abend message will break the job.
Else you may condition each job to start with the end of the previous one. (fill parameter PRED_JOBCOUNT in JOB_CLOSE with the JOBCOUNT returned by the JOB_OPEN of the previous submitted Job)
For more complex requirement or information look at [Programming with the Background Processing System (BC-CCM-BTC)|http://help.sap.com/erp2005_ehp_04/helpdata/EN/fa/096c53543b11d1898e0000e8322d00/frameset.htm]
Regards
2009 Feb 19 8:45 AM
Hi raymond,
i have done as u said .i have passed parameters like previous jobname,jobcount to job_close function module.but it was giving dump saying that invalid job start.
please guide me.
Thanks
sai
2009 Feb 19 8:59 AM
You have to schedule the first job some seconds in future as it must not be active when scheduling the following jobs. job must be in a status scheduled or released. Look at [Sample Program: Start-Time Window with JOB_CLOSE|http://help.sap.com/saphelp_40b/helpdata/EN/fa/096d8e543b11d1898e0000e8322d00/content.htm] (check parameters used)
Also in [Sample Program: Wait for Predecessor Job with JOB_CLOSE|http://help.sap.com/saphelp_40b/helpdata/EN/fa/096db5543b11d1898e0000e8322d00/content.htm] look for a job predecessor scheduling. (check parameters used)
Regards
2009 Feb 19 8:53 AM
have a look
http://help.sap.com/saphelp_46c/helpdata/en/fa/096ce5543b11d1898e0000e8322d00/frameset.htm
Regards
Shashi
2009 Feb 19 9:00 AM
hi,
as per the procedure i have done evry thing still i am getting runtime error.
LOOP AT IT_FILENAMES INTO TS_FILENAMES.
IF SY-TABIX = 1.
JOBNAME = TS_FILENAMES-ZZFNAME.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = JOBNAME
IMPORTING
JOBCOUNT = JOBCOUNT.
SUBMIT program WITH P_FILE1 = TS_FILENAMES-ZZFNAME VIA JOB JOBNAME NUMBER JOBCOUNT AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = JOBCOUNT
JOBNAME = JOBNAME
STRTIMMED = 'X'.
ELSE.
JOBNAME2 = TS_FILENAMES-ZZFNAME.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = JOBNAME2
IMPORTING
JOBCOUNT = JOBCOUNT2.
SUBMIT program WITH P_FILE1 = TS_FILENAMES-ZZFNAME VIA JOB JOBNAME2 NUMBER JOBCOUNT2 AND RETURN.
.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = JOBCOUNT2
JOBNAME = JOBNAME2
PREDJOB_CHECKSTAT = 'X'
PRED_JOBCOUNT = JOBCOUNT
PRED_JOBNAME = JOBNAME.
JOBCOUNT = JOBCOUNT2.
JOBNAME = JOBNAME2.
ENDIF.
ENDLOOP.
2009 Feb 19 9:28 AM
Try something like
LOOP AT it_filenames INTO ts_filenames.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = jobname
IMPORTING
jobcount = jobcount.
SUBMIT program
WITH p_file1 = ts_filenames-zzfname
VIA JOB jobname NUMBER jobcount
AND RETURN.
IF sy-tabix EQ 1.
CLEAR: pred_jobcount,
pred_jobname.
GET TIME.
IF sy-uzeit LT '235950'.
sdlsstrttm = sy-uzeit + 10.
sdlstrtdt = sy-datum.
ELSE.
sdlsstrttm = '000010'.
sdlstrtdt = sy-datum + 1.
ENDIF.
ELSE.
sdlsstrttm = ' '. " no_time from LBTCHTOP
sdlstrtdt = ' '. " no_date from LBTCHTOP
ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = jobcount
jobname = jobname
predjob_checkstat = ' '
pred_jobcount = pred_jobcount
pred_jobname = pred_jobname
sdlstrtdt = sdlstrtdt
sdlstrttm = sdlstrttm
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 = 8.
pred_jobcount = jobcount.
pred_jobname = jobname.
ENDLOOP.I removed the checkstat, cause if you want to check the status you only have to submit one job with multiple steps. (Put JOB_OPEN and JOB_CLOSE out of the loop)
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = jobname
IMPORTING
jobcount = jobcount.
LOOP AT it_filenames INTO ts_filenames.
SUBMIT program
WITH p_file1 = ts_filenames-zzfname
VIA JOB jobname NUMBER jobcount
AND RETURN.
ENDLOOP.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = jobcount
jobname = jobname
strtimmed = 'X'.Regards
2009 Feb 19 9:03 AM
2009 Feb 19 9:09 AM
Hi thomas,
thanks for ur reply.but i already did as u sais.u can check my code.but still i am getting error as invalid ob start.
first job is execution successfully.but when cursor comes to second job_close function it was giving dump error.
Thanks
sai
2009 Feb 19 9:13 AM
You should call JOB_CLOSE for the first job after calling JOB_CLOSE for the second job, otherwise the first job is already active when you try to set it as predecessor -> error.
Thomas
2009 Feb 19 10:45 AM
thanks u thomas.
my problem was solved with ur solution.
thanks u.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |