Wednesday, December 22, 2010
Set IS_PRINT-PRINT = 'X' to get Print parameters popup. When you execute program, it prints ALV output to spool.
REPORT  zdownload_alvoutput.
*&---------------------------------------------------------------------*
*& Declarations
*&---------------------------------------------------------------------*
DATA:
      i_t001       TYPE t001 OCCURS 0,
      pdf          LIKE tline OCCURS 0.
DATA:
     g_spool       TYPE tsp01-rqident,
     g_program     TYPE sy-repid VALUE sy-repid.
TYPE-POOLS:slis.
DATA:
      w_print      TYPE slis_print_alv,
      w_print_ctrl TYPE alv_s_pctl.
*&---------------------------------------------------------------------*
*& Selection screen
*&---------------------------------------------------------------------*
PARAMETERS: p_file TYPE string.

*&---------------------------------------------------------------------*
*& Initialization
*&---------------------------------------------------------------------*
INITIALIZATION.
  p_file = 'C:\venkat.pdf'.

*&---------------------------------------------------------------------*
*& Start-of-selection
*&---------------------------------------------------------------------*
START-OF-SELECTION.
  SELECT * FROM t001 INTO TABLE i_t001 UP TO 100 ROWS.
  w_print-print = 'X'.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = g_program
      i_structure_name   = 'T001'
      is_print           = w_print
    TABLES
      t_outtab           = i_t001.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    g_spool = sy-spono.
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
      EXPORTING
        src_spoolid = g_spool
      TABLES
        pdf         = pdf.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename = p_file
          filetype = 'BIN'
        TABLES
          data_tab = pdf.
    ENDIF.
  ENDIF.

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.