2012 Dec 20 6:31 AM
Hi all,
I am trying to schedule a background job but i am facing a problem it is getting scheduled instead of Starting Immediately. How to Release it. I have searched the forum but could not get a working solution for my case. I used the following Code.
call function 'JOB_OPEN'
exporting
* DELANFREP = ' '
* JOBGROUP = ' '
jobname = jobname
sdlstrtdt = sy-datum
sdlstrttm = sy-uzeit
jobclass = 'C'
importing
jobcount = jobcount
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'GET_PRINT_PARAMETERS'
EXPORTING
IMMEDIATELY = 'X'
NO_DIALOG = C_TRUE
RELEASE = 'X'
USER = SY-UNAME
IMPORTING
* OUT_ARCHIVE_PARAMETERS =
OUT_PARAMETERS = parameters
VALID = valid
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
submit (program_name) using selection-set variant via job jobname number jobcount to sap-spool without spool dynpro
spool parameters parameters and return.
sdlstrtdt = sy-datum .
sdlstrttm = sy-uzeit.
do.
call function 'JOB_CLOSE'
exporting
jobcount = jobcount
jobname = jobname
sdlstrtdt = sdlstrtdt
sdlstrttm = sdlstrttm
strtimmed = 'X'
importing
job_was_released = released
changing
ret = ret
exceptions
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
invalid_target = 8
others = 9.
if sy-subrc = 0.
exit.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
enddo.
but i am getting exception invalid Start Date on execution of Job_Close FM Since the job did not start and has been Scheduled
2012 Dec 20 6:36 AM
Did you try without passing start_date and start_time to JOB_CLOSE?
2012 Dec 20 6:36 AM
Did you try without passing start_date and start_time to JOB_CLOSE?
2012 Dec 20 6:49 AM
It worked. Thanks a lot. Could you please help me find the spool number generated because Sy-spono is 0 and i used the following code but getting wrong spool number.
f_repid = program_name.
f_uname = sy-uname.
move f_repid+0(12) to lc_rq2name.
condense lc_rq2name.
select * from tsp01
where rq2name = lc_rq2name
and rqowner = sy-uname
order by rqcretime descending.
exit.
endselect.
f_rqident = tsp01-rqident.
2012 Dec 20 6:59 AM
Aren't you getting the spool in the output from FM GET_PRINT_PARAMETERS?
2012 Dec 20 7:04 AM
Once the Job Completed then only you can get the Spool. It will commit in the table TSP01. Till then you need to wait. You can use additional button to show up.. check the below code.
In the GET_PRINT_PARAMETERS Function module
check this Importing Parameter parameter-PLIST
Submit the Job like this
*submit job with all the selection screen params...
SUBMIT (JOB_NAME) USER SYST-UNAME
VIA JOB JOB_NAME NUMBER JOB_NR
WITH CLIENT = CLIENT
WITH MONIFROM = MONIFROM
WITH MONI_TO = MONI_TO
WITH TQ_FROM = TQ_FROM
WITH TQ_TO = TQ_TO
WITH SPOOLNR = SPOOLNR----------> This is of type TSP01-RQIDENT
TO SAP-SPOOL SPOOL PARAMETERS PARAMS
WITHOUT SPOOL DYNPRO
AND RETURN.
Hope this helps
2012 Dec 20 7:06 AM
No I am not and I have used that FM get_print_parameters before the submit statement. Did you mean it gets modified in the Submit statement and if true even that is not happening in my case.
Regards,
Chandni Sharma
2012 Dec 20 7:14 AM
Plist Contains the first 9 characters of the name of the program and the first 3 characters of my User ID.
And what I understood is Submit Statement is scheduling the job and Job_close is releasing it. But until the job is released the spool number will not be generated. I tried doing the same but still getting 0 in the variable Spool_nr.
Thanks & Regards,
Chandni Sharma.
2012 Dec 20 7:15 AM
2012 Dec 20 7:44 AM
Tried the same but it gives me an exception no runtime info. But i could use tbtc_spoolid but the problem is i think i will have to order by Spool Count in descending order and then take the grea
test one assuming this to be the latest one corresponding to the Jobname and Jobcount i have provided.
Thanks & Regards,
Chandni Sharma.
2012 Dec 20 8:50 AM
Tried the same but it gives me an exception no runtime info. But i could use tbtc_spoolid but the problem is i think i will have to order by Spool Count in descending order and then take the grea
test one assuming this to be the latest one corresponding to the Jobname and Jobcount i have provided.
and I am not getting the spool_id when i execute the program in background. i even used Wait up to 5 seconds. But still no value.
Thanks & Regards,
Chandni Sharma.
2012 Dec 20 10:26 AM
2012 Dec 20 11:16 AM
WITH SPOOLNR = SPOOLNR----------> This is of type TSP01-RQIDENT
Using WITH you pass the selection-screen parameters to the SUBMIT'ted program. AFAIK there is no such addition for the SUBMIT statement.
Release 731 documentation does not mention this addition in the SUBMIT statement. Can you redirect me to the one you are referring to!
BR,
Suhas