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: 

How to retrieve a spool id

mrahhaoui
Participant
0 Kudos

Hi I generated a spool id by a submit but I wanted to retrieve it because I have to convert the report in pdf. The function 'CONVERT_ABAPSPOOLJOB_2_PDF' requires the spoolid.

Anybody has a solution please?

* Generate spool-id.

  SUBMIT rkaep000
    WITH P_TCODE = 'KSB1'
    WITH SELECTION-TABLE i_tab
     TO SAP-SPOOL
*       SPOOL PARAMETERS print_parameters
*       ARCHIVE PARAMETERS archi_parameters
*       WITHOUT SPOOL DYNPRO
     AND RETURN.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
      EXPORTING
        src_spoolid   = spoolid
        no_dialog     = 'X'
      IMPORTING
        pdf_bytecount = l_pdf_fsize
      TABLES
        pdf           = l_pdf_table
      EXCEPTIONS
        OTHERS        = 0.
    IF SY-SUBRC EQ 0.
    ENDIF.

Regards,

Mohamed.

8 REPLIES 8

former_member156446
Active Contributor
0 Kudos

SY-SPONO should help u

Former Member
0 Kudos

another way you can get the details in TBTC_SPOOLID as well.

0 Kudos

SY-SPONO is the best option..

0 Kudos

Yes but how to use SY-SPONO and retrieve this spool-id by this SY-SPONO?

Thank you and regards,

MohameD.

0 Kudos

SY-SPONO it self is the last spool number in current program.

so.. in FM

CALL FUNCTION *'CONVERTABAPSPOOLJOB_2_PDF'*_

EXPORTING

src_spoolid = SY-SPONO -


> u can directly pass i guess

.........................

............................

.............................

Former Member
0 Kudos

Hi,

Get from the table TSP01.

Regards,

Kumar Bandanadham

venkat_o
Active Contributor
0 Kudos

Hi rahhaoui mohamed,

I have developed report to do what you asked . Its absolutely working. You have to create two programs with names ztest_print and ztest_to_be_printed. You will find ztest_to_be_printed program at end of the code. code wise very small.

Once you check , change to according to your requirement.

<pre>

REPORT ztest_print.

TABLES:

tsp01.

"Variables

DATA:

l_lay TYPE pri_params-paart,

l_lines TYPE pri_params-linct,

l_cols TYPE pri_params-linsz,

l_val TYPE c.

*Types

TYPES:

t_pripar TYPE pri_params,

t_arcpar TYPE arc_params.

"Work areas

DATA:

lw_pripar TYPE t_pripar,

lw_arcpar TYPE t_arcpar.

"Variables

DATA:

l_no_of_bytes TYPE i,

l_pdf_spoolid LIKE tsp01-rqident,

l_jobname LIKE tbtcjob-jobname,

l_jobcount LIKE tbtcjob-jobcount,

file_name type string.

"Types

TYPES:

t_attachment TYPE solisti1,

t_pdf TYPE tline.

"Workareas

DATA :

w_attachment TYPE t_attachment,

w_pdf TYPE t_pdf.

"Internal Tables

DATA :

i_attachment TYPE STANDARD TABLE OF t_attachment,

i_pdf TYPE STANDARD TABLE OF t_pdf.

&----


*& Selection-screen

&----


parameters:

p_file type ibipparms-path.

at selection-screen on value-request for p_file.

perform f4_for_p_file changing file_name .

l_lay = 'X_65_132'.

l_lines = 65.

l_cols = 132.

"Read, determine, change spool print parameters and archive parameters

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

in_archive_parameters = lw_arcpar

in_parameters = lw_pripar

layout = l_lay

line_count = l_lines

line_size = l_cols

no_dialog = 'X'

IMPORTING

out_archive_parameters = lw_arcpar

out_parameters = lw_pripar

valid = l_val

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

IF l_val <> space AND sy-subrc = 0.

lw_pripar-prrel = space.

lw_pripar-primm = space.

SUBMIT ztest_to_be_printed

TO SAP-SPOOL

SPOOL PARAMETERS lw_pripar

ARCHIVE PARAMETERS lw_arcpar

WITHOUT SPOOL DYNPRO

AND RETURN.

SELECT MAX( rqident )

FROM tsp01

INTO tsp01-rqident

WHERE rqowner = sy-uname.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = tsp01-rqident

no_dialog = ' '

IMPORTING

pdf_bytecount = l_no_of_bytes

pdf_spoolid = l_pdf_spoolid

btc_jobname = l_jobname

btc_jobcount = l_jobcount

TABLES

pdf = i_pdf.

CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'

EXPORTING

line_width_src = 134

line_width_dst = 255

TABLES

content_in = i_pdf

content_out = i_attachment

EXCEPTIONS

err_line_width_src_too_long = 1

err_line_width_dst_too_long = 2

err_conv_failed = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE s000(0k) WITH 'Conversion Failed'.

EXIT.

ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'C:\Documents and Settings\Administrator\Desktop\venkat.pdf'

filetype = 'BIN'

TABLES

data_tab = i_attachment.

ENDIF.

&----


*& Form F4_FOR_p_file

&----


form f4_for_p_file changing file.

data:

l_field_name like dynpread-fieldname value 'P_FILE'.

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = l_field_name

importing

file_name = p_file.

file = p_file.

endform. " F4_FOR_p_file

<pre>

REPORT ztest_to_be_printed.

Write 'Report is done by me'.

</pre></pre>

I hope that it solves your problem.

Thanks

Venkat

mrahhaoui
Participant
0 Kudos

ONCATENATE 'rkaep000' sy-datum sy-uzeit INTO name.

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = name

IMPORTING

jobcount = number

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4.

  • Generate spool-id.

IF sy-subrc = 0.

SUBMIT rkaep000

WITH p_tcode = 'KSB1'

WITH SELECTION-TABLE i_tab

WITH kostl = wa_r_kostl-low

TO SAP-SPOOL

SPOOL PARAMETERS print_parameters

ARCHIVE PARAMETERS archi_parameters

WITHOUT SPOOL DYNPRO

VIA JOB name NUMBER number

AND RETURN.

IF sy-subrc = 0.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = number

jobname = name

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.

  • Retrieve the spool id in table tbcto and tbtc_spoolid

SELECT SINGLE * FROM tbtco INTO wa_tbtco

WHERE jobname EQ name

AND sdluname EQ sy-uname.

SELECT SINGLE * FROM tbtc_spoolid INTO wa_tbtc_spoolid

WHERE jobcount = wa_tbtco-jobcount.

MOVE wa_tbtc_spoolid-spoolid TO wa_spoolid.