2008 Apr 23 7:56 PM
Hi,
I am using JOB_OPEN , SUBMIT and JOB_CLOSE for program to create a spool.
My problem is after the JOB_CLOSE i am calling another report to send output of first report from the spool.
My problem is after submitting the program report1 system calls the job_close and tried to send report1 output as mail. But still the submit report1 is still running .
My question how to use submit statement wait for submit report1 is finished and then only call JOB_CLOSE.
call function 'JOB_OPEN'
exporting
jobname = v_jobname
importing
jobcount = v_jobcount
exceptions
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03
others = 99.
submit report1
via job v_jobname
number v_jobcount
to sap-spool without spool dynpro
spool parameters wa_params
and return.
call function 'JOB_CLOSE'
exporting
jobcount = v_jobcount
jobname = v_jobname
strtimmed = 'X'
importing
job_was_released = v_job_released
exceptions
invalid_startdate = 01
jobname_missing = 02
job_close_failed = 03
job_nosteps = 04
job_notex = 05
lock_failed = 06
others = 99.
submit report2 with spool = v_spool. " For mailing
Sa_R
2008 Apr 23 8:05 PM
One option would be to add job steps using the FM JOB_SUBMIT. This way you can say that the next step in the job should wait for the previous to end before continuing.
One option would be to add job steps using the FM JOB_SUBMIT. This way you can say that the next step in the job should wait for the previous to end before continuing.
2008 Apr 23 8:05 PM
One option would be to add job steps using the FM JOB_SUBMIT. This way you can say that the next step in the job should wait for the previous to end before continuing.
2008 Apr 23 8:06 PM
After submit can u try
WAIT UP TO 2 SECONDS.and see what happens.
2008 Apr 23 8:25 PM
nobody knows how long a certain report will last, so wait up to X seconds can work one day and give problems the other day.
Than it would be better to use FM SHOW_JOBSTATE and see if report is finished. But you have to do this a DO - ENDDO / WHILE - ENDWHILE.
2008 Apr 23 9:06 PM
Thanks Mike.
Your solution work well
call function 'JOB_OPEN'
exporting
jobname = v_jobname
importing
jobcount = v_jobcount
exceptions
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03
others = 99.
submit ygenr001
via job v_jobname
number v_jobcount
to sap-spool without spool dynpro
spool parameters wa_params
and return.
" Simply call the JOB_SUBMIT with extpgm_wait_for_termination = 'X'
" that will wait for step to complete.
call function 'JOB_SUBMIT'
exporting
authcknam = sy-uname
extpgm_wait_for_termination = 'X'
jobcount = v_jobcount
jobname = v_jobname
exceptions
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
others = 10.
call function 'JOB_CLOSE'
exporting
jobcount = v_jobcount
jobname = v_jobname
strtimmed = 'X'
importing
job_was_released = v_job_released
exceptions
invalid_startdate = 01
jobname_missing = 02
job_close_failed = 03
job_nosteps = 04
job_notex = 05
lock_failed = 06
others = 99.
perfrom send_mail using v_spool_no.
Sa_R
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |