Saturday, December 18, 2010
We can print alv report without displaying on screen by passing print parameters through function module REUSE_ALV_LIST_DISPLAY or REUSE_ALV_GRID_DISPLAY.

Steps to print ALV Output

  1. define print parameters structure
    " Workareas
    data:
    w_print            type slis_print_alv.
    
  2. build w_print structure. double click on slis_print_alv structure, u will come to know what are the parameters u can pass using that structure.
    w_print-print = 'X'.
    
  3. Pass w_print structure through REUSE_ALV_GRID_DISPLAY. Print parameters screen popup is displayed, Once press continue output is written to spool, after REUSE_ALV_GRID_DISPLAY function module call, we can find the spool number in sy-spono
    data:
    l_program type sy-repid.
    l_program = sy-repid.
    
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    i_callback_program = l_program
    is_layout          = w_layout
    it_fieldcat        = i_fieldcat
    it_events          = i_events
    is_print           = w_print
    tables
    t_outtab           = i_t001
    exceptions
    program_error      = 1
    others             = 2.
    if sy-subrc  0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    elseif sy-subrc = 0.
    "sy-spono gives u spool no..
    endif.
    
  4. Once u know the spool no .. u can get the spool using the below function module
    "Variables
    data:
    l_no_of_bytes type i,
    l_pdf_spoolid like tsp01-rqident,
    l_jobname     like tbtcjob-jobname,
    l_jobcount    like tbtcjob-jobcount.
    
    call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
    exporting
    src_spoolid              = g_spool_no
    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
    exceptions
    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.
    

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.