01-26-2009 7:47 AM
Hello,
does somebody know, how I can get the generated spool number of a submitted program?
Unfortunately, the system variables sy-spono or sy-sponr will be deleted, when the submitted program will be left.
Is it possibly feasible to get the spool number between the function modules 'JOB_OPEN' and 'JOB_CLOSE'?
Thanks a lot and regards.
Sergej
01-26-2009 9:21 AM
Hello Sergej,
Yes, you can get the Spool Number from the Job created.
1. Use the FM: 'GET_JOB_RUNTIME_INFO' to get the Background Job Runtime Data.
2. Then use the table TBTCP to get the Spool Number.
* get the job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
* Get the spool number
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident '0000000000'
ORDER BY jobname
jobcount
stepcount.
IF sy-subrc = 0.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
gd_spool_nr = wa_tbtcp-listident. "gd_spool_nr --> contains spool no.
ENDIF.
Hope this helps.
BR,
Suhas
01-26-2009 7:50 AM
you can get recent spool number based on the date , user and time form table TSP01
01-26-2009 7:58 AM
Only date won't be sufficient. You will have to use the index to retrieve the spool and the title of the spool too.
SELECT SINGLE *
INTO t_tsp01
FROM tsp01
WHERE rqfinal IN ('.','X') " completed spool
AND rqclient = sy-mandt
AND rqowner = sy-uname
AND rqtitle = t_stamp.
Here the variable t_stamp is a spool title that can be passed while submitting the job ( TO SAP-SPOOL COVER TEXT t_stamp ) and used to retrieve the spool that was submitted.
I've also passed the client and owner of spool and spool completion flag so that it uses the index.
regards,
Advait
Edited by: Advait Gode on Jan 26, 2009 8:59 AM
01-26-2009 8:10 AM
Is this way safe?
Is there another way, to find out the generated spool number?
Or is it possible to control the generation of the spool number?
There is the function module 'GET_PRINT_PARAMETERS', but you cannot set the spool number.
Regards
Sergej
01-26-2009 8:16 AM
HI,
Using 'JOB_OPEN' 'SUBMIT_JOB' and 'JOB_CLOSE' FM's you can get the Spool number. the only way is read flatest spool numer from TSP01 table for the created jobname and user.
01-26-2009 8:20 AM
Hi,
Yes this should be safe, atleast it is working in my program. This is because I'm using a date and time stamp for the title, which is unique for each program run. Now if you are submitting the job within a loop, you can add a some sort of a serial number to the title as well.
regards,
Advait
01-26-2009 9:21 AM
Hello Sergej,
Yes, you can get the Spool Number from the Job created.
1. Use the FM: 'GET_JOB_RUNTIME_INFO' to get the Background Job Runtime Data.
2. Then use the table TBTCP to get the Spool Number.
* get the job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
* Get the spool number
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident '0000000000'
ORDER BY jobname
jobcount
stepcount.
IF sy-subrc = 0.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
gd_spool_nr = wa_tbtcp-listident. "gd_spool_nr --> contains spool no.
ENDIF.
Hope this helps.
BR,
Suhas