Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Spool number of sumitted program

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

SuhaSaha
Advisor
Advisor
0 Kudos

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

6 REPLIES 6

Former Member
0 Kudos

you can get recent spool number based on the date , user and time form table TSP01

0 Kudos

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

0 Kudos

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

0 Kudos

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.

0 Kudos

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

SuhaSaha
Advisor
Advisor
0 Kudos

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