‎2010 Nov 01 2:11 PM
Hi guys,
I have a user exit where I need to launch a program, to make a kind of SUBMIT to a Zprogram, but I just want to launch the Zprogram and not wait for it to finish. I mean, if the Zprogram takes, let's say, an hour, I don't want to wait for an hour in my user exit, I just want to schedule the execution and go on with the rest of the process in the user exit.
Can you get what I mean?
Thanks in advance!
Kind regards,
Matias.
‎2010 Nov 01 2:37 PM
Hi,
Then in this case you schedule the Program as a background right..
DATA: l_valid,
ls_params LIKE pri_params,
lv_jobname LIKE tbtcjob-jobname,
lv_jobcount LIKE tbtcjob-jobcount.
*--Get Print Parameters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
no_dialog = 'X'
IMPORTING
valid = l_valid
out_parameters = ls_params.
CLEAR : ls_params-primm, ls_params-prrel.
lv_jobname = 'ZJOBNAME'.
*--Create the Background Job
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = lv_jobname
IMPORTING
jobcount = lv_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
*--Submit the Program as the Background step for the above job
SUBMIT (Program Name)
WITH p_ufile = v_ufile
WITH SELECTION-TABLE it_selopt
VIA JOB lv_jobname
NUMBER lv_jobcount
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS ls_params
AND RETURN.
*--Schedule and close job.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_jobcount
jobname = lv_jobname
strtimmed = 'X'
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.
This will schedule the program as a background job which will not stop the execution of the transaction. Let me know if any.
Regards,
Srinivas
‎2010 Nov 01 2:44 PM
Hi Hari,
is it necessary to use the spool parameters?
Or do I get the same effect with:
JOB_OPEN
SUBMIT zprogram
VIA JOB 1111111
AND RETURN.
JOB_CLOSE
I don't understand why i'd need the spool stuff.
Thakns,
Matias.
‎2010 Nov 01 3:08 PM
Hello,
If you're not interested in the spool output of the scheduled program you don't need the SPOOL PARAMETERS. Read the F1 documentation for further details.
BR,
Suhas
‎2010 Nov 01 4:28 PM
Hi,
If you don't want to pass the SPOOL PARAMETERS, Comment the SPOOL keywords it will work.
SUBMIT (PROGRAM NAME)
WITH p_ufile = v_ufile
WITH SELECTION-TABLE it_selopt
VIA JOB lv_jobname
NUMBER lv_jobcount
* TO SAP-SPOOL WITHOUT SPOOL DYNPRO
* SPOOL PARAMETERS ls_params
AND RETURN.
Use the above statment it will work. Let know if any.
Regards,
Srinivas