Sending an ALV List screen output to SPOOL

Hi Guru's,
     I am working with a standard transaction FBWE. In this transaction we are displaying a remittance list
using ALV LIST.  Now the requirement is I need to send this ALV List output to SPOOL.
               1. Please tell me how to send an ALV List output to Spool.
               2. This transaction is having only one user exit, as per my investigation I can not use
                   this user exit. Can anybody tell me the alternative way for this.
Thanks,
Ravi

You can using the SUBMIT along with spool options
Read the SUBMIT help.

Similar Messages

  • How to send the alv list display to spool

    Hi all,
    I am executing a program in foreground. My requirement is sending alv list output to spool. When i execute the smae program in background mode the SAP is handling the spool output in hierarchial list display. How to get the same output in foreground also.
    Thanks and Regards,
    Vijay.

    Hi max,
    I think my question is not clear.
    when I execute my report in background mode, I can able to see the output in the spool.
    But when I execute the same report in foreground no spool output is getting generated.
    To handle this I am calling some function modules like RSPO_OPEN_SPOOLREQUEST , RSPO_WRITE_SPOOLREQUEST,  RSPO_WRITE_SPOOLREQUEST. But by using this i cannot able to get the desired output in alv list display format. what to do to get my desired output.
    Thanks and Regards,
    Vijay.

  • Multiple ALV lists in a single spool of a job

    Hi All,
    Executing a custom program in background generates 2 lists in two different spools.
    First list  - ALV Grid displayed as ALV list
    Second List - ALV Blocked List.
    Though both the Spool request numbers generated during the execution of the program are displayed in the JOB LOG of the background job,only the latest spool(ALV Blocked List) is saved under this job.
    We should go to Tx:SP01/02 to view the First list(ALV Grid) generated in the first Spool request.
    Can someone tell me how to get both the lists in a single spool request..(Programmatically)
    Or let me know if there is a way to display both the spool numbers in the Spool list of the job in SM37.
    Thanks in advance.
    Hemanth

    Hi Hemanth,
    maybe you can have a look at the function RSPO_INSERT_SPOOL_CONCATENATE. There is a documentation in the function module transaction.
    Regards
    Frédéric

  • ALV lists in background = no spool - why ??

    Hi Experts,
    I have a quick (probably very simple) issue on programs using ALV grid/lists.
    We have a program, dointg some treatmeant.
    At end of execution of program we display errors and processing messages viathe ALV grid.
    So it is working fine on foreground.
    But when we execute it in background we have no spool. nothing. Even in SM37 not the spool icon.
    I understood that normally we could have the ALV content in the spool. But I do not understand what is wrong.
    Could some experts help me to understand what is wrong and hwo to solve ??
    Thanks for your help.
    S.N

    Hi Newbie,
    The importing parameter IS_PRINT of ALV List will solve your issue. I have tested this.
    Data : wa_print type SLIS_PRINT_ALV.
    wa_print-print = 'X'.
    wa_print-no_print_listinfos = 'X'.
    Now you have to make separate call for ALV in foreground and background .
    For that,
    If sy-batch = 'X'.
    call function module by passing IS_PRINT parameter(wa_print).
    else.
    call function module without IS_PRINT.
    endif.
    Test the spool using sp01.
    Regards
    Sreekanth

  • ALV List to spool..

    Hello,
    I need to send the alv list to the spool . The device name is part of my selection screen. I know that i have to pass the value in the structure in the function module REUSE_LIST_DIPSLAY  but where would i pass on the device name and other print parameters?
    Thanks & Regards

    Hi subramaniam,
    My requirement is that the selection screen has the following options as radio buttons
    1) Send to Device
    2) Send to device
    Depending on the choice the report has to be printed.I don't think the user is going to agree to the method that you suggested .
    The selection screen has also an input field for the device name.
    Thanks and regards
    Avirop

  • Problems submitting ALV list to spool

    Hi!
    When sending the ALV list (function module REUSE_ALV_GRID_DISPLAY) to sap-spool, there seems to be a problem with the <b>"Total"</b> lines. When the <b>"Total"</b> line appears on a page break, it's not displayed at all - not at the end of the current page nor at the top of the next page. All the other <b>"Total"</b> lines are displayed correctly, as long as they don't appear on a page break.
    Does anyone know how to solve this problem?
    - Mari Virik

    I have not heard of this.  I would suggest that you search OSS notes for this issue.  Or report the problem directly to SAP through OSS.

  • ALV list Header details scattered

    Hi All,
    I have a ALV-LIST report output but the header details displayed are scattered in output. Can you suggest how to align all deatils properly aligned.

    Hi again,
    1. first of all how are u writing / displaying
       the alv header ?
    2. using documentary write ?
       then also, u can use one variable of
      length 100 and use this concept.
    3. If u are using top_of_page
      event,
      in this event, WE CAN use WRITE.
      (i have used it, and it
      works fantastic)
                  (not in case of alv grid)
    4. My point is, what ever u are using,
       use on variable of length 100.
      WRITE value INTO variable.
      using offset
      and then proceed further.
    regards,
    amit m.

  • Print ALV List

    Hi experts,
    T code ME2m   after executing i would like to print that sheet . with all coloms in A4 size paper.
    how can Increse size of LETTERS  and  colom and rows.
    after pressing PRINT icon  we will get pop up window(Print ALV List.
    then Output device -  Local
    number of copies1
    Print from page   1         1
    Then i  clicked   PROPERTIES  
    then i double clicked  PARAMETER VALUE     X_65_255
    then i selected  Format  radio button  then i selected  X_58_170..
    then i executed..
    that tiem system giving message   like
    System cannot print the last 176 columns of the
    report
    but i am not getting all the fealds in the page ?
    how to do configuration for this.
    Regards,
    Anthyodaya.

    In ME2N menu List --> Export document to word processing -> Create word document-> Start MS word.
    After downloading,Click F11,Save it as word document,Adjust page set up to Land Scape and also custom paper format
    to accommodate all fields in print.

  • Display Page number in ALV List.

    Dear Friends,
        I want to display page numbers in ALV list print output. But I dont know how to do that without using objects.
    Please suggest.
    Regards,
    Madan.

    TRY LIKE THIS
    data : ifieldcat type slis_t_fieldcat_alv,
           wfieldcat type slis_fieldcat_alv,
           IEVENT TYPE SLIS_T_EVENT,
           WEVENT TYPE SLIS_ALV_EVENT..
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
       I_LIST_TYPE           = 0
    IMPORTING
       ET_EVENTS             = IEVENT
    EXCEPTIONS
      LIST_TYPE_WRONG       = 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.
    ENDIF.
    READ TABLE IEVENT INTO WEVENT WITH KEY NAME = 'TOP_OF_PAGE'.
    IF SY-SUBRC EQ 0.
    WEVENT-FORM = 'TOP_OF_PAGE'.
    MODIFY IEVENT FROM WEVENT INDEX SY-TABIX.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                =
      I_BUFFER_ACTIVE                   = ' '
       I_CALLBACK_PROGRAM                = REPID
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = 'TOPOFPAGE'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       IT_FIELDCAT                       = IFIELDCAT
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
       IT_EVENTS                         = IEVENT
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      IT_ALV_GRAPHICS                   =
      IT_ADD_FIELDCAT                   =
      IT_HYPERLINK                      =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
      IT_EXCEPT_QINFO                   =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = ITAB
    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.
    ENDIF.
    FORM TOP_OF_PAGE.
    WRITE : /10 'HeadinG OF ALV'.
    WRITE : 100 SY-PAGNO.
    ENDFORM.
    ONE THING IS THERE YOU CAN USE WRITE FOR ONLY LIST DISPLAY NOT FOR GRID DISPALY.
    REGARDS
    SHIBA DUTTA

  • How to send the ALV GRID output to spool by using the print button in std t

    How to send the ALV GRID output to spool by using the print button in standard tool bar.
    We have created a button in the va02 transaction.  If user click on the button the new screen will be display on that screen we are populating the alv grid output using the oops concept.  But i am unable to send the output to spool using the print button in the standard tool bar.
    I am able to display the Print parameter dialog box but i am not able to send it to spool.
    Kindly help.
    Thanks In Advance.
    G.V.Ramana

    Hi Shaik,
    There is not properties button in my print screen.
    MODULE user_command_0900 INPUT.
        WHEN 'EXCEL'.
          PERFORM excel_download.                              
        WHEN 'PRI'.
          PERFORM print_output.
    form Print_output.
    CALL FUNCTION 'RSPO_LIST_LAYOUT_FITS'
               EXPORTING
                    columns        = 80
                    device         = 'ANY '
                    lines          = 65
                    maxpenality    = 1999
               TABLES
                    layouts        = lt_layouts1
               EXCEPTIONS
                    unknown_device = 1
                    OTHERS         = 2.
          IF sy-subrc = 0.
            LOOP AT lt_layouts1.
              IF lt_layouts1-penality < 1000        AND
                 lt_layouts1-penality < l_min_penality.
                l_layout       = lt_layouts1-layout.
                l_min_penality = lt_layouts1-penality.
              ENDIF.
            ENDLOOP.
            IF NOT l_layout IS INITIAL.
              CALL FUNCTION 'GET_PRINT_PARAMETERS'
                   EXPORTING
                        mode                   = 'CURRENT'
                        line_size              = 80             "#EC *
                new_list_id            = l_new_list_id
                        no_dialog              = l_no_dialog
                        layout                 = l_layout
                   IMPORTING
                        out_archive_parameters = rs_arc_params
                        out_parameters         = rs_pri_params
                        valid                  = l_valid
                   EXCEPTIONS
                        archive_info_not_found = 1
                        invalid_print_params   = 2
                        invalid_archive_params = 3
                        OTHERS                 = 4.
              IF sy-subrc NE 0.                                 " INS SLIN
              ENDIF.                                            " INS SLIN
              IF rs_pri_params-linsz LT 80 OR
                 rs_pri_params-linsz LT gt_stack-s_lprint-width.
                gt_stack-print_line_break = 'X'.
              ELSE.
                CLEAR gt_stack-print_line_break.
              ENDIF.
              IF l_valid NE 'X'.
                rs_pri_params = ls_pri_params_sav.
                rs_arc_params = ls_arc_params_sav.
              ENDIF.
            ENDIF.
          ENDIF.
    endform.                    " Print_output
        CALL METHOD gv_cost_tot_alv_grand->set_table_for_first_display
                EXPORTING
                   is_layout         = gs_layout_cost_tot_grand
                CHANGING
                   it_fieldcatalog   = gt_fcat_cost_tot_grand[]
                   it_outtab         = gt_cost_tot_grand[].
    Please check my code

  • ALV list display in a Background job - Spool output

    Hi,
    We are currently working on a report scheduled to be run in the background job, and the ALV list is displayed in the spool output.
    ALV list in the spool does not look the same as front run job, the column headers are all crowded together, and there is no grid in-between different columns or rows. It's hard to read.
    Is there a way to add grid for this kind of output?
    Thanks!

    Hi Deepak:
    I expanded your report into two rows display, and the grid in the spool display simply gone!
    report zzscratch line-size 120 no standard page heading.
    type-pools slis.
    tables pa0001.
    data : li_field type standard table of slis_fieldcat_alv,
    gi_events type standard table of slis_alv_event,
    gr_layout_bck type slis_layout_alv,
    gr_save like disvariant,
    gr_events type slis_alv_event.
    types : begin of gtt_emp,
    pernr type persno,
    ename  like pa0001-ename,
    uname  like pa0001-UNAME,
    end of gtt_emp.
    data : lr_field type slis_fieldcat_alv.
    data : lc_rep like syst-repid.
    data : li_emp type standard table of gtt_emp,
    lr_emp type gtt_emp.
    data : gv_ref_table type lvc_rtname.
    gv_ref_table = 'CATSDB'.
    lr_field-fieldname = 'PERNR'.
    lr_field-ref_tabname = gv_ref_table.
    lr_field-inttype = 'N'.
    lr_field-outputlen = 8.
    lr_field-seltext_l = 'EMPLOYEE Number'.
    append lr_field to li_field.
    lr_field-fieldname = 'ENAME'.
    lr_field-ref_tabname = 'PA0001'.
    lr_field-inttype = 'C'.
    lr_field-outputlen = 40.
    lr_field-seltext_l = 'EMPLOYEE Name'.
    append lr_field to li_field.
    lr_field-fieldname = 'UNAME'.
    lr_field-ref_tabname = 'PA0001'.
    lr_field-inttype = 'C'.
    lr_field-outputlen = 12.
    lr_field-seltext_l = 'User Name'.
    lr_field-row_pos = 2.
    lr_field-col_pos = 1.
    append lr_field to li_field.
    lc_rep = sy-repid.
    gr_layout_bck-edit_mode = 'D'.
    gr_save-report = sy-repid.
    lr_emp-pernr = '00000001'.
    lr_emp-ename = 'abc'.
    lr_emp-uname = 'testus'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000002'.
    lr_emp-ename = 'def'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000003'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000004'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000005'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000006'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000007'.
    append lr_emp to li_emp.
    lr_emp-pernr = '00000008'.
    append lr_emp to li_emp.
    end-of-selection.
    Function module for ALV grid display
      call function 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_buffer_active    = 'X'
                i_callback_program = lc_rep
                is_layout          = gr_layout_bck
                it_fieldcat        = li_field
                i_save             = 'A'
                is_variant         = gr_save
                it_events          = gi_events
           TABLES
                t_outtab           = li_emp[]
           EXCEPTIONS
                program_error      = 1
                others             = 2.
      if sy-subrc <> 0.
    clear gr_messages.
    message e023 into gr_messages.
    append gr_messages to gi_messages.
      endif.

  • Multi ALV lists/grid report in one output/screen

    Hi,
    I need to develop a ALV report, where in the output/ALV/List/Grid should look like below (all lists/grids should be fit in only one screen, if there are too many entires in the sub reports user will scroll down each), here am giving the details (MATNR, KUNNR, LIFNR) of the output just for example purpose
                                                 _My_Report_
    Sub_report_1
    MATNR-----Description
    Sub_report_2
    KUNNR-----Name
    Sub_report_3
    LIFNR-----Name
    Sub_report_4
    BANK-----Name
    Its okay to have any kind of ALV either grid or List, when user press F8 on the selection screen all should come in one screen, if there are too many entries then user will scroll down
    Thank you

    Hello,
    You can use blocked alv to achieve this.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          i_callback_program = l_repid.
    *Adding First Block to the List
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                  = w_layo
          it_fieldcat                = it_fcat
          i_tabname                  = text-064
          it_events                  = it_events
          it_sort                    = it_sort
        TABLES
          t_outtab                   = it_mainalv
        EXCEPTIONS
          program_error              = 1
          maximum_of_appends_reached = 2
          OTHERS                     = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                  = w_layo
          it_fieldcat                = it_fcat1
          i_tabname                  = text-094
          it_events                  = it_events1
          it_sort                    = it_sort1
        TABLES
          t_outtab                   = it_field_change
        EXCEPTIONS
          program_error              = 1
          maximum_of_appends_reached = 2
          OTHERS                     = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Displaying the list
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
        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.
      ENDIF.
    Thanks.
    ramya.

  • How to send an ALV to Spool

    Dear all,
    Could you please help, my requirement is to send an ALV report as a PDF attachement to a list of email address. My plan is to send the ALV to spool and read it from there and email it. However I have a problem in as much as the ALV is not being sent to spool, furthermore I also get print dialog popup when running the report. Can you please help, i am using CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY and  CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF' I have browsed here and there are several questions on this topic but they do not address the issue of sending the file to the spool. The partial code is below
    DATA:i_t001 TYPE t001 OCCURS 0,
         pdf    LIKE tline OCCURS 0,
         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.
    PARAMETERS: p_file TYPE string.
    INITIALIZATION.
      p_file = 'H:\TEST_gh.pdf'.
    START-OF-SELECTION.
      rp-def-time-period.
      help1 = behrs DIV 24.
      bdate = ldate - help1.
      help1 = behrs MOD 24.
      help2 = ltime(2) - help1.
      IF help2 LT 0.
        bdate = bdate - 1.
        btime = ltime.
        btime(2) = 24 + help2.
      ELSE.
        btime = ltime.
        btime(2) = help2.
      ENDIF.
      pn-begps = ldate - 1.
      pn-endps = ldate.
    GET pernr.
      loop at p0007 where begda le ldate and endda ge ldate.  "
      endloop.                                              
    * überprüft Arbeitszeitplanregel
    * CHECK schkz.
      CHECK p0007-schkz IN schkz.
      CHECK p0007-zterf IN zterf.        
      CALL FUNCTION 'HR_SEL_STAT_CHECK'
           EXPORTING
                get_pernr    =  pernr-pernr
                get_ldate    =  ldate
                get_bdate    =  bdate
                get_btime    =  btime
                get_psp_flag =  psp_flag
                get_ltime    =  ltime
    *    IMPORTING
    *         NO_PERMIT    =
           TABLES
                get_p0000    =  p0000
                get_p0001    =  p0001
                get_p0002    =  p0002
                get_p0050    =  p0050
                get_p0007    =  p0007
                data_tab     =  data_tab.
    *   End-of-Selection                                                   *
    END-OF-SELECTION.
      loop at data_tab into ls_data_tab.
        ls_data_tab-total_records = '1'.
        ls_data_tab-kostl = p0001-kostl.
        Append ls_data_tab to lt_data_tab.
      endloop.
      DESCRIBE TABLE data_tab LINES lines.
      CALL FUNCTION 'HR_GET_ERROR_LIST'
        TABLES
          error      = errors
          errortexts = errortexts
        EXCEPTIONS
          no_errors  = 1
          OTHERS     = 2.
      IF lines EQ 0 AND sy-subrc EQ 1.
        MESSAGE i050.
        STOP.
      ENDIF.
      LOOP AT errors.
        READ TABLE data_tab WITH KEY errors-pernr.
        IF sy-subrc EQ 0.
          DELETE data_tab INDEX sy-tabix.
        ENDIF.
      ENDLOOP.
      g_repid = sy-repid.
    * fill field catalog for output
      PERFORM fill_fcat USING  fcat
                               g_repid.
    * Listheader
      PERFORM fill_header USING header_alv_wa
                                header_alv.
      FIELD-SYMBOLS <lwa_fcat> like line of fcat.
      LOOP AT fcat ASSIGNING <lwa_fcat>.
        IF <lwa_fcat>-fieldname = 'TOTAL_RECORDS'.
          <lwa_fcat>-do_sum    = 'X'.
        ENDIF.
      ENDLOOP.
    *Right, sort the table and produce sub totals
      wa_sort-spos      = 18.
      wa_sort-fieldname = 'KOSTL'.
      wa_sort-up        = 'X'.
      wa_sort-subtot    = 'X'.
      append wa_sort to it_sort.
    * Layout for REUSE_ALV_GRID_DISPLAY
      s_layout-colwidth_optimize = 'X'.
      s_layout-zebra             = 'X'.
      s_layout-no_author         = 'X'.
    w_print-print = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = g_repid
        "      i_callback_pf_status_set = 'SET_PF_STATUS'
          i_callback_user_command = 'USER_COMMAND'  
          i_callback_top_of_page  = 'TOP_OF_PAGE'
          is_layout               = s_layout           
          it_fieldcat             = fcat
          it_sort                 = it_sort
          i_save                  = 'A'                       
          i_structure_name        = MY_STRUCTURE'
          is_print                = w_print
        TABLES
          t_outtab                = lt_data_tab
        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.
      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.
          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 'REUSE_ALV_GRID_DISPLAY'
              EXPORTING
                i_callback_program      = g_repid
              "      i_callback_pf_status_set = 'SET_PF_STATUS'
                i_callback_user_command = 'USER_COMMAND'  
                i_callback_top_of_page  = 'TOP_OF_PAGE'
                is_layout               = s_layout           
                it_fieldcat             = fcat
                it_sort                 = it_sort
                i_save                  = 'A'                 
                i_structure_name        = MY_STRUCTURE'
              TABLES
                t_outtab                = lt_data_tab
              EXCEPTIONS
                program_error           = 1.
                ENDIF.
          endif.
        endif.

    Hi Andy ,
    write this code before calling "CONVERT_ABAPSPOOLJOB_2_PDF"
    CALL FUNCTION 'SET_PRINT_PARAMETERS'
         EXPORTING
           destination = 'LOCL' " Printer
           layout      = 'X_65_512/2' "Format "X_65_255
           line_count  = '65' "Line Count
           line_size   = '1024'. "Line Size
    Regards ,
    Yogendra Bhaskar

  • Convert ALV list to PDF and send mails to respective persons

    Hi All,
    I have a requirement ..we have written a program which will give o/p in alv list.Now I got a requirement to download that program to ALV format.Kindly help me how to approch for that we have some standard FM's for that like CONVERT_ABAPSPOOLJOB_2_PDF..what are the necessary inputs I have to give for that FM,
    Second requirement is I have to send an E mail of that list to respective persons.help me on this also
    Regards
      KK

    Hi,
    Try with this program which will send the spool to email.
    PARAMETER: p_email1 LIKE somlreci1-receiver
                        DEFAULT '[email protected]',
               p_sender LIKE somlreci1-receiver
                        DEFAULT '[email protected]',
               p_delspl AS CHECKBOX.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    * Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    * Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount LIKE tbtcm-jobcount,
          gd_jobname LIKE tbtcm-jobname,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject   LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des.
    * Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    * Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    * Write statement to represent report output. Spool request is created
    * if write statement is executed in background. This could also be an
    * ALV grid which would be converted to PDF without any extra effort
      WRITE 'Hello World'.
      new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
    *** Alternative way could be to submit another program and store spool
    *** id into memory.
    *submit ZSPOOLTOPDF2
    *        to sap-spool
    *        spool parameters   %_print
    *        archive parameters %_print
    *        without spool dynpro
    *        and return.
    * Get spool id from program called above
    *  IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
        PERFORM convert_spool_to_pdf.
        PERFORM process_email.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
        IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
    *       FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
    *       FORM get_job_details                                          *
    FORM get_job_details.
    * Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
    *       FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           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.
      CHECK sy-subrc = 0.
    * Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
    *       FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1.
    *  perform send_email using p_email2.
    ENDFORM.
    *       FORM send_email                                               *
    *  -->  p_email                                                       *
    FORM send_email USING p_email.
      CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    * Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = 'Attachname'.
    *  CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod        = 'Message Body text, line 1'.
      APPEND it_mess_bod.
      it_mess_bod        = 'Message Body text, line 2...'.
      APPEND it_mess_bod.
    * If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    * Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
    *       FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
    *       Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
    data:   t_packing_list like sopcklsti1 occurs 0 with header line,
            t_contents like solisti1 occurs 0 with header line,
            t_receivers like somlreci1 occurs 0 with header line,
            t_attachment like solisti1 occurs 0 with header line,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    * Fill the document data.
      w_doc_data-doc_size = 1.
    * Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    * Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    * Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    * Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    * Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    * Populate zerror return code
      ld_error = sy-subrc.
    * Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    Regards,
    Raghav

  • ALV output to spool

    hi,
    i am having a issue when running ALV output to background. If user gives his email address i am able to send output as attachment to email.but incase he doesnt give then i have to send it to SPOOL.
    I am able to send the output to spool but when i execute the report in background i get a POPUP where i have to input device and then a other dialog box which gives formatting information I.E. X_65_132' and when i click OK then spool is getting generated.
    i tried ways to suppress this popup but couldnt find the way..can anyone suggest me a way to suppress this popup?
    i used get_print_parameters function module but the program doesn't go till that place and immediately before executing start-of-selection i am getting this popup.
    regards

    REPORT  ytest.
    INCLUDE yest_top.
    AT SELECTION-SCREEN OUTPUT.
      PERFORM selectionscreen_modify.
      PERFORM validate_selscreen .
    START-OF-SELECTION.
    PERFORM fetch_data.
        PERFORM build_dyntable.
    Inside the build_dyntable perform i am calling alv_list_display to dislay output.
    when i debug the code after executing report from seleciton screen in background execution immediately after AT SLECTION SCREEN OUTPUT i get the popup.
    let me know incase anything to be done to suppress the popup.
    thanks

Maybe you are looking for