ITAB TO SPOOL

Dear Experts,
There are many threads regarding spool.
But here I had given task by functional that I had to develop an object which show a some data list, in which i have to tick mark and send selected list as a mail to particular party.
Also same thing to do as mass mailing for scheduling in back ground for all party.
Now problem is I have an internal table with list of customer and it's particular details which i have to send by email.
Now i know how to convert spool to pdf but i don't know how to convert internal table to spool.
Please note i had try with many example which had already posted in sad.sap.com.
i had got only one binary spool from it successfully. but which is not convert into pdf.
Please i know that if i develop smartform for it is to easy but i want to do mass mailing and i had already developed module-pool for it.
Please guide
how do i convert my internal table to spool in specific layout with out using smart form. if it is in oops then it will be more helpful for conceptually.
thanks & regards,
Nayan Lad

Hi,
please find below prgroms are use full this Spool program will convert to PDF RSTXPDFT4.
and this program Spool download
               T A B L E S   & T Y P E S                             *
TYPES : BEGIN OF ty_mail_data ,
          text(4000),
       END OF ty_mail_data.
DATA : t_mail_data TYPE TABLE OF ty_mail_data WITH HEADER LINE ,
       l_mail_data TYPE TABLE OF ty_mail_data WITH HEADER LINE,
       w_char(4000),
       w_char1(4000),
       filenamee LIKE ibipparms-path.
PARAMETERS: p_spool TYPE tsp01-rqident.
Fetching Spool data into internal table
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
     EXPORTING
          rqident = p_spool
     TABLES
          buffer  = t_mail_data.
DELETE t_mail_data WHERE text(1) = '-'.
READ TABLE  t_mail_data WITH KEY text(1) = '|'.
IF sy-subrc EQ 0.
  formatting Internal table according to file fromat...
  LOOP AT t_mail_data.
    IF t_mail_data-text(1) EQ '|' OR  t_mail_data-text(1) EQ '-'.
      l_mail_data-text = w_char .
      APPEND l_mail_data.
      WRITE :/ w_char.
      CLEAR w_char.
      w_char = t_mail_data-text.
    ELSE.
      MOVE t_mail_data-text TO w_char1.
      CONCATENATE w_char w_char1 INTO w_char.
    ENDIF.
  ENDLOOP.
  l_mail_data-text = w_char .
  APPEND l_mail_data.
  WRITE :/ w_char.
ENDIF.
CALL FUNCTION 'F4_FILENAME'
     IMPORTING
          file_name = filenamee.
CALL FUNCTION 'GUI_DOWNLOAD'
     EXPORTING
          bin_filesize            = 1024
          filename                = filenamee
          filetype                = 'ASC'
     TABLES
          data_tab                = l_mail_data
     EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          OTHERS                  = 5.
IF sy-subrc <> 0.
MESSAGE e000 WITH text-i02.    "Exception in GUI_DOWNLOAD
ENDIF.
Edited by: BRsankar on Sep 29, 2011 9:13 AM
Edited by: BRsankar on Sep 29, 2011 9:14 AM

Similar Messages

  • Spool to HTML Function Module

    Hi Experts,
                Can anyone help me please.  Is there any FM that can convert spool to HTML?  Just like converting spool to PDF but only I need it in HTML.  I can't use spool to PDF because I'm having problems when it comes to massive pages, but if it's only 5 pages it actually works but not with 100 pages or more.  So please, if anyone can help me with spool to html.  Points will be given and also to those who tried.  Thanks.
    Anna

    Hi again.  Thanks for your reply.  But I'm actually having a problem with the list variable.  My dilemma actually is how I can transfer the jtab grabphical spool to the abaplist.  Please, please help me and  check what went wrong.  I'm actually trying to download the graphical spool to an html format.  Thanks.
    TABLES: TBTCO, TBTCP, TSP01.
    TYPE-POOLS: truxs.
    DATA: BEGIN OF itab OCCURS 0,
            sp_name TYPE tbtco-jobname,
            br_code(1),
            dumon(7),
            sp_numb TYPE TSP01-rqident,
            ofc(7),
          END OF itab.
    DATA: BEGIN OF btab OCCURS 5,
            fld1(24),
            fld2(12),
          END OF btab.
    DATA: htmllines TYPE TABLE OF w3html WITH HEADER LINE,
               w_jtab TYPE TABLE OF ABAPLIST WITH HEADER LINE.
    DATA: BEGIN OF jtab OCCURS 0,
            fld1(11),
            fld2(41),
            fld3(21),
            fld4(11),
            fld5(10),
            fld6(22),
            fld7(72),
          END OF jtab.
    INITIALIZATION.
    START-OF-SELECTION.
      PERFORM download_html.
    *&      Form  download_html
          text
    FORM download_html.
      DATA: lv_file   TYPE string,
            lv_string TYPE string,
            lt_conv   TYPE truxs_t_text_data.
      SORT itab BY sp_name br_code dumon.
      LOOP AT itab.
        CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
          EXPORTING
            rqident = itab-sp_numb "Spool Number
          TABLES
            BUFFER  = btab.
        LOOP AT btab WHERE fld1 = 'BROKER REPORT ID'.
          PERFORM get_month.
          MOVE: btab-fld2+4(1) TO itab-br_code,
                date TO itab-dumon.
          MODIFY itab.
        ENDLOOP.
        Move to jtab for Conversion HTML
          CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
            EXPORTING
              rqident = itab-sp_numb "Spool Number
            TABLES
              BUFFER  = jtab.
    ****SPOOL TO HTML
        CALL FUNCTION 'SAVE_LIST'
          TABLES
                listobject         = jtab
          EXCEPTIONS
                list_index_invalid = 1
                others             = 2.
        CALL FUNCTION 'WWW_LIST_TO_HTML'
         TABLES
           html = htmllines.
        AT NEW sp_name.
          CONCATENATE: p_file itab-sp_name '\' INTO p_file.
        ENDAT.
        AT NEW br_code.
          PERFORM get_brcode.
          CONCATENATE: p_file brc '\' INTO p_file.
        ENDAT.
        AT NEW dumon.
          CONCATENATE: p_file itab-dumon '\' INTO p_file.
        ENDAT.
        CONCATENATE: p_file itab-ofc '.HTML' INTO p_file.
        IF sy-subrc = 0.
          IF p_pres EQ 'X'.
            MOVE p_file TO lv_file.
            CALL FUNCTION 'GUI_DOWNLOAD'
              EXPORTING
                filename = lv_file
                filetype = 'BIN'
              TABLES
                data_tab = it_pdf_output.
            IF sy-subrc <> 0.
              MESSAGE e398(00) WITH 'Error creating file' p_file.
            ELSE.
              MESSAGE i398(00) WITH 'File Created' p_file.
            ENDIF.
          ELSE.
            APPEND LINES OF it_pdf_output TO lt_conv.
            IF lt_conv[] IS NOT INITIAL.
              OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
              IF sy-subrc EQ 0.
                LOOP AT lt_conv INTO lv_string.
                  TRANSFER lv_string TO p_file.
                ENDLOOP.
                CLOSE DATASET p_file.
                IF sy-subrc EQ 0.
                  MESSAGE i398(00) WITH 'File Created' p_file.
                ELSE.
                  MESSAGE e398(00) WITH 'Error closing file' p_file.
                ENDIF.
              ELSE.
                MESSAGE e398(00) WITH 'Error creating file' p_file.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "convert_spool_to_pdf
    Edited by: Anna Bechayda on Apr 23, 2008 10:18 AM

  • ITAB to PDF without spool request

    Hi Experts,
    I have a requirement where I need to convert internal table data into PDF format and send it as an E-Mail with PDF attachment.
    How do I achieve this .
    I dont have any smart form or SCript...
    In Fact I don't want to use SPOOL....
    Is there any way to convert Internal Table to PDF.....
    Please Guide....
    Edited by: Thomas Zloch on Sep 29, 2011 1:50 PM

    Hi,
    try below stuff,
    http://wiki.sdn.sap.com/wiki/display/Snippets/SENDALVGRIDASPDFATTACHMENTTOSAPINBOXUSINGCLASSES
    some more info like this at ,
    http://wiki.sdn.sap.com/wiki/display/ABAP/SendingMails-HomePage
    Thanks,
    Chandra
    Edited by: Chandrashekhar Mahajan on Sep 29, 2011 3:25 PM

  • Spool to itab

    Hi,
    When a delivery printed, i can get its spool number but i want to upload this spool's contents into an internal table?
    Is that possible?
    Thanks.

    Hi,
    Please search in SDN before you post, you will get lots of answers.
    YOu can use the function module
    *Type Declarations
    TYPES: BEGIN OF ty_rdidata,
    line(1000) TYPE c,
    END OF ty_rdidata.
    DATA: ws_spool LIKE tsp01-rqident,
    i_rdidata TYPE STANDARD TABLE OF ty_rdidata,
    wa_rdidata TYPE ty_rdidata.
    PARAMETERS: p_sp TYPE tsp01-rqident.
    ws_spool = '0000019125'.
    CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB_RAW'
    EXPORTING
    rqident = ws_spool
    FIRST_LINE = 1
    LAST_LINE =
    TABLES
    buffer = i_rdidata
    EXCEPTIONS
    no_such_job = 1
    not_abap_list = 2
    job_contains_no_data = 3
    selection_empty = 4
    no_permission = 5
    can_not_access = 6
    read_error = 7
    OTHERS = 8
    IF sy-subrc 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF..
    regards,
    nazeer

  • URGENT -----  Problem in converting spool to pdf .

    Error - File cannot be opened because of no pages ......
    Hi experts,
    I am passing internal table contents to spool   -->  then spool to pdf  -
    >  then mail sending.
    Everything is fine but only error is in the receiving mail the above error is coming.
    given the code...
    <b>I think the error is in converting into pdf function module</b>
    <b>Help me to solve this problem as it is very urgent</b>
    include data_declare.       "  pasted down
    select * from kna1 into table itab up to 50 rows.
    CALL FUNCTION 'RSPO_OPEN_SPOOLREQUEST'
    EXPORTING
    dest = 'LP01'
    immediate_print = 'X'
    IMPORTING
    handle = handle
    SPOOLID = spoolid.
    loop at itab.
    concatenate itab-kunnr itab-name1 itab-land1 into text separated by
    space.
    CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'
    EXPORTING
    handle = handle
    text =  text.
    endloop.
    CALL FUNCTION 'RSPO_CLOSE_SPOOLREQUEST'
    EXPORTING
    handle = handle.
    Convert Spool to PDF **********************************
      <b>CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = 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.</b>
    Processing Mail Sending ************************************
      DATA: p_email LIKE somlreci1-receiver,
            p_sender LIKE somlreci1-receiver,
            sub(40).
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      REFRESH it_mess_bod.
    Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = text-002.
      it_mess_bod        = text-001.
      APPEND it_mess_bod.
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
      MOVE 'Orders Rejeced on' TO sub.
      WRITE: sy-datum DD/MM/YYYY TO sub+27(10).
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   TABLES it_mess_bod
                                          it_mess_att
                                    USING
                                         p_email
                                           sub                  "text-009
                                          'PDF'
                                           gd_attachment_name
                                           gd_attachment_desc
                                         p_sender
                                         gd_sender_type
                                 CHANGING gd_error
                                          gd_reciever.
    ENDFORM.                    " process_email
    *&      Form  send_file_as_email_attachment
          text
         -->P_IT_MESS_BOD  text
         -->P_IT_MESS_ATT  text
         -->P_TEXT_009  text
         -->P_1058   text
         -->P_GD_ATTACHMENT_NAME  text
         -->P_GD_ATTACHMENT_DESC  text
         <--P_GD_ERROR  text
         <--P_GD_RECIEVER  text
    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-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      CLEAR gt_mail.
      SELECT SINGLE * FROM zmail INTO gt_mail
                      WHERE grpnr = '1'.
      IF NOT gt_mail-mail1 IS INITIAL.
        t_receivers-receiver = gt_mail-mail1.
        APPEND t_receivers.
      ENDIF.
      IF NOT gt_mail-mail2 IS INITIAL.
        t_receivers-receiver = gt_mail-mail2.
        APPEND t_receivers.
      ENDIF.
      IF NOT gt_mail-mail3 IS INITIAL.
        t_receivers-receiver = gt_mail-mail3.
        APPEND t_receivers.
      ENDIF.
      IF NOT gt_mail-mail4 IS INITIAL.
        t_receivers-receiver = gt_mail-mail4.
        APPEND t_receivers.
      ENDIF.
    LOOP AT gt_mail.
       t_receivers-receiver = gt_mail-mailid..
       APPEND t_receivers.
    ENDLOOP.
      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.                    " send_file_as_email_attachment
    Data Declaration ************************************
    DATA : handle LIKE sy-tabix.
    data itab like kna1 occurs 0 with header line.
    data: text(50) type c.
    data: spoolid type TSP01-RQIDENT.
    DATA : gt_listobject LIKE abaplist OCCURS 10 .
    DATA : gt_objcont LIKE soli OCCURS 10 WITH HEADER LINE.
    DATA : gt_objcont1 LIKE soli OCCURS 10 WITH HEADER LINE.
    DATA : gt_objhead LIKE soli OCCURS 10 WITH HEADER LINE.
    DATA : gt_att_head LIKE soli OCCURS 10  WITH HEADER LINE.
    DATA : gt_receivers LIKE soos1 OCCURS 10 WITH HEADER LINE.
    DATA : gt_packing_list LIKE soxpl OCCURS 10 WITH HEADER LINE.
    DATA : gt_so_ali LIKE soli OCCURS 100 WITH HEADER LINE.
    DATA : gt_so_ali1 LIKE soli OCCURS 100 WITH HEADER LINE.
    DATA : gt_document_data LIKE sood1.
    DATA: lineno TYPE i , length TYPE i , size TYPE i.
    DATA: gt_message LIKE soli OCCURS 10 WITH HEADER LINE,
          gt_message1 LIKE soli OCCURS 10 WITH HEADER LINE.
    DATA: gt_scheme LIKE ztrc_scheme OCCURS 0 WITH HEADER LINE,
         gt_mail LIKE zmail_prov OCCURS 0 WITH HEADER LINE.
          gt_mail LIKE zmail." occurs 0 with header line.
    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'.
    DATA: check TYPE c,
          days TYPE i.
    <b></b><b></b><b></b>

    Hi Prashant,
    Thanks for your reply. Really it is very useful one.
    In this, the output list is getting populated into spool and to pdf.
    But my requirement sending the internal table contents to spool directly without dispalying in the output list.
    I did the program like the above mentioned one already. But my requirement is not that one.
    Regards
    chakradhar

  • How to Send Internal table to SAP Spool using Function Modules or Methods?

    Hi Experts,
    How to Send Internal table to SAP Spool using Function Modules or Methods?
    Thanks ,
    Kiran

    This is my code.
    I still get the no ABAP list data for the spool, even tho I can see it sp01?
    REPORT  Z_MAIL_PAYSLIP.
    * Declaration Part *
    tables: PERNR, PV000, T549Q, V_T514D, HRPY_RGDIR.
    infotypes: 0000, 0001, 0105, 0655.
    data: begin of ITAB occurs 0,
      MTEXT(25) type C,
      PERNR like PA0001-PERNR,
      ABKRS like PA0001-ABKRS,
      ENAME like PA0001-ENAME,
      USRID_LONG like PA0105-USRID_LONG,
    end of ITAB.
    data: W_BEGDA like HRPY_RGDIR-FPBEG,
          W_ENDDA like HRPY_RGDIR-FPEND.
    data: RETURN like BAPIRETURN1 occurs 0 with header line.
    data: P_INFO like PC407,
          P_FORM like PC408 occurs 0 with header line.
    data: P_IDX type I,
          MY_MONTH type T549Q-PABRP,
          STR_MY_MONTH(2) type C,
          MY_YEAR type T549Q-PABRJ,
          STR_MY_YEAR(4) type C,
          CRLF(2) type x value '0D0A'.
    data: W_CMONTH(10) type C.
    data: TAB_LINES type I,
          ATT_TYPE like SOODK-OBJTP.
    data: begin of P_INDEX occurs 0,
            INDEX type I,
    end of P_INDEX.
    constants: begin of F__LTYPE, "type of line
       CMD like PC408-LTYPE value '/:',  "command
       TXT like PC408-LTYPE value 's',   "textline
    end of F__LTYPE.
    constants: begin of F__CMD, "commands
      NEWPAGE like PC408-LINDA value '',
    end of F__CMD.
    data: P_LIST like ABAPLIST occurs 1 with header line.
    *data: OBJBIN like SOLISTI1 occurs 10 with header line,
    data: OBJBIN like  LVC_S_1022 occurs 10 with header line,
          DOCDATA like SODOCCHGI1,
          OBJTXT like SOLISTI1 occurs 10 with header line,
          OBJPACK like SOPCKLSTI1 occurs 1 with header line,
          RECLIST like SOMLRECI1 occurs 1 with header line,
          OBJHEAD like SOLISTI1 occurs 1 with header line,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_buffer type string,
          l_no_of_bytes TYPE i,
          l_pdf_spoolid LIKE tsp01-rqident,
          l_jobname     LIKE tbtcjob-jobname.
    data: file_length  type int4,
          spool_id     type rspoid,
          line_cnt     type i.
    *-------------------------------------------------------------------* * INITIALIZATION *
    OBJBIN = ' | '.
    append OBJBIN.
    OBJPACK-HEAD_START = 1.
    data: S_ABKRS like PV000-ABKRS.
    data: S_PABRP like T549Q-PABRP.
    data: S_PABRJ like T549Q-PABRJ.
    * SELECTION SCREEN                                                  *
    selection-screen begin of block BL1.
    parameters: PAY_VAR like BAPI7004-PAYSLIP_VARIANT default 'ESS_PAYSLIPS' obligatory.
    selection-screen end of block BL1.
    START-OF-SELECTION.
      s_ABKRS = PNPXABKR.
      S_PABRP = PNPPABRP.
      s_pabrj = PNPPABRJ.
      w_begda = PN-BEGDA.
      w_endda = PN-ENDDA.
    get pernr.
    *                                 "Check active employees
      rp-provide-from-last p0000 space pn-begda  pn-endda.
      CHECK P0000-STAT2 IN PNPSTAT2.
    *                                 "Check Payslip Mail flag
      rp-provide-from-last p0655 space pn-begda  pn-endda.
      CHECK P0655-ESSONLY = 'X'.
      rp-provide-from-last p0001 space pn-begda  pn-endda.
    *                                 "Find email address
      RP-PROVIDE-FROM-LAST P0105 '0030' PN-BEGDA PN-ENDDA.
      if p0105-usrid_LONG ne ''.
        ITAB-PERNR      = P0001-PERNR.
        ITAB-ABKRS      = P0001-ABKRS.
        ITAB-ENAME      = P0001-ENAME.
        ITAB-USRID_LONG = P0105-USRID_LONG.
        append itab.
        clear itab.
      endif.
      "SY-UCOMM ='ONLI'
    END-OF-SELECTION.
    *------------------------------------------------------------------* start-of-selection.
      write : / 'Payroll Area        : ', S_ABKRS.
      write : / 'Payroll Period/Year : ',STR_MY_MONTH,'-',STR_MY_YEAR. write : / 'System Date : ', SY-DATUM.
      write : / 'System Time         : ', SY-UZEIT.
      write : / 'User Name           : ', SY-UNAME.
      write : / SY-ULINE.
      sort ITAB by PERNR.
      loop at ITAB.
        clear : P_INFO, P_FORM, P_INDEX, P_LIST, OBJBIN, DOCDATA, OBJTXT, OBJPACK, RECLIST, TAB_LINES.
        refresh : P_FORM, P_INDEX, P_LIST, OBJBIN, OBJTXT, OBJPACK, RECLIST.
    *                                                  Retrieve Payroll results sequence number for this run
        select single * from HRPY_RGDIR where PERNR eq ITAB-PERNR
                                        and FPBEG ge W_BEGDA
                                        and FPEND le W_ENDDA
                                        and SRTZA eq 'A'.
    *                                                  Produce payslip for those payroll results
        if SY-SUBRC = 0.
          call function 'GET_PAYSLIP'
            EXPORTING
              EMPLOYEE_NUMBER = ITAB-PERNR
              SEQUENCE_NUMBER = HRPY_RGDIR-SEQNR
              PAYSLIP_VARIANT = PAY_VAR
            IMPORTING
              RETURN          = RETURN
              P_INFO          = P_INFO
            TABLES
              P_FORM          = P_FORM.
          check RETURN is initial.
    *                                                 remove linetype from generated payslip
          loop at p_form.
            objbin = p_form-linda.
            append objbin.
            line_cnt = line_cnt + 1.
          endloop.
          file_length = line_cnt * 1022.
    *                                                 create spool file of paylsip
          CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'
            EXPORTING
              i_file_length = file_length
            IMPORTING
              e_spoolid     = spool_id
            TABLES
              it_textdata   = objbin.
          IF sy-subrc EQ 0.
            WRITE spool_id.
          ENDIF.
          DESCRIBE table objbin.
          DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
          CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
            EXPORTING
              SRC_SPOOLID                    = spool_id
              NO_DIALOG                      = ' '
              DST_DEVICE                     = 'MAIL'
    *      PDF_DESTINATION                =
    *    IMPORTING
    *      PDF_BYTECOUNT                  = l_no_of_bytes
    *      PDF_SPOOLID                    = l_pdf_spoolid
    *      LIST_PAGECOUNT                 =
    *      BTC_JOBNAME                    =
    *      BTC_JOBCOUNT                   =
            TABLES
              PDF                            = 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
          IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    *Download PDF file C Drive
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename = 'C:\itab_to_pdf.pdf'
          filetype = 'BIN'
        TABLES
          data_tab = pdf.
    * Transfer the 132-long strings to 255-long strings
    *  LOOP AT pdf.
    *    TRANSLATE pdf USING ' ~'.
    *    CONCATENATE gd_buffer pdf 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.
          OBJHEAD = 'Objhead'.
          append OBJHEAD.
    * preparing email subject
          concatenate W_ENDDA(6)
                    ' Payslip-'
                    ITAB-ENAME+0(28)
                    ITAB-PERNR+4(4) ')'
                 into DOCDATA-OBJ_DESCR.
          DOCDATA-OBJ_NAME = 'Pay Slip'.
          DOCDATA-OBJ_LANGU = SY-LANGU.
          OBJTXT = 'Pay Slip.'.
          append OBJTXT.
    *prepare email lines
          OBJTXT = DOCDATA-OBJ_DESCR.
          append OBJTXT.
          OBJTXT = 'Please find enclosed your current payslip.'.
          append OBJTXT.
    * Write Attachment(Main)
    * 3 has been fixed because OBJTXT has fix three lines
          read table OBJTXT index 3.
    *    DOCDATA-DOC_SIZE = ( 3 - 1 ) * 255 + strlen( OBJTXT ).
          clear OBJPACK-TRANSF_BIN.
          OBJPACK-HEAD_START = 1.
          OBJPACK-HEAD_NUM = 0.
          OBJPACK-BODY_START = 1.
          OBJPACK-BODY_NUM = 3.
          OBJPACK-DOC_TYPE = 'RAW'.
          append OBJPACK.
    * Create Message Attachment
          ATT_TYPE = 'PDF'.
          describe table OBJBIN lines TAB_LINES.
          read table OBJBIN index TAB_LINES.
    *    OBJPACK-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).
          OBJPACK-TRANSF_BIN = 'X'.
          OBJPACK-HEAD_START = 1.
          OBJPACK-HEAD_NUM = 0.
          OBJPACK-BODY_START = 1.
          OBJPACK-BODY_NUM = TAB_LINES.
          OBJPACK-DOC_TYPE = ATT_TYPE.
          OBJPACK-OBJ_NAME = 'ATTACHMENT'.
          OBJPACK-OBJ_DESCR = 'Payslip'.
          append OBJPACK.
    * Create receiver list refresh RECLIST.
          clear RECLIST.
          RECLIST-RECEIVER = itab-USRID_long.
          translate RECLIST-RECEIVER to lower case.
          RECLIST-REC_TYPE = 'U'.
          append RECLIST.
    * Send the document
    *SO_NEW_DOCUMENT_ATT_SEND_API1
          call function 'SO_DOCUMENT_SEND_API1'
            exporting
              DOCUMENT_DATA = DOCDATA
              PUT_IN_OUTBOX = 'X'
              COMMIT_WORK = 'X'
    * IMPORTING
    *   SENT_TO_ALL =
    *   NEW_OBJECT_ID =
            tables
              PACKING_LIST  = OBJPACK
              OBJECT_HEADER = OBJHEAD
              CONTENTS_BIN  = pdf
              CONTENTS_TXT  = OBJTXT
    *   CONTENTS_HEX =
    *   OBJECT_PARA =
    *   OBJECT_PARB =
              RECEIVERS = RECLIST
            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.
          if SY-SUBRC NE 0.
            ITAB-MTEXT = 'Message Not Sent to : '.
          else.
            ITAB-MTEXT = 'Message Sent to : '.
          endif.
    *    else.
    *      ITAB-MTEXT = 'Message Not Sent to : '.
    *    endif.
        else.
          "SY-SUBRC Not = 0
          ITAB-MTEXT = 'Payroll data not found : '.
        endif.
        "end of SY-SUBRC = 0.
        modify ITAB.
      endloop. "end loop at ITAB
      sort ITAB by MTEXT PERNR.
      loop at ITAB.
        at new MTEXT.
          uline.
          write : / ITAB-MTEXT color 4 intensified on.
          write : / 'Emp. Code' color 2 intensified on,
                 12 'Emp. Name' color 2 intensified on,
                 54 'Email ID' color 2 intensified on.
        endat.
        write : / ITAB-PERNR, 12 ITAB-ENAME, 54 ITAB-USRID_LONG.
      endloop.

  • ALV report display online and generate in spool

    Dear expert,
    I have created an ALV report. I want to run this report online. After executed, the report is displayed. After display this report, I also want to generate the output report in the spool. Is there any way to do this? Thank you.
    I have tried to use submit...to SAP Spool. in this way, it will generate the spool, but it will not display the report online. I want it both display online and generate a spool.

    well forget yout the new-page print on thingie, since you use ALV.
    if you had a write list this trick would be cool since you just could do following:
    Do 2 times.
      if sy-index GT 1.
        new page print on.
      endif.
      loop at itab into wa.
        write stuff....
      endloop.
      if sy-index GT 1.
        new page print off.
      endif.
    enddo.
    /edit arrrgh forgot to write further...
    with your ALV you could process a write list as well after displaying but you will have layout differences between your display and your spool then and i dont think that this is what you want/need.
    you could however after display process your programm a second time, in background task and give it a printer where to print to. Since ALV wont get executed in background task you will get a spool instead.
    Edited by: Florian Kemmer on Sep 15, 2010 2:40 PM

  • How to send a list to spool?

    Dear Friend,
    I made a banking payment system program,right now i have to send directly a list of document to spool,how can I do it?
    I got one function module also,but i don't knoe the number of parameters should be pass...........
    so pleases suggest me best way to ccomlish my Requirment
    Thanks & Regards
    Ricky

    Hi Ricky,
    Check the below code.It creates spool on execution.
    Go through this piece of code and try to implement it for your requirement.
    REPORT  ZTEST.                              .
    tables: usr01.
    perform send_report_to_spool.
    form send_report_to_spool.
      data: loc_dest like pri_params-pdest,
            wf_listname type char12,
            wf_listtext like PRI_PARAMS-PRTXT,
            wf_copies type i,
            wf_days type i,
            wf_PARAMS LIKE PRI_PARAMS,     " achieving file PRI_PARAMS.
            wf_valid type c.
      clear : wf_listname , loc_dest , wf_listtext .
      move: 'AP interface' to   wf_listname .
      move: 'AP interface' to   wf_listtext .
    select single spld into usr01-spld from usr01 where bname eq sy-uname .
      if sy-subrc eq 0 .
        move: usr01-spld to loc_dest .
      endif .
      call function 'GET_PRINT_PARAMETERS'
        EXPORTING
          destination    = loc_dest
          copies         = 1
          list_name      = wf_listname
          list_text      = wf_listtext
          immediately    = ' '
          release        = ' '
          new_list_id    = 'X'
          expiration     = 1
          line_size      = 200
          line_count     = 65
          layout         = 'X_65_200'
          sap_cover_page = 'X'
          receiver       = 'SAP*'
          department     = ''
          no_dialog      = 'X'
        IMPORTING
          out_parameters = wf_params
          valid          = wf_valid.
      if wf_valid <> space.
        new-page print on parameters wf_params no dialog.
        perform write_summary .
        new-page print off.
      endif .
    endform.                    "send_report_to_spool
    FORM write_summary .
    data: begin of itab occurs 0,
          matnr type matnr,
          end of itab.
    select matnr
           from mara
           into table itab
           up to 10 rows.
    loop at itab.
    write: / itab-matnr.
    endloop.
    ENDFORM.                    " write_summary

  • Spool is not generating.

    Hi everyone,
    I am scheduling a report in background and tracking it in SM37 then Job finishes with no spool.
    So may I know what are the potential reasons behind it.
    Is it Users Id related as spools are generating perfectly for some User Id's.
    Or is there a problem in printer settings.
    Your quick response is highly  appreciated in order to trouble shoot it.
    Thanks.
    Sudhanshu

    Hi,
    Check out the following code sample to create spool withing program.
    data: loc_dest like pri_params-pdest .
      clear : wf_listname , loc_dest , wf_listtext .
      move: 'List name' to   wf_listname .
      move: 'List header text' to   wf_listtext .
    select single spld into usr01-spld from usr01 where bname eq sy-uname .
      if sy-subrc eq 0 .
        move: usr01-spld to loc_dest .
      endif .
      call function 'GET_PRINT_PARAMETERS'
           exporting
                destination    = loc_dest
                copies         = wf_copies
                list_name      = wf_listname
                list_text      = wf_listtext
                immediately    = ' '
                release        = ' '
                new_list_id    = 'X'
                expiration     = wf_days
                line_size      = 200
                line_count     = 65
                layout         = 'X_65_200'
                sap_cover_page = 'X'
                receiver       = 'SAP*'
                department     = ''
                no_dialog      = 'X'
           importing
                out_parameters = wf_params
                valid          = wf_valid.
      if wf_valid <> space.
        new-page print on parameters wf_params no dialog.
        perform write_summary .
        new-page print off.
      endif .
    within the write_summary do a normal write operation.
    loop at <itab> .
    write:/
    endloop .
    Thanks.

  • Create Spool from Internal table & converrt the spool to PDF

    Hi All,
    My requirement is take data from a table and find amount specific to each Vendors . So I took all the data into ITAB and do all the calculation. Later after calculation I have to create a spool from this ITAB and this spool have to convert to PDF. Later this PDF have to seend via email.
    To convert the internal table to Spool , I used
    LOOP AT t_summ INTO wa_summ.
        w-amount = wa_summ-remittanceamount.
        CONCATENATE wa_summ-vendorcode
                    wa_summ-controlnum
                    w-amount INTO wa_textdata SEPARATED BY space.
        APPEND wa_textdata TO t_textdata.
      ENDLOOP.
      DESCRIBE TABLE t_textdata .
      w-file_length = syst-tfill * 1022.
      l_doctype = 'LIST'.
      l_layout = 'X_POSTSCRIPT'.
      CONCATENATE ' Listbill Summary Report for' syst-datum INTO
                          l_title SEPARATED BY space.
      l_receiver = syst-uname.
    * Create Spool
      CALL FUNCTION 'RSPO_SR_OPEN'
       EXPORTING
          dest                   = 'LOCL'
    *   LDEST                  =
          layout                 = l_layout
          name                   = 'SUMREP'
    *   SUFFIX1                =
    *   SUFFIX2                =
       copies                 = '1'
    *   PRIO                   =
    *      immediate_print        = ' '
    *   AUTO_DELETE            =
          titleline              = l_title
          receiver               = syst-uname           "
    *      division               = l_pri_params-prabt " abteilung
    *      authority              = l_pri_params-prber           "
    *   POSNAME                =
    *   ACTTIME                =
    *   LIFETIME               = '8'
    *   APPEND                 =
    *   COVERPAGE              =
    *   CODEPAGE               =
          doctype                = l_doctype
    *   ARCHMODE               =
    *   ARCHPARAMS             =
    *   TELELAND               =
    *   TELENUM                =
    *   TELENUME               =
         IMPORTING
          handle                 = l_spool_handle
          spoolid                = w-spoolid
    EXCEPTIONS
       device_missing         = 1
       name_twice             = 2
       no_such_device         = 3
       operation_failed       = 4
       OTHERS                 = 5
                .                                            "#EC DOM_EQUAL
      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 'SLVC_C1022_TO_C255'
        EXPORTING
          i_file_length = w-file_length
        TABLES
          it_c1022      = t_textdata
          et_c255       = lt_spool.
      l_length = w-file_length.
      LOOP AT lt_spool INTO ls_spool.
        l_length = l_length - 255.
        IF ( l_length > 0 ).
          l_line_length = 255.
        ELSE.
          l_line_length = l_length + 255.
        ENDIF.
    *   Write contents to spool
        CALL FUNCTION 'RSPO_SR_WRITE'
          EXPORTING
            handle = l_spool_handle
            text   = ls_spool
            length = l_line_length.
      ENDLOOP.
    * Close Spool
      CALL FUNCTION 'RSPO_SR_CLOSE'
        EXPORTING
          handle                 = l_spool_handle
         pages                  = 1
      FINAL                  = 'X'
       EXCEPTIONS
         handle_not_valid       = 1
         operation_failed       = 2
         OTHERS                 = 3
    By this I can see the spool with data in SP02.
    Then to conver to PDF, I used
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
        EXPORTING
          src_spoolid                    = w-spoolid
          no_dialog                      = 'X'
          DST_DEVICE                     = 'LOCL'
    *      PDF_DESTINATION                =
        IMPORTING
    *      PDF_BYTECOUNT                  =
    *      PDF_SPOOLID                    =
          list_pagecount                 = list_pagecount
    *      BTC_JOBNAME                    =
    *      BTC_JOBCOUNT                   =
       TABLES
         pdf                            = t_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
      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 'GUI_DOWNLOAD'
        EXPORTING
    *   BIN_FILESIZE                    =
          filename                        = 'D:\t\t.pdf'
         filetype                        = 'BIN'
        TABLES
          data_tab                        = t_pdf
    *   FIELDNAMES                      =
       EXCEPTIONS
         file_write_error                = 1
         no_batch                        = 2
         gui_refuse_filetransfer         = 3
         invalid_type                    = 4
         no_authority                    = 5
         unknown_error                   = 6
         header_not_allowed              = 7
         separator_not_allowed           = 8
         filesize_not_allowed            = 9
         header_too_long                 = 10
         dp_error_create                 = 11
         dp_error_send                   = 12
         dp_error_write                  = 13
         unknown_dp_error                = 14
         access_denied                   = 15
         dp_out_of_memory                = 16
         disk_full                       = 17
         dp_timeout                      = 18
         file_not_found                  = 19
         dataprovider_exception          = 20
         control_flush_error             = 21
         OTHERS                          = 22
    But later when I go and open the PDF, I am getting an error saying'Page cannot be open because it dont have any pages'
    Please help me
    Regards,
    Nikhil

    Hi Nikhil,
    <li>If you are still not able to find out the problem. You can an alternative way , which is used for the same purpose.
    <li>Try this way. It creates spool and and same CONVERT_ABAPSPOOLJOB_2_PDF fm is used to convert spool to PDF. It works. Test this test program.
       REPORT ztest_notepad.
       DATA:g_val         TYPE c,
            w_pripar      TYPE pri_params,
            w_arcpar      TYPE arc_params,
            i_pdf         TYPE TABLE OF tline,
            spoolid       LIKE tsp01-rqident,
            l_no_of_bytes TYPE i,
            l_pdf_spoolid LIKE tsp01-rqident,
            l_jobname     LIKE tbtcjob-jobname,
            l_jobcount    LIKE tbtcjob-jobcount.
       DATA:it_t001 TYPE TABLE OF t001 WITH HEADER LINE.
       START-OF-SELECTION.
         SELECT * FROM t001 INTO TABLE it_t001.
         "Read, determine, change spool print parameters and archive parameters
         CALL FUNCTION 'GET_PRINT_PARAMETERS'
           EXPORTING
             in_archive_parameters  = w_arcpar
             in_parameters          = w_pripar
             layout                 = 'X_65_132'
             line_count             = 65
             line_size              = 132
             no_dialog              = 'X'
           IMPORTING
             out_archive_parameters = w_arcpar
             out_parameters         = w_pripar
             valid                  = g_val.
         IF g_val  NE space AND sy-subrc = 0.
           w_pripar-prrel = space.
           w_pripar-primm = space.
           NEW-PAGE PRINT ON  NEW-SECTION PARAMETERS w_pripar ARCHIVE PARAMETERS w_arcpar NO DIALOG.
         ENDIF.
         LOOP AT it_t001.
           WRITE:/ it_t001.
         ENDLOOP.
         NEW-PAGE PRINT OFF.
         CALL FUNCTION 'ABAP4_COMMIT_WORK'.
         spoolid = sy-spono.
         CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
             src_spoolid   = spoolid
             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.
         CALL FUNCTION 'GUI_DOWNLOAD'
           EXPORTING
             filename = 'C:\temp\test.pdf'
             filetype = 'BIN'
           TABLES
             data_tab = i_pdf.
    Thanks
    Venkat.

  • Transfer ITAB contents to PDF format

    Hi,
    I want to transfer ITAB contents to PDF.format. For this iam following above steps:
    (Note: my output in Z-report1 is in classical format and year wise but in output it contain all 12 moths data so i want to generate new PDF file for each month separately if i run this report in background then it will generate only one spool request for all 12 months)
    1) Z- report through which iam transferring ITAB comtents to memory ID.
    2) then through SUBMIT iam calling new Z-report1.
    3) then iam importing ITAB content to Z-report1.
    4) Now to get the Spool no i want to execute Z-report1 in background (automatically it should run in background because iam calling Z-report1 in Z-report).
    SO is there any function module so that i can pass report name (Z-report1) and it will run in background
    Please help.
    Thanks .
    Regards.
    Hemant.

    You can submit a program via job. Check the F1 help on submit button.
    I'm doing something similar :
    Here is the code snippet for submitting the program and getting the spool request.
      SUBMIT (gwa_rkb1d-rname) TO SAP-SPOOL COVER TEXT t_stamp
      WITHOUT SPOOL DYNPRO IMMEDIATELY flag KEEP IN SPOOL flag_kisp
      WITH    SELECTION-TABLE seltab   USING SELECTION-SET p_vari
      AND RETURN.
      SELECT SINGLE *
        INTO t_tsp01
        FROM tsp01
        WHERE rqfinal   IN ('.','X')
        AND   rqclient  = sy-mandt
        AND   rqowner   = sy-uname
        AND   rqtitle   = t_stamp.
      IF sy-subrc = 0.
        CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
          EXPORTING
            rqident              = t_tsp01-rqident
          TABLES
            buffer               = buffer
          EXCEPTIONS
            no_such_job          = 1
            not_abap_list        = 2
            job_contains_no_data = 3
            selection_empty      = 4
            no_permission        = 5
            can_not_access       = 6
            read_error           = 7
            OTHERS               = 8.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      ENDIF.
    Also Job_open, job_submit and Job_close functions can be used.
    regards,
    Advait

  • Making spool, convert it into PDF and send that PDf throgh EMAIl

    Hi,
    In my making ALV report. In that i want to make the spool  and then convert it into the pdf and send mail to the recepient.
    Atul

    Hi,
    please try the following code. It works for me.
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    DATA : path LIKE pcfile-path.
    DATA : extension(5) TYPE c.
    DATA : name(100) TYPE c.
    DATA:receiver TYPE somlreci1-receiver  ,
         p_file   LIKE rlgrap-filename.
    declarations for PDF convertion
    DATA:  path1       TYPE string ,
           fullpath    TYPE string.
    DATA :textlines LIKE tline OCCURS 100 WITH HEADER LINE.
    DATA otf LIKE itcoo OCCURS 1000 WITH HEADER LINE.
    DATA it_lines LIKE tline OCCURS 100 WITH HEADER LINE.
    DATA options LIKE itcpo.
    DATA header LIKE thead.
    DATA result     LIKE     itcpp.
    DATA: bin_filesize TYPE i.
        fullpath type string.
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    DATA: filesize TYPE i,
          convcount TYPE i,
          cancel(1).
    textlines-tdformat = '*'.
    textlines-tdline    = 'Hello Hao'.
    APPEND textlines.
    options-tdgetotf = 'X'.
    options-tdnoprev = 'X'.
    CALL FUNCTION 'PRINT_TEXT'
      EXPORTING
      APPLICATION                    = 'TX'
      ARCHIVE_INDEX                  = ' '
      ARCHIVE_PARAMS                 = ' '
      DEVICE                         = 'PRINTER'
       dialog                         = ' '
        header                         = header
       OPTIONS                        = options
    IMPORTING
      NEW_ARCHIVE_PARAMS             =
       RESULT                         = RESULT
      tables
        lines                          =  textlines
       otfdata                        = otf
    EXCEPTIONS
      CANCELED                       = 1
      DEVICE                         = 2
      FORM                           = 3
      OPTIONS                        = 4
      UNCLOSED                       = 5
      UNKNOWN                        = 6
      FORMAT                         = 7
      TEXTFORMAT                     = 8
      COMMUNICATION                  = 9
      BAD_PAGEFORMAT_FOR_PRINT       = 10
      OTHERS                         = 11
    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 'CONVERT_OTF'
         EXPORTING
              format            = 'PDF'
         IMPORTING
              bin_filesize      = filesize
         TABLES
              otf               = otf
              lines             = it_lines
         EXCEPTIONS
              err_conv_not_possible = 1
              err_bad_otf           = 2.
    fullpath = 'C:/foldername/test.pdf'.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        bin_filesize                  = bin_filesize
        filename                      = fullpath
        filetype                      = 'BIN'
      APPEND                        = ' '
      CODEPAGE                      = ' '
      NO_BYTEORDER_MARK             = ' '
    IMPORTING
       FILELENGTH                    = c
      TABLES
        data_tab                      = it_lines
      FORMAT_TAB                    =
      EXCEPTIONS
        file_write_error              = 1
        no_batch                      = 2
        gui_refuse_filetransfer       = 3
        invalid_type                  = 4
        no_authority                  = 5
        unknown_error                 = 6.
    *filename = fullpath.
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    Set Variables
    docdata-obj_name = 'Tst'.
    docdata-obj_descr = 'Testing'.
    reclist-receiver = give the mail id.
    reclist-rec_type = 'U'.
    APPEND reclist.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = fullpath
          filetype                = 'BIN'
        TABLES
          data_tab                = itab
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
      path = fullpath.
      CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
      EXPORTING
      complete_filename = path
    CHECK_DOS_FORMAT =
      IMPORTING
    DRIVE =
      extension = extension
      name = name
    NAME_WITH_EXT =
    PATH =
      EXCEPTIONS
      invalid_drive = 1
      invalid_extension = 2
      invalid_name = 3
      invalid_path = 4
      OTHERS = 5
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT itab.
    pos = 255 - len.
    IF pos > 134.                         "length of pdf_table
    pos = 134.
    ENDIF.
    objbin+len = itab(pos).
    len = len + pos.
    IF len = 255.                         "length of out (contents_bin)
    APPEND objbin.
    CLEAR: objbin, len.
    IF pos < 134.
    objbin = itab+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND objbin.
    ENDIF.
    Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    name = extension.
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = name.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = name.
    APPEND objpack.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    receivers = reclist
    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
    IF sy-subrc <> 0.
    MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    Keerthi

  • Creating Spool request

    Hi friends,
    as per the old message I am trying to create a spool request which further will be downloaded to PDF format. I am facing a problem, as per message  when I try to do write in worte_perform I am receving ABAP dumps with Illegal page number
    anyidea why is it so .
    Thanks
    Lakhbir
    data: loc_dest like pri_params-pdest .
      clear : wf_listname , loc_dest , wf_listtext .
      move: 'List name' to   wf_listname .
      move: 'List header text' to   wf_listtext .
    select single spld into usr01-spld from usr01 where bname eq sy-uname .
      if sy-subrc eq 0 .
        move: usr01-spld to loc_dest .
      endif .
      call function 'GET_PRINT_PARAMETERS'
           exporting
                destination    = loc_dest
                copies         = wf_copies
                list_name      = wf_listname
                list_text      = wf_listtext
                immediately    = ' '
                release        = ' '
                new_list_id    = 'X'
                expiration     = wf_days
                line_size      = 200
                line_count     = 65
                layout         = 'X_65_200'
                sap_cover_page = 'X'
                receiver       = 'SAP*'
                department     = ''
                no_dialog      = 'X'
           importing
                out_parameters = wf_params
                valid          = wf_valid.
      if wf_valid <> space.
        new-page print on parameters wf_params no dialog.
        perform write_summary .
        new-page print off.
      endif .
    within the write_summary do a normal write operation.
    loop at <itab> .
    write:/
    endloop .

    We encountered a similar problem on 4.6C using a custom BAPI to save invoices to PDF for an internal web app.  We used a BDC/call transaction to access the output function from there.  This was only supposed to be a temporary workaround but has been working and we probably won't revisit until our next upgrade.  Hopefully this idea will help on your version, if so I am new here and need points!
    *Generate Transaction
      PERFORM dynpro USING :
                     'X' 'SAPMV60A'   '0101'   ,
                     ' ' 'VBRK-VBELN' v_invoice ,
                     ' ' 'BDC_OKCODE' '=DRCK'   .
      PERFORM dynpro USING :
                     'X' 'SAPLVMSG'   '0110'   ,
                     ' ' 'DNAST-KSCHL' v_kschl,
                     ' ' 'BDC_OKCODE' '=STAR'   .
      SELECT * UP TO 1 ROWS
        FROM nast WHERE objky = v_invoice
                  AND   vstat = '1'
                  AND   kappl = 'V3'
                  AND   kschl = v_kschl
                  AND   aktiv = space.
      ENDSELECT.
      IF sy-subrc = 0.
        PERFORM dynpro USING :
                       'X' 'SAPLSPO1'   '0300'   ,
                       ' ' 'BDC_OKCODE' '=YES'   .
      ENDIF.
      PERFORM dynpro USING :
                     'X' 'SAPLVMSG'   '0100'   ,
                     ' ' 'NAST-LDEST' 'TD06',
                     ' ' 'NAST-DIMME'  space,
                     ' ' 'NAST-TDOCOVER' space,
                     ' ' 'NAST-TDRECEIVER' space,
                     ' ' 'NAST-DELET' 'X',
                     ' ' 'BDC_OKCODE' '=STAR'   .
      CALL TRANSACTION   'VF03'
           USING         i_bdcdata
           MODE          v_mode
           UPDATE        'S'
           MESSAGES INTO i_bdcmsgcoll.

  • How to get the spool id or how to create a spool id for the report .

    hi,
    how to get the spool id or how to create a spool id for the report .
    this spool id i have to use it in CONVERT_ABAPSPOOLJOB_2_PDF fm to get the pdf download file.
    my requirement is to download a pdf file from the alv grid list.

    Hi Raghu,
    Execute this program.
    REPORT  ZTEST_3318                              .
    tables: usr01.
    perform send_report_to_spool.
    *&      Form  send_report_to_spool
          text
    form send_report_to_spool.
      data: loc_dest like pri_params-pdest,
            wf_listname type char12,
            wf_listtext like PRI_PARAMS-PRTXT,
            wf_copies type i,
            wf_days type i,
            wf_PARAMS LIKE PRI_PARAMS,     " achieving file PRI_PARAMS.
            wf_valid type c.
      clear : wf_listname , loc_dest , wf_listtext .
      move: 'AP interface' to   wf_listname .
      move: 'AP interface' to   wf_listtext .
    select single spld into usr01-spld from usr01 where bname eq sy-uname .
      if sy-subrc eq 0 .
        move: usr01-spld to loc_dest .
      endif .
      call function 'GET_PRINT_PARAMETERS'
        EXPORTING
          destination    = loc_dest
          copies         = 1
          list_name      = wf_listname
          list_text      = wf_listtext
          immediately    = ' '
          release        = ' '
          new_list_id    = 'X'
          expiration     = 1
          line_size      = 200
          line_count     = 65
          layout         = 'X_65_200'
          sap_cover_page = 'X'
          receiver       = 'SAP*'
          department     = ''
          no_dialog      = 'X'
        IMPORTING
          out_parameters = wf_params
          valid          = wf_valid.
      if wf_valid <> space.
        new-page print on parameters wf_params no dialog.
        perform write_summary .
        new-page print off.
      endif .
    endform.                    "send_report_to_spool
    *&      Form  write_summary
          text
    -->  p1        text
    <--  p2        text
    FORM write_summary .
    data: begin of itab occurs 0,
          matnr type matnr,
          end of itab.
    select matnr
           from mara
           into table itab
           up to 10 rows.
    loop at itab.
    write: / itab-matnr.
    endloop.
    ENDFORM.                    " write_summary
    This will create spool in SP01.What data you want to put in Spool write it in form write_summary.I have done coding for testing purpose
    After that use that spool for your purpose.
    If Useful award point

  • Create Spool From OTF Data

    Hi all,
    Is there any way of creating a spool request or printing OTF data directly from an internal table.
    Scenario is that I have read a spool request with multiple pages into OTF format and now have an internal table with OTF data. I have then split the spool data at page level into another internal table.
    This table also contains OTF data . Is there anyway of printing this internal table directly to printer. If not is there any way of creating a spool request from this internal table?
    Regards,
    Preet

    May be i can help to some extent. I will just tell you how to convert a internal table into spool. I have done the coding
    REPORT  zpmm_pdf                                .
    TYPES : BEGIN OF itab,
            name(20) TYPE c,
            age TYPE i,
            *** TYPE c,
            END OF itab.
    DATA : gt_itab TYPE STANDARD TABLE OF itab,
           gw_itab TYPE itab.
    DATA : counter  TYPE i.
    ********************Data declaration for use in converting to pdf
    DATA : pripar LIKE pri_params.
    DATA : lw_space VALUE ''.
    DATA : itab_pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    <b>*To get spool info</b>
    DATA : rqident LIKE tsp01-rqident ,
           rqcretime LIKE tsp01-rqcretime .
    <b>DATA: spool_id LIKE tsp01-rqident.</b>
    DATA : numbytes TYPE i,
           cancel.
    DATA : gv_filename LIKE rlgrap-filename VALUE 'C:\swet.pdf'.
    ********************END of Data declaration for use in converting to pdf
                           START-OF-SELECTION
    DO 20 TIMES.
      gw_itab-name = 'swetabh_shukla'.
      gw_itab-age = counter + 1.
      gw_itab-***  = 'M'.
      counter = counter + 1.
      APPEND gw_itab TO gt_itab.
      CLEAR : gw_itab.
    ENDDO.
    <b>* Gt_itab is the internal table that we will write to spool</b>
    *Start
    SET PARAMETER ID 'ZPDF' FIELD lw_space.
    <b>CALL FUNCTION 'GET_PRINT_PARAMETERS'</b>
      EXPORTING
        in_parameters          = pripar
        line_size              = 255
        layout                 = 'X_65_132'
        no_dialog              = 'X'
      IMPORTING
        out_parameters         = pripar
      EXCEPTIONS
        archive_info_not_found = 1
        invalid_print_params   = 2
        invalid_archive_params = 3
        OTHERS                 = 4.
    <b>*********To write data in spool</b>
    NEW-PAGE PRINT ON PARAMETERS pripar NO DIALOG .
    RESERVE 5 LINES.
    <b>*********From here data will be written in spool</b>
    WRITE : 'Name',
            'Age',
    LOOP AT gt_itab INTO gw_itab.
      WRITE : / gw_itab-name,
                gw_itab-age,
                gw_itab-***.
    ENDLOOP.
    <b>*****To switch off spool writing</b>
    NEW-PAGE PRINT OFF.
    ************End of spool writing
    <b>******To get the latest spool id of spool written by us</b>
    SELECT  rqident  rqcretime FROM tsp01
                 INTO (rqident,rqcretime)
                 WHERE rqowner = sy-uname
                 ORDER BY rqcretime DESCENDING.
      EXIT.
    <b>********  It will just read the latest spool id and exit</b>
    ENDSELECT.
    MOVE  rqident TO spool_id. <b>" We get the spool id here of the spool we wrote</b>
    <b>*Now  spool_id contains the spool id. We can convert this spool to pdf also as given *below</b>
    ****************************************************To convert spool to pdf
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
             src_spoolid = spool_id
          NO_DIALOG =
          DST_DEVICE =
          PDF_DESTINATION =
          IMPORTING
             pdf_bytecount = numbytes
          PDF_SPOOLID =
          LIST_PAGECOUNT =
          BTC_JOBNAME =
          BTC_JOBCOUNT =
           TABLES
             pdf = itab_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.
                           END-OF-SELECTION
    To download the pdf file as local file
    CALL FUNCTION 'DOWNLOAD'
               EXPORTING
                    bin_filesize     = numbytes
                    filename         = gv_filename
                    filetype         = 'BIN'
                    filetype_no_show = 'X'
               IMPORTING
                    act_filename     = gv_filename
                    filesize         = numbytes
                    cancel           = cancel
               TABLES
                    data_tab         = itab_pdf.
    <b> I think i gave a lot of extra code, but i just gave it for proper understanding.
    Only a few days ago i came across this concept. So had the ready made code.</b>
    <b>Please do reward point if helpful</b>
    Regards
    swetabh

Maybe you are looking for