Skip to Content
0
Jan 11, 2012 at 09:01 AM

spool creation in foreground for ALV without print popup screen

468 Views

Hi, I have requirement of sending ALV grid output to Email as PDF attachment using only set_table_for_first_display method. I am doing similar thing as given in below link.

http://wiki.sdn.sap.com/wiki/display/Snippets/SENDALVGRIDASPDFATTACHMENTTOSAPINBOXUSINGCLASSES?showComments=true&showCommentArea=true#addcomment

but when it is going inside set_table_for_first_display method,it is coming back to the calling screen with spool id. it is not returning to the next line of set_table_for_first_display method. my requirement is, it should create spool without showing print pop up screen in foreground. I have tried all possibilities. but not yet succeeded. My code snap is like this.

  CALL FUNCTION 'SET_PRINT_PARAMETERS'
   EXPORTING
     destination                 = 'LOCL'
     layout                      = 'X_65_512/2'
     line_count                  = '65'
     line_size                   = '1024'.

  st_print-print = 'X'.

  gs_layout_alv-zebra = 'X'.
  gs_layout_alv-cwidth_opt = selected.

*  display alv
  CALL METHOD grid->set_table_for_first_display
       EXPORTING
           is_layout                     = gs_layout_alv
           is_print                      = st_print
    CHANGING
            it_outtab                     = git_summary[]
            it_fieldcatalog               = gt_fieldcat_lvc[]
    EXCEPTIONS
         invalid_parameter_combination = 1
         program_error                 = 2
         too_many_lines                = 3
         OTHERS                        = 4
          .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  IF sy-batch = 'X'.
*  NEW-PAGE PRINT OFF.
*  CALL FUNCTION 'ABAP4_COMMIT_WORK'.

*  SELECT * FROM tsp01 INTO tsp01
*           WHERE rq2name = st_print-print_ctrl-pri_params-plist
*           ORDER BY rqcretime DESCENDING.
*    v_spono = tsp01-rqident.
*    EXIT.
*  ENDSELECT.
*
*  IF sy-subrc NE 0.
*    CLEAR v_spono.
*  ENDIF.

*convert spool to pdf and send as attachment to sap inbox.
    MOVE sy-spono TO v_spono.

<formatted the code snippet>

v_spono is everytime showing 0.

Edited by: Suhas Saha on Jan 11, 2012 3:26 PM