2005 Oct 10 4:02 PM
Hello All,
I would like to know if there is a way to schedule jobs dynamically. For example: If the user wants to set up a series of jobs 2days in advance can we do it by creating a selection screen on which user has the ability to enter the date and time when he wants to schedule the jobs and I can trigger an event which is already scheduled with the series of steps to be executed on that date and time instead of going to tcode "SM36".
You help will be appreciated.
Thanks
Pavan
2005 Oct 10 4:09 PM
Pavan,
You can schedule jobs dynamically. Look at the function modules JOB_OPEN, JOB_SUBMIT, JOB_CLOSE.
Regards,
Ravi
Note : If this helps you, please reward points.
Pavan,
You can schedule jobs dynamically. Look at the function modules JOB_OPEN, JOB_SUBMIT, JOB_CLOSE.
Regards,
Ravi
Note : If this helps you, please reward points.
2005 Oct 10 4:08 PM
Hi Pavan;
You can schedule the background jobs to run peridodically after an event, then trigger the event in ABAP using BP_EVENT_RAISE. The events are maintained in transaction SM62.
Cheers,
John
2005 Oct 10 4:09 PM
Pavan,
You can schedule jobs dynamically. Look at the function modules JOB_OPEN, JOB_SUBMIT, JOB_CLOSE.
Regards,
Ravi
Note : If this helps you, please reward points.
2005 Oct 10 4:16 PM
Hello Ravi,
Can you give me an example.
Say I have a series of jobs A,B,C,D and the user inputs a date and time when the these jobs need to run. Based on the user input the jobs should run as
1. A
2. B
3. C
4. D
2005 Oct 10 4:17 PM
Check out this sample program...
report zrich_0002.
data:
l_valid,
ls_params like pri_params,
l_jobcount like tbtcjob-jobcount.
parameters: p_job type tbtcjob-jobname.
parameters: p_prog(30) type c.
parameters: p_sdat like sy-datum.
parameters: p_stim type sy-uzeit.
start-of-selection.
* Get Print Parameters
call function 'GET_PRINT_PARAMETERS'
exporting
no_dialog = 'X'
importing
valid = l_valid
out_parameters = ls_params.
* Open Job
call function 'JOB_OPEN'
exporting
jobname = p_job
importing
jobcount = l_jobcount.
* Submit report to job
submit (p_prog)
via job p_job
number l_jobcount
to sap-spool without spool dynpro
spool parameters ls_params
and return.
* Schedule and close job.
call function 'JOB_CLOSE'
exporting
jobcount = l_jobcount
jobname = p_job
sdlstrtdt = p_sdat
sdlstrttm = p_stim
* strtimmed = 'X'
.
Regards,
RIch Heilman
2005 Oct 10 7:04 PM
Rich,
Thanks for the input but when I created a test program and defiened a job called "ZTEST" with 2 steps and when I execute the program it gives an error -
Exception condition "JOB_NOSTEPS" raised.
Any thoughts?
Pavan
2005 Oct 10 7:07 PM
Please post the code where you added the steps to the job. This error indicates, that no steps were inserted into the job due to an error condition. Either you didn't give the selection screen values/variant for the program in the steps or the job is not created.
Srinivas
2005 Oct 10 7:14 PM
Srinivas,
I used the same code which Rich posted above.
I did create the job with 2 steps in it (2 reports).
Pavan
2005 Oct 10 7:14 PM
Not sure whats going on..... This sample submits one job with 2 steps, and it works great. Of cousr
report zrich_0002.
data:
l_valid,
ls_params like pri_params,
l_jobcount like tbtcjob-jobcount.
parameters: p_job type tbtcjob-jobname.
parameters: p_prog1(30) type c.
parameters: p_prog2(30) type c.
parameters: p_sdat like sy-datum.
parameters: p_stim type sy-uzeit.
start-of-selection.
* Get Print Parameters
call function 'GET_PRINT_PARAMETERS'
exporting
no_dialog = 'X'
importing
valid = l_valid
out_parameters = ls_params.
* Open Job
call function 'JOB_OPEN'
exporting
jobname = p_job
importing
jobcount = l_jobcount.
* Submit report as STEP 1
submit (p_prog1)
via job p_job
number l_jobcount
to sap-spool without spool dynpro
spool parameters ls_params
and return.
* Submit another report as STEP 2
submit (p_prog2)
via job p_job
number l_jobcount
to sap-spool without spool dynpro
spool parameters ls_params
and return.
* Schedule and close job.
call function 'JOB_CLOSE'
exporting
jobcount = l_jobcount
jobname = p_job
sdlstrtdt = p_sdat
sdlstrttm = p_stim
* strtimmed = 'X'
.
Can you please post your test program.
Regards,
Rich Heilman
2005 Oct 10 8:49 PM
Rich,
Thank you very much for the input. I have one more question:
Can I use a variant of p_prog1 during submit of p_prog1?
Pavan
2005 Oct 10 8:58 PM
You need to use the option 'USING SELECTION-SET variant' in your SUBMIT statement.
Srinivas
2005 Oct 10 9:01 PM
2005 Oct 10 9:06 PM
you will want to do something like this.
report zrich_0002.
data:
l_valid,
ls_params like pri_params,
l_jobcount like tbtcjob-jobcount.
parameters: p_job type tbtcjob-jobname.
<b>parameters: p_prog1 type trdir-name.
parameters: p_var1 type varid-variant.
parameters: p_prog2 type trdir-name.</b><b>parameters: p_var2 type varid-variant.</b>
parameters: p_sdat like sy-datum.
parameters: p_stim type sy-uzeit.
<b>at selection-screen on value-request for p_var1.
call function 'RS_PROGRAM_POPUP_VARIANT'
exporting
progname = p_prog1
variant = p_var1
importing
new_variant = p_var1
exceptions
no_variant = 1
others = 2.
at selection-screen on value-request for p_var2.
call function 'RS_PROGRAM_POPUP_VARIANT'
exporting
progname = p_prog2
variant = p_var2
importing
new_variant = p_var2
exceptions
no_variant = 1
others = 2.</b>
start-of-selection.
* Get Print Parameters
call function 'GET_PRINT_PARAMETERS'
exporting
no_dialog = 'X'
importing
valid = l_valid
out_parameters = ls_params.
* Open Job
call function 'JOB_OPEN'
exporting
jobname = p_job
importing
jobcount = l_jobcount.
* Submit report as STEP 1
submit (p_prog1)
via job p_job
number l_jobcount
<b> using selection-set p_var1</b>
to sap-spool without spool dynpro
spool parameters ls_params
and return.
* Submit another report as STEP 2
submit (p_prog2)
via job p_job
number l_jobcount
<b> using selection-set p_var2</b>
to sap-spool without spool dynpro
spool parameters ls_params
and return.
* Schedule and close job.
call function 'JOB_CLOSE'
exporting
jobcount = l_jobcount
jobname = p_job
sdlstrtdt = p_sdat
sdlstrttm = p_stim
* strtimmed = 'X'
.
Regards,
Rich Heilman
2005 Oct 10 9:09 PM
Rich/Srinivas,
Thank you very much for your responses. I have a one more question:
Let us say as of today I have 3 steps (A,B,C) to be executed in a particular job and next year another step needs to be added (due to business process changes) inbetween B and C (A,B,D,C) is there a way we can do this without changing the existing program.
Something like
Define a job with the various steps. Once the user selects the start date and time then the job is executed with the steps created and if there is a new step which needs to be added then just insert a step in the current job.
Please let me know...
Pavan
2005 Oct 10 9:16 PM
Yes, if you were to just running programs, you could use a select-option instead of a parameter on the selection screen. Then all you need to do is update a variant of the driver program to include the new step. Since you are using variants as well, you need to tie the variant to the program being submitted. So in this case, I would suggest maintaining a custom table with ..
Job Name
Step Number
Program Name
Variant
Then you can retrieve these records at run time and loop thru them and build the job. Then all you need to do is add the new step to the custom table. No programming changes.
Please remember to award points for all helpful answers. If you problem is solved, please mark as solved. Thanks.
Regards,
Rich Heilman
2005 Oct 10 9:21 PM
Here is a example which uses a custom table.
report zrich_0002.
data:
l_valid,
ls_params like pri_params,
l_jobcount like tbtcjob-jobcount.
data: icusttable type table of zcusttable with header line.
parameters: p_job type tbtcjob-jobname.
parameters: p_sdat like sy-datum.
parameters: p_stim type sy-uzeit.
start-of-selection.
* Get Print Parameters
call function 'GET_PRINT_PARAMETERS'
exporting
no_dialog = 'X'
importing
valid = l_valid
out_parameters = ls_params.
select * into corresponding fields of table icusttable
from zcusttable
where jobname = p_job.
sort icusttable ascending by jobname stepnumber
* Open Job
call function 'JOB_OPEN'
exporting
jobname = p_job
importing
jobcount = l_jobcount.
* build steps
loop at icusttable.
submit (icusttable-program)
via job p_job
number l_jobcount
using selection-set icusttable-variant
to sap-spool without spool dynpro
spool parameters ls_params
and return.
endloop.
* Schedule and close job.
call function 'JOB_CLOSE'
exporting
jobcount = l_jobcount
jobname = p_job
sdlstrtdt = p_sdat
sdlstrttm = p_stim
* strtimmed = 'X'
.
Regards,
Rich Heilman
2005 Dec 31 8:31 AM
Hi All,
My requirement is to trigger a particular job after a certain event.
For example if an entry is created in table TRFCQIN,
I want a certain job to run after an entry is created in the table TRFCQIN,
TO check the entry in table TRFCQIN everytime ,I do not want to create and shedule another background job.
Is there any other Possible way to do it.
Any help would be highly appreciated.
Regards
Sunil.K.T
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |