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: 

Get program name from print spool number

Former Member
0 Kudos

Hello,

     My requirement is user is able to create a PDF from a SAP spool job with a proper defined filename .

User launches the application i.e ME23N , CV04n etc...

Application provides the list of recent print jobs with proper name.

In the coding , I had select the spool number from TSP01 now i am looking for the link table between a spool request and the corresponding

abap program .

following things done in the coding

1> get spool number from TSP01

2> Pass the spool number to TBTCP-LISTIDENT

but here i am not getting any result .

Please suggest me some table or FM which gives me the program name for print spool number.

Thanks and Regards,

Prakash Kolhe

10 REPLIES 10

ipravir
Active Contributor
0 Kudos

Hi,

Use the TSP01, TBTCO and TBTCP table to get the Program name and other characteristics based on the spool no.

Regards.

Praveer.

Former Member
0 Kudos

Hello Praveer,

     Thanks for your quick response .

In TBTCO table contains value only if the spool is created by job .

In our case this print reqest is not present in TBTCP . Please suggest any other solution .

Thanks and Regards,

Prakash Kolhe

ipravir
Active Contributor
0 Kudos

Hi,

Use the LISTIDENT column /  field in TBTCP table to pass the Spool no.

You will get the Job Name and based on that, you will get the Program name.

Regards.

Praveer.

Former Member
0 Kudos

Hello Praveer,

  yes , you are correct but it only success if the spool is created by job.

This spool is not in TBTCP  so how can i get the program name .

Thanks and Regards,

Prakash Kolhe

ipravir
Active Contributor
0 Kudos

Hi,

How are you creating the spool? if possible provide the code information.

Regards.

Praveer.

Former Member
0 Kudos

Hello Praveer,

1*..First get the spool number from tspo1

SELECT * FROM tsp01 WHERE rqowner EQ sy-uname.

     MOVE-CORRESPONDING tsp01 TO it. APPEND it.

   ENDSELECT.

2 **..

LOOP AT it .

     MOVE it-rqident TO listident.

* find all job steps in tbtc_spoolid that relate to given spoolid

     SELECT * FROM tbtc_spoolid INTO TABLE steps_spoolid

     WHERE spoolid = listident.

     IF sy-subrc = 0.

       LOOP AT steps_spoolid INTO step_spoolid.

         IF step_spoolid-recycled IS INITIAL.

           SELECT SINGLE * FROM tbtcp INTO step

           WHERE jobname = step_spoolid-jobname AND

                 jobcount = step_spoolid-jobcount AND

                 stepcount = step_spoolid-stepcount.

           IF sy-subrc = 0.

             APPEND step TO steps.

           ENDIF.

         ENDIF.

       ENDLOOP.

     ELSE" old job without TBTC_SPOOLID entry?

       SELECT * FROM tbtcp INTO TABLE i_steps

       WHERE jobname LIKE '%'

         AND jobcount LIKE '%'

         AND listident = listident.

       IF sy-subrc = 0.

         APPEND LINES OF i_steps TO steps.

       ENDIF.

     ENDIF.

ENDLOOP.



SECOND POINT : not getting any value

ipravir
Active Contributor
0 Kudos

Hi,

Basically all background Jobs are executed though the BASIS user id.

Kindly provide the user ID as input field and then try with other use id.

Since you are searching the Program Name through the User ID. for the timing remove the user id and pass the any known Spool no and check the result of your seconds point.

Regards.

Praveer.

Former Member
0 Kudos

Hello ,

  thanks again.

But i need the program name which has a  given spool request number not any  .

Spool Request Number : i.e user run the T-code and print it then spool request generate .

suppose i am the User : PRAK and execute the t-code ME23N and print it .

Here system generate the spool number  so we need to find out the executable program name .

Regards,

Prakash Kolhe

SimoneMilesi
Active Contributor
0 Kudos

I do not think  there is such stored information (i'm checking a bit in my system without success).

You can still work a tricky work around.

In each print program you can fill the spool parameters

RQ0NAME

RQ1NAME

RQ2NAME

with TCODE/sy-repid and the recover them reading TSP01 table.

Laszlo_B
Active Contributor
0 Kudos

Hello Prakash,

unfortunately the R/3 spooler does not use a dedicated table/field to store the value which program has created the spool.

The nearest solution is to use the Spool Name: if the application does not override this data, the creating program can be seen in TSP01-RQ0NAME, TSP01-RQ1NAME, TSP01-RQ2NAME.

For example, if you print the demo program SHOWCOLO and you don't change the Spool Name, the default Spool Name will be:

LIST1S LOCL SHOWCOLO_

Where "SHOWCOLO" is the report name.

Since this value can be easily overritten by the application, the better solution would be to check the spools from the application. For example: as far as I know the applications which use table NAST contain the spool data in fields NAST-LDEST, NAST-DSNAM, NAST-DSUF1, NAST-DSUF2 (as well as a few other fields), where DSNAM, DSUF1 and DSUF2 are the same as the previously mentioend RQ0NAME, RQ1NAME and RQ2NAME.

Best regards,

Laszlo