Skip to Content
author's profile photo Former Member
Former Member

report output to spool


how to generate spool with the report output when the program is run in back ground .

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Nov 20, 2007 at 10:42 AM

    When a program is run in background, any write statements will automatically write to spool

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 10:44 AM


    When you use a write statement in your program and

    run it in background, the output of the WRITE

    statement is put in SPOOL.

    u can chk it in SM37


    Samson Rodrigues.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 10:47 AM


    See this sample code it might help u.

    Save Report Output to a PDF File

    This report takes another report as input, and captures the output of that report. The output is then converted to PDF and saved to a local file. This shows how to use some of the PDF function modules, as well as an easy way to create PDF files.

    One thing I am not thrilled about is how the spool number is retrieved. If anyone has any better method, please let me know! Until I actually have a production use for a program like this, I will not try to find a better way.

    Source Code Listing

    report zabap_2_pdf.

    *-- Enhancements: only allow to be run with variant. Then called

    *-- program will be transparent to users

    *-- TABLES





    mstr_print_parms like pri_params,

    mc_valid(1) type c,

    mi_bytecount type i,

    mi_length type i,

    mi_rqident like tsp01-rqident.



    mtab_pdf like tline occurs 0 with header line,

    mc_filename like rlgrap-filename.



    p_repid like sy-repid, " Report to execute

    p_linsz like sy-linsz default 132, " Line size

    p_paart like sy-paart default 'X_65_132'. " Paper Format


    concatenate 'c:\'



    into mc_filename.

    *-- Setup the Print Parmaters

    call function <b>'GET_PRINT_PARAMETERS'</b>


    authority= space

    copies = '1'

    cover_page = space

    data_set = space

    department = space

    destination = space

    expiration = '1'

    immediately = space

    in_archive_parameters = space

    in_parameters = space

    layout = space

    mode = space

    new_list_id = 'X'

    no_dialog= 'X'

    user = sy-uname


    out_parameters = mstr_print_parms

    valid = mc_valid


    archive_info_not_found = 1

    invalid_print_params = 2

    invalid_archive_params = 3

    others = 4.

    *-- Make sure that a printer destination has been set up

    *-- If this is not done the PDF function module ABENDS

    if mstr_print_parms-pdest = space.

    mstr_print_parms-pdest = 'LOCL'.


    *-- Explicitly set line width, and output format so that

    *-- the PDF conversion comes out OK

    mstr_print_parms-linsz = p_linsz.

    mstr_print_parms-paart = p_paart.

    <b> submit (p_repid) to sap-spool without spool dynpro

    spool parameters mstr_print_parms

    via selection-screen

    and return.</b>*-- Find out what the spool number is that was just created

    perform get_spool_number using sy-repid


    changing mi_rqident.

    *-- Convert Spool to PDF

    call function 'CONVERT_ABAPSPOOLJOB_2_PDF'


    src_spoolid= mi_rqident

    no_dialog = space

    dst_device = mstr_print_parms-pdest


    pdf_bytecount = mi_bytecount


    pdf = mtab_pdf


    err_no_abap_spooljob = 1

    err_no_spooljob = 2

    err_no_permission = 3

    err_conv_not_possible = 4

    err_bad_destdevice = 5

    user_cancelled = 6

    err_spoolerror = 7

    err_temseerror = 8

    err_btcjob_open_failed = 9

    err_btcjob_submit_failed = 10

    err_btcjob_close_failed = 11

    others = 12.

    call function 'DOWNLOAD'


    bin_filesize = mi_bytecount

    filename = mc_filename

    filetype = 'BIN'


    act_filename = mc_filename


    data_tab = mtab_pdf.


    • FORM get_spool_number *


    • Get the most recent spool created by user/report *


    • --> F_REPID *

    • --> F_UNAME *

    • --> F_RQIDENT *


    form get_spool_number using f_repid


    changing f_rqident.


    lc_rq2name like tsp01-rq2name.

    concatenate f_repid+0(8)


    into lc_rq2name separated by '_'.

    select * from tsp01 where rq2name = lc_rq2name

    order by rqcretime descending.

    f_rqident = tsp01-rqident.



    if sy-subrc ne 0.

    clear f_rqident.


    endform." get_spool_number

    Hope this helps u.

    Also refer


    PDF Output

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 10:53 AM

    SM36 , select job wizard,when u define the job u can specify spool list recepients, system will catch all write statements to spool and send the spool to ur SAP inbox, from there u can take print if needed.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.