Urgent spool to pdf

Hi Experts,
I have an output with checkboxes and spoolnumber,Descrip,date, etc and i  have a user-command button 'click' and when i select the 1 checkbox or many checkboxes against the spoolnumbers in output, i need to pass the spoolnumber values against the checkboxes selected to another program rstxlpdft4..how i need to write the logic in user-command?

hi loop all the data where check box is clicked..
into an internal table then pass it to the program through the submit command ..

Similar Messages

  • 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

  • Regarding spool to pdf

    Hi All
    i have a doubt
    When i am converting my spool to pdf is working fine no issue
    but one thing i got is in my pdf doc after every some 32 char
    i am getting one space between my data.
    Can anyone tell me what can be the reason and how to rectify it. Its urgent.
    Points will be rewarded.
    Eg...
    As in address1
    its showing as add  ress1
    In Spool its coming fine.
    Is there anything like the conversion is done in line from some part of text and then rest?

    Hi,
    you are using paragraph format for address .
    in paragraph format check 3 check boxes it will work i think try it.

  • While converting spool to PDF marathi character shown as symbolic in PDF

    Hi guys,
    I have requirement to send payslip via mail.i have developed program everything working well.get payslip,create spool and convert spool to pdf is working well.But issue is while converting spool into PDF then marathi character display like special symbols in PDF (in payslip emp.name , emp location,designation,department are in Marathi).
    code as follow,
    CALL FUNCTION 'GET_PAYSLIP'
             EXPORTING
               EMPLOYEE_NUMBER = WA-PERNR
               SEQUENCE_NUMBER = WA_PC261-SEQNR
               PAYSLIP_VARIANT = FORMULAR                        " 'ZN01'
             IMPORTING
               RETURN          = RETURN
               P_INFO          = PINFO
             TABLES
               P_FORM          = PFORM.
           CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
            EXPORTING
                FORMNAME                 = 'ZHR_ESS_PAYSLIP_TO_PDF'
    *          VARIANT                  = ' '
    *          DIRECT_CALL              = ' '
           IMPORTING
                FM_NAME                  = FNAME.
    *     EXCEPTIONS
    *       NO_FORM                  = 1
    *       NO_FUNCTION_MODULE       = 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.
           SF_CONTROL_PARAMETERS-DEVICE = 'PRINTER'.
           SF_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
           SF_OUTPUT_OPTIONS-TDNEWID       = 'X'.
           SF_CONTROL_PARAMETERS-LANGU     = SY-LANGU.
           SF_OUTPUT_OPTIONS-TDDEST  = 'LP01'.
    *      SF_OUTPUT_OPTIONS-tdprinter = 'PDFUC'.
           CALL FUNCTION FNAME "'/1BCDWB/SF00000499'
             EXPORTING
    *     ARCHIVE_INDEX              =
    *    ARCHIVE_INDEX_TAB          =
    *   ARCHIVE_PARAMETERS         =
         CONTROL_PARAMETERS         = SF_CONTROL_PARAMETERS
    *    MAIL_APPL_OBJ              =
    *    MAIL_RECIPIENT             =
    *    MAIL_SENDER                =
         OUTPUT_OPTIONS             = SF_OUTPUT_OPTIONS
         USER_SETTINGS              = ''
               PINFO                      = PINFO
               PFORM                      = PFORM
            IMPORTING
    *    DOCUMENT_OUTPUT_INFO       =
               JOB_OUTPUT_INFO            = JOB_OUTPUT_INFO
    *    JOB_OUTPUT_OPTIONS         =
            EXCEPTIONS
              FORMATTING_ERROR           = 1
              INTERNAL_ERROR             = 2
              SEND_ERROR                 = 3
              USER_CANCELED              = 4
              OTHERS                     = 5
           IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
           ENDIF.
           IF JOB_OUTPUT_INFO-SPOOLIDS IS NOT INITIAL.
             LOOP AT JOB_OUTPUT_INFO-SPOOLIDS INTO LV_SPOOL.
               EXIT.
             ENDLOOP.
             REFRESH IT_TY_TAB_PDF.
             CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
               EXPORTING
                 SRC_SPOOLID              = LV_SPOOL
                 NO_DIALOG                = ' '
               TABLES
                 PDF                      = IT_TY_TAB_PDF
               EXCEPTIONS
                 ERR_NO_OTF_SPOOLJOB      = 1
                 ERR_NO_SPOOLJOB          = 2
                 ERR_NO_PERMISSION        = 3
                 ERR_CONV_NOT_POSSIBLE    = 4
                 ERR_BAD_DSTDEVICE        = 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.
             APPEND LINES OF IT_TY_TAB_PDF TO IT_TY_TAB_PDF1..
    Please guys help on this issue.its urgent.

    i am doing this...
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = l_spool_nr1
                no_dialog                = 'X'
                dst_device               = 'LOCL'
           IMPORTING
                pdf_bytecount            = l_bytecount
                LIST_PAGECOUNT           = l_page1
           TABLES
                pdf                      = itab_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.
    now l_bytecount stores the total number of bytes in the internal table itab_pdf_output. The value of this differs when i run in foreground nad background seperately

  • Smart form: Spool to PDF Conversion more than 100 pages.

    Hi folks,
    I have an issue with Function Module (FM) CONVERT_ABAPSPOOLJOB_2_PDF when the report to be converted has more than 100 pages.....i have explained this scenario as below
    We have been using the FM CONVERT_ABAPSPOOLJOB_2_PDF to convert ABAP report to PDF file and then send this via mail using FM SO_DOCUMENT_SEND_API1.....
    PDF conversion using FM CONVERT_ABAPSPOOLJOB_2_PDF works well if the number of report pages is less than 100....i.e the table pdf of the FM will contain the output as expected.....
    If the report has more than 100 pages, the the FM CONVERT_ABAPSPOOLJOB_2_PDF will schedule the conversion job as a background job and returns with a SY-subrc eq 0 and the table parameter pdf will ne empty.
    Could you suggest me a woorkaround in this situtaion...i.e how do I then get the output of the background job
    And  any process to convert Spool to PDF if having more than 100 pages.
    Thanks in Advance............

    Pb,
    If the report has more than 100 pages, the the FM CONVERT_ABAPSPOOLJOB_2_PDF will schedule the conversion job as a background job and returns with a SY-subrc eq 0 and the table parameter pdf will ne empty
    i would suggest you to if pages are more than 100 than you need to send report output to sp01 with spool request number by using fm job_open..job_close..
    than from sp01 you can convert pdf by running RSTXPDFT4 in se38.
    hope this would solve your problem.
    Amit.

  • Display logo In PDF output ( Spool to PDF output )

    Hi Experts,
    In my requirement i am using 'REUSE_ALV_GRID' to display logo.
    In our functionality we are executing report in background and we are converting spool into PDF output. Now our requirement is to display LOGO in PDF output.
    Any pointers on this are appreciated.
    Regards,
    Bhanu.R

    Hello,
    Use the top-of-page parameter of the FM 'REUSE_ALV_GRID_DISPLAY' and use the FM REUSE_ALV_COMMENTARY_WRITE to add the logo to the I_LOGO export parameter to get the logo in the ALV output. Now convert this to spool and to pdf and you can get the logo in the pdf as well
    Vikranth

  • 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.

  • Convert spool to pdf and send in email sometimes attachment duplicated.

    Hi all, I have a process that creates a spool, converts it to a pdf and then attaches it to an email. My problem is that sometimes, the same attachment is duplicated.
    The process seems to work fine in debug mode (the attachment changes for each loop) but when I run it in the background, every few emails, it will duplicate an attachment.
    I have noticed that the size of the pdf seems to change properly but that the content of the pdf does not match.  So, it is like it gets the correct size of the pdf but not the body.
    This is code that a consultant wrote and I am pretty new to abap/sap. I have changed some of the code because it was trying to handle an endless loop (I figured it should not have to handle (be in) an endless loop). I changed that code and it is working but this previous issue still exists. Thanks for your help.
    *&      Form  PROCESS_EMPLOYEE
    FORM process_employee .
    * process appraisal only
      IF it_final[] IS NOT INITIAL .
    *                READ DISTRIBUTION LIST                                *
        REFRESH : it_email, it_idlient. 
    *Sort by supervisor
        SORT it_final[] BY supervisor.
        LOOP AT it_final INTO wa_final .
          APPEND wa_final TO it_final1 .
          AT END OF supervisor .
    * Perform to create the PDF from the Output
           report = 'zhr_pm_appemail'.
           PERFORM create_pdf using report.
    ** Perform to email the PDF attachment
    ** to the supervisor and the Mailing list
            subject = 'Performance Appraisals'.
            PERFORM process_email using subject.
            REFRESH it_final1 .
            CLEAR it_final1 .
            CLEAR wa_final .
            FREE MEMORY ID 'MEM'.
          ENDAT .
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " PROCESS_EMPLOYEE
    *&      Form  CREATE_PDF
    FORM create_pdf using report.
      DATA:  spoolno TYPE tsp01-rqident.
      DATA : p_repid TYPE sy-repid .
      DATA: v_len  TYPE i , v_len1  TYPE i .
      DATA: v_temp(8) TYPE c .
      DATA: p_uname TYPE sy-uname .
      DATA: it_tsp01 TYPE STANDARD TABLE OF tsp01 WITH HEADER LINE .
    *  DATA: it_pdf TYPE tline OCCURS 0 WITH HEADER LINE .
      TABLES: tsp01.
      DATA: var  TYPE c .
    *-- STRUCTURES
      DATA:
        lc_rq2name TYPE tsp01-rq2name.
      DATA:
        mstr_print_parms TYPE pri_params,
        mc_valid(1)      TYPE c,
        mi_bytecount     TYPE i,
        mi_length        TYPE i,
        mi_rqident       TYPE tsp01-rqident.
    *-- INTERNAL TABLES
      DATA:
        mtab_pdf    TYPE tline OCCURS 0 WITH HEADER LINE,
        mc_filename TYPE rlgrap-filename.
    *-- SELECTION SCREEN
      DATA:
        p_linsz TYPE sy-linsz VALUE 80, " Line size
        p_paart TYPE sy-paart VALUE 'X_65_80'.  " Paper Format
        p_uname = sy-uname .
        var = var + 1.
        p_repid = report.
    * START-OF-SELECTION .
      concatenate p_repid+0(9)
                  p_uname+0(3)
            into mc_filename
       separated by '_'.
    translate mc_filename to upper case.
    *-- Setup the Print Parmaters
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING
          authority              = space
          copies                 = '1'
          cover_page             = space
          data_set               = space
          department             = space
          destination            = space
          expiration             = '1'
          immediately            = space
          new_list_id            = 'X'
          no_dialog              = 'X'
          user                   = sy-uname
        IMPORTING
          out_parameters         = mstr_print_parms
          valid                  = mc_valid
        EXCEPTIONS
          archive_info_not_found = 1
          invalid_print_params   = 2
          invalid_archive_params = 3
          OTHERS                 = 4.
    IF sy-subrc = 0 .
    *--Make sure that a printer destination has been set up. If this is not done the PDF module abends.
    *-- Explicitly set line width, and output format so that
    *-- the PDF conversion comes out OK
      mstr_print_parms-linsz = p_linsz.
      mstr_print_parms-paart = p_paart.
            EXPORT it_final1 it_email p_email1 p_sender p_date vl_nmth
            TO MEMORY ID 'MEM' .
          IF report =   'zhr_pm_appandprogemail'.
             SUBMIT zhr_pm_appandprogemail TO SAP-SPOOL WITHOUT SPOOL DYNPRO
          SPOOL PARAMETERS mstr_print_parms
          VIA SELECTION-SCREEN AND RETURN.
          ENDIF.
          IF report =   'zhr_pm_appemail'.
             SUBMIT zhr_pm_appemail TO SAP-SPOOL WITHOUT SPOOL DYNPRO
          SPOOL PARAMETERS mstr_print_parms
          VIA SELECTION-SCREEN AND RETURN.
          ENDIF.
    ENDIF.
    *Find out what the spool number is that was just created
      perform get_spool_number using p_repid p_uname changing mi_rqident.
    *converting the spool request into pdf
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
        EXPORTING
          src_spoolid              = mi_rqident
          no_dialog                = space
          dst_device               = mstr_print_parms-pdest
        IMPORTING
          pdf_bytecount            = mi_bytecount
        TABLES
          pdf                      = it_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.
    *  call function 'DOWNLOAD'
    *    exporting
    *      bin_filesize      = mi_bytecount
    *      filename          = mc_filename
    *      filetype          = 'BIN'
    *    importing
    *      act_filename      = mc_filename
    *    tables
    *      data_tab          = it_mess_att.
      CHECK sy-subrc = 0.
    * Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf INTO wa_pdf.
        TRANSLATE wa_pdf USING ' ~'.
        CONCATENATE v_gd_buffer wa_pdf INTO v_gd_buffer.
        CLEAR wa_pdf .
      ENDLOOP.
      TRANSLATE v_gd_buffer USING '~ '.
      DO.
        it_mess_att = v_gd_buffer.
       APPEND it_mess_att.
        SHIFT v_gd_buffer LEFT BY 255 PLACES.
        IF v_gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.                    " CREATE_PDF
    * FORM get_spool_nunber *
    * Get the most recent spool created by user/report                      *
    form get_spool_number using f_repid
          f_uname changing f_rqident.
      data:
            lc_rq2name TYPE rlgrap-filename.
      concatenate f_repid+0(6)
                  f_repid+7(3)
                  f_uname+0(3)
            into lc_rq2name.
    *   separated by '_'.
    translate lc_rq2name to upper case.
      select * from tsp01 where rq2name = lc_rq2name
        order by rqcretime descending.
          f_rqident = tsp01-rqident.
          exit.
          endselect.
          if sy-subrc ne 0.
            clear f_rqident.
          endif.
    endform. " get spool number
    *&      Form  SEND_MAIL
    FORM send_email USING p_email subject.
      REFRESH it_mess_bod.
    * Default subject matter
      gd_subject         = text-019 ."'Subject'.
      gd_attachment_desc = text-020 ."'Performance Appraisal'.
      IF subject =   'Performance Appraisals and Progression I'.
        gd_attachment_desc = 'PerfAppAndProg'.
      ENDIF.
      IF subject =   'Performance Appraisals'.
        gd_attachment_desc = 'PerfAppraisal'.
      ENDIF.
    * 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 .pdf
      PERFORM send_file_as_email_attachment
                                   TABLES it_mess_bod
                                          it_mess_att
                                    USING p_email
                                          subject
                                          'PDF'
                                          gd_attachment_desc
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 CHANGING gd_error
                                          gd_reciever.
    ENDFORM.                    " SEND_MAIL
    *       FORM process_email                                            *
    FORM process_email using subject.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1 subject.
    *  perform send_email using p_email2.
    ENDFORM.                    "process_email
    *&      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.
      CLEAR : ld_email , ld_mtitle , ld_format , ld_attdescription  ,
        ld_attfilename , ld_sender_address , ld_sender_address_type ,
        w_doc_data.
      REFRESH: t_packing_list.
      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.
      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.
      LOOP AT it_email.
    * Add the recipients email address
        t_receivers-receiver = it_email.
        t_receivers-rec_type = 'U'.
        t_receivers-com_type = 'INT'.
        t_receivers-notif_del = 'X'.
        t_receivers-notif_ndel = 'X'.
        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_HEX               = 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.
      IF sy-subrc = 0.
        PERFORM update_infotype_0019 .
      ENDIF.
    * Populate zerror return code
    *  ld_error = sy-subrc.
    **  stop .
    *  READ TABLE t_receivers WITH KEY retrn_code = '0' .
    *  IF sy-subrc = 0 .
    *    v_update_flag = '1' .
    *    EXPORT v_update_flag TO MEMORY ID 'MEM2' .
    *  ENDIF .
    ** Populate zreceiver return code
    *  LOOP AT t_receivers.
    *    ld_receiver = t_receivers-retrn_code.
    *  ENDLOOP.
    ENDFORM.                    "send_file_as_email_attachment
    *&      Form  GET_NEXT_MONTH
    FORM get_next_month .
      CLEAR v_month .
      v_month = vl_nmth+4(2).
      REFRESH it_t247 .
      CLEAR it_t247 .
      CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
        EXPORTING
          langu = 'E'
          month = v_month
        IMPORTING
          t247  = it_t247.
      CLEAR v_mon_text .
      v_mon_text = it_t247-ltx .
    ENDFORM.                    " GET_NEXT_MONTH
    Edited by: Katie Doody on Feb 24, 2010 12:30 AM

    Thank you for your response, this has allowed me to identify the problem. It is when I create the spool by using the code below. If I add a wait after this, the program works successfully. Is there another way to write the data to create a spool within my initial program rather than doing the submit? Could it be that it is putting data in memory?
    SUBMIT zhr_pm_appandprogemail TO SAP-SPOOL WITHOUT SPOOL DYNPRO
          SPOOL PARAMETERS mstr_print_parms
          VIA SELECTION-SCREEN AND RETURN.
    *& Report  ZHR_PM_APPANDPROGEMAIL
    REPORT  ZHR_PM_APPANDPROGEMAIL
            NO STANDARD PAGE HEADING
            LINE-SIZE 80
            LINE-COUNT 65(8).
    *        MESSAGE-ID zhr.
    * INTERNAL TABLES DECLARATION
    DATA: it_pdf TYPE tline OCCURS 0 ." WITH HEADER LINE .
    * WORK AEA DECLARATION
    DATA: wa_pdf TYPE tline .
    * Spool to PDF conversions
    *DATA: "gd_spool_nr TYPE tsp01-rqident,
    *      gd_destination TYPE rlgrap-filename,
    *      gd_bytecount TYPE tst01-dsize,
    DATA:v_update_flag TYPE c .                                   "flag for updating infotype 41 last appraisal date
    DATA: v_gd_buffer TYPE string.
    DATA: BEGIN OF it_final1 OCCURS 0 ,
            supervisor      TYPE persno ,
            pernr           TYPE persno ,
            ename           TYPE pa0001-ename ,
            subgroup        TYPE persk ,
            stext           TYPE t503t-ptext ,
            lastapp         TYPE dats ,
            lastjob         TYPE dats ,
            email           TYPE ztype,
            darxx(5)        TYPE c,
            progression(1)  TYPE c,
            supervisor_desc(50) TYPE c,
          END OF it_final1 .
    DATA:   t_packing_list TYPE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_contents TYPE solisti1 OCCURS 0 WITH HEADER LINE,
            t_receivers TYPE somlreci1 OCCURS 0 WITH HEADER LINE,
            t_attachment TYPE solisti1 OCCURS 0 WITH HEADER LINE,
            t_object_header TYPE solisti1 OCCURS 0 WITH HEADER LINE,
            w_cnt TYPE i,
            w_sent_all(1) TYPE c,
            w_doc_data TYPE sodocchgi1 .
    DATA: gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA: v_flag TYPE c VALUE '1' .
    DATA: BEGIN OF it_final OCCURS 0 ,
            subgroup       TYPE persk ,
            supervisor     TYPE persno ,
            pernr          TYPE persno ,
            ename          TYPE pa0001-ename ,
            stext          TYPE t503t-ptext ,
            lastapp        TYPE dats ,
            lastjob        TYPE dats ,
            email          TYPE ztype,
            progression(1) TYPE c,
            supervisor_desc(50) TYPE c,
          END OF it_final .
    DATA:it_t247 TYPE STANDARD TABLE OF t247 WITH HEADER LINE .
    DATA: it_email TYPE STANDARD TABLE OF zemail WITH HEADER LINE.
    *VARIABLE DECLARATION
    DATA: p_date   TYPE sy-datum ,               "excution date
          vl_date  TYPE sy-datum ,
          p_email1 TYPE somlreci1-receiver ,     "receiver
          p_sender TYPE somlreci1-receiver .     "sender
    DATA:  w_recsize TYPE i.
    DATA: gd_recsize TYPE i.
    DATA : vl_nmth TYPE sy-datum.
    DATA: v_month(2) TYPE n .
    DATA: v_mon_text TYPE t247-ltx .
    *START OF SELECTION
    START-OF-SELECTION .
      REFRESH t_receivers.
      IMPORT it_final1 it_email p_email1 p_sender p_date vl_nmth FROM MEMORY ID 'MEM'.
      PERFORM get_next_month .
      LOOP AT it_final1 .
        IF  it_final1-progression IS NOT INITIAL.
          MOVE-CORRESPONDING it_final1 TO it_final .
          APPEND it_final .
          CLEAR  it_final .
    *   Add the recipients email address
          t_receivers-receiver = it_final1-email.
          t_receivers-rec_type = 'U'.
          t_receivers-com_type = 'INT'.
          t_receivers-notif_del = 'X'.
          t_receivers-notif_ndel = 'X'.
          APPEND t_receivers.
        ENDIF.
      ENDLOOP .
      PERFORM write_output .
    *END OF SELECTION
    END-OF-SELECTION .
    *&      Form  WRITE_OUTPUT
    FORM write_output .
      DATA: l_date(14) TYPE c ,
            l_date_temp(14) TYPE c ,
            v_date(10) TYPE c ,
            v_date1(20) TYPE c ,
            v_date1_temp(20) TYPE c ,
            f_date(10) TYPE c.
      DATA: lv_stext TYPE t503t-ptext .
      CLEAR : v_date, v_date1.
      CONCATENATE p_date+4(02) p_date+6(02) p_date+0(04)'.' INTO v_date.
      CONCATENATE v_mon_text p_date+0(4) INTO l_date_temp SEPARATED BY space.
      CONCATENATE l_date_temp '.' INTO l_date.
      CONCATENATE v_mon_text vl_nmth+6(2) INTO v_date1_temp SEPARATED BY space.
      CONCATENATE v_date1_temp ',' INTO v_date1_temp.
      CONCATENATE v_date1_temp vl_nmth(4) INTO v_date1_temp SEPARATED BY space.
      CONCATENATE v_date1_temp '.' INTO v_date1.
      CONDENSE l_date .
      FORMAT INTENSIFIED ON.
      SKIP 4.
      WRITE:/(80) text-001 CENTERED .         "'METROPOLITAN UTILITIES DISTRICT'.
      WRITE:/(80) text-002 CENTERED .         "'OMAHA NEBR.'.
      SKIP 2.
      WRITE:/(80) text-003 CENTERED .        "'Inter-Departmental Communication'.
      FORMAT INTENSIFIED OFF.
      WRITE  :/(80) v_date CENTERED using edit mask '__/__/____'.   " v_date.
      SKIP 2.
      WRITE: /10 text-004.                     "'SUBJECT:   Performance Appraisals and Progression Increase'.
      SKIP 1.
      WRITE: /10 text-005, it_final1-supervisor_desc.  "'TO: Supervisor'.
      SKIP 1.
      WRITE: /10 text-006.                     "'FROM:      Anne M. Undajon, Director of Compensation and Benefits'.
      SKIP 2.
      WRITE:/10 text-007 .                       "'Listed below are the employees in your area who are due a '.
      WRITE:/10 text-008 ,l_date.                "'Performance Appraisal during the month of ',l_date.'.      "v_mon_text , P_date+0(4)
      WRITE:/10 text-009 .                       "'These employees are also eligible for a progression increase.
      WRITE:/10 text-010 .                       "' A performance appraisal form can be found on-line in the MUD '.
      WRITE:/10 text-011 .                       "'template section. The Performance Appraisal is to be completed '
      WRITE:/10 text-012 .                       "'and discussed with the employee by the immediate supervisor.'
      SKIP 2.
      WRITE:/10 text-013.                        "Signed forms should be returned to the Human Resource Department by '.
      WRITE:/10 v_date1.
      SKIP 2 .
      SORT it_final[] BY subgroup .
      LOOP AT it_final .
        CLEAR: lv_stext .
        lv_stext =  it_final-stext.
        AT NEW subgroup .
          TRANSLATE lv_stext TO UPPER CASE .
          WRITE:/(80) lv_stext CENTERED .
          SKIP 2 .
          WRITE: 10 text-014 .                      "'Employee name' .
          WRITE: 32 text-015 .                      "'Job Date' .
          WRITE :44 text-016 .                      "'Last Appraisal' .
          WRITE :59 text-021 .                      "'Employee' .
          WRITE :/10 '--------------------' , 32'----------', 44 '--------------', 59 '--------'.
        ENDAT .
        WRITE:/10 it_final-ename .
        WRITE: 32 it_final-lastjob using edit mask '__/__/____'.
        CONCATENATE it_final-lastapp+4(02) it_final-lastapp+6(02) it_final-lastapp+0(04) INTO f_date.
        WRITE :44 f_date using edit mask '__/__/____'.
        SHIFT it_final-pernr left deleting leading '0'.
        WRITE : 59 it_final-pernr.
        SKIP 2 .
      ENDLOOP.
      SKIP 4.
      WRITE :10 text-017.             "'Anne M. Undajon'.
      FORMAT INTENSIFIED ON.
      WRITE:/10 text-018.              "'Director of Compensation & Benefits'.
      FORMAT INTENSIFIED OFF.
    ENDFORM.                    " WRITE_OUTPUT
    *&      Form  GET_NEXT_MONTH
    FORM get_next_month .
      CLEAR v_month .
      v_month = vl_nmth+4(2).
      REFRESH it_t247 .
      CLEAR it_t247 .
      CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
        EXPORTING
          langu = 'E'
          month = v_month
        IMPORTING
          t247  = it_t247.
      CLEAR v_mon_text .
      v_mon_text = it_t247-ltx .
    ENDFORM.                    " GET_NEXT_MONTH
    Edited by: Katie Doody on Feb 24, 2010 4:07 PM

  • Spool to PDF stored in application server

    Hi Experts,
    Please, please.....I need help.......
    I have a problem with converting spool to PDF. If I download the spool to presentation, the output is fine, BUT when I download it to application server and try to view it in al11, a set of characters comes out and if I try to save it on my local drive from the application server, an error message pops out stating that it could not read the file because it is either not a supported file type or because the file has been damaged. Please help me. I've tried doing everything I can already. I cannot run the convertion of spool file to presentation because it always ends up as run time error, that's why I have no choice but to run it in background. These files will only be viewed by different offices. This files will NOT be sent via email.  Please, please.......help......I'm really, really desperate......Here's what I did with the program....Please tell me where I went wrong.....Help......I've been on it for days and this is really causing a major headache........
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    PARAMETERS: p_file TYPE LOCALFILE DEFAULT TEXT-F02 OBLIGATORY.
    DATA: gd_buffer TYPE STRING OCCURS 0 WITH HEADER LINE.
    lt_conv LIKE gd_buffer OCCURS 0 WITH HEADER LINE.
    DATA lv_string TYPE string.
    LOOP AT it_pdf_output.
    TRANSLATE it_pdf_output USING '~'.
    CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
    ENDLOOP.
    TRANSLATE gd_buffer USING '~'.
    APPEND gd_buffer.
    DO.
    counter = strlen( gd_buffer ).
    IF counter GE 255.
    lt_conv = gd_buffer(255).
    APPEND lt_conv.
    SHIFT gd_buffer LEFT BY 255 PLACES.
    ELSE.
    lt_conv = gd_buffer(counter).
    APPEND lt_conv.
    EXIT.
    ENDIF.
    ENDDO.
    IF lt_conv[] IS NOT INITIAL.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc EQ 0.
    IF sy-subrc 0.
    MESSAGE e398(00) WITH 'Error creating file' p_file.
    ENDIF.
    LOOP AT lt_conv INTO lv_string.
    TRANSFER lv_string TO p_file.
    ENDLOOP.
    CLOSE DATASET p_file.
    IF sy-subrc EQ 0.
    ELSE.
    MESSAGE e398(00) WITH 'Error closing file' p_file.
    ENDIF.
    ELSE.
    MESSAGE e398(00) WITH 'Error creating file' p_file.
    ENDIF.
    ENDIF.

    Hi,
    maybe a look at Function Module 'CONVERT_ABAPSPOOLJOB_2_PDF' could solve your problem.
    Regards
    Mark-André

  • Problem in converting Spool to PDF file, having non-English characters

    Hi All,
            I have problem in converting Spool to PDF format.
    Scenario : I have a spool which has non-English characters. I am using CONVERT_ABAPSPOOLJOB_2_PDF  FM to perform conversion. But my output is having junk values( ie # ) for non-English characters. Any pointers to solve this issue will be appreciated.
    I even tried with report RSTXPDFT4 , it also gives me the same junk characters.
    Regards,
    Navin.

    Hi All,
            I have problem in converting Spool to PDF format.
    Scenario : I have a spool which has non-English characters. I am using CONVERT_ABAPSPOOLJOB_2_PDF  FM to perform conversion. But my output is having junk values( ie # ) for non-English characters. Any pointers to solve this issue will be appreciated.
    I even tried with report RSTXPDFT4 , it also gives me the same junk characters.
    Regards,
    Navin.

  • Converting spool to pdf to base64

    Hello people
    I am trying to convert a spool to pdf and then I need to convert the pdf to base64.
    I used fm CONVERT_OTFSPOOLJOB_2_PDF to convert the spool to pdf, with the data returned in an internal table it_pdf of type tline.
    I then need to convert it_pdf to base64, I did it as follows:
    DATA: v_input       TYPE xstring,
              v_string64   TYPE string,
      EXPORT it_pdf[] TO DATA BUFFER v_input. "convert to xstring
      CALL FUNCTION 'SCMS_BASE64_ENCODE_STR'
        EXPORTING
          input  = v_input
        IMPORTING
          output = v_string64
    v_string64 seems to contain corrupt data, is this the correct way, anyone have any suggestions here?
    Thanx in advance.

    Just today someone has posted this link somewhere
    https://wiki.sdn.sap.com/wiki/display/sandbox/Conversion%20of%20Spool%20Request%20Data%20into%20PDF%20and%20Excel%20Format%20and%20Send%20it%20into%20Mail

  • Problem while converting Spool to PDF

    Hi,
    I am sending ALV report output to Spool then converting the Spool to PDF using  'CONVERT_ABAPSPOOLJOB_2_PDF'.
    I am able to send the mail but in the PDF, the first page contains data statistics(no. of records passed) but I want to supress it. I need to get my Actual output only.
    Please help me regarding this.
    Thanks,
    Swathi

    You need to set the print parameter of the ALV to avoid the statistics in the Spool.
    Like:
    data:   ls_prnt      type slis_print_alv.
    ls_prnt-NO_PRINT_LISTINFOS = 'X'.
      call function 'REUSE_ALV_GRID_DISPLAY'
          is_print                          = ls_prnt
    Regards,
    Naimesh Patel

  • Problem in converting spool to pdf

    Hi Experts,
    I want an internal table to be converted to the PDF. For this RSPO_OPEN_SPOOLREQUEST, RSPO_WRITE_SPOOLREQUEST and RSPO_CLOSE_SPOOLREQUEST to create the spool. However, somehow the table tsp01 does not gets updated as a result i could not convert the data to PDF. Can any one help me how this problem could be solved.
    Thank.
    Warm Regards,
    Harshad.

    Hi,
    you can refer this sample code.
    DATA: t_otfdata_tab LIKE ITCOO OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'CLOSE_FORM'
    TABLES
    OTFDATA = t_otfdata_tab
    fill the exceptions..
    IF SY-SUBRC = 0.
    ENDIF.
    then pass the t_otfdata_tab to this function module..
    CONSTANTS: c_pdf(03) VALUE 'PDF'.
    PDF File size
    DATA: w_file_size TYPE I.
    Internal Table to hold Form contents in PDF format
    DATA: t_pdfdata_tab LIKE tline OCCURS 0 WITH HEADER LINE.
    for converting. the output format from OTF to PDF
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT eq c_pdf
    IMPORTING
    BIN_FILESIZE = w_file_size
    TABLES
    OTF eq t_otfdata_tab
    LINES eq t_pdfdata_tab
    EXCEPTIONS...
    use these links, hope it will be useful to you....
    Problem in converting spool to PDF file
    Problem in converting the spool to PDF.
    Thanks and Regards,
    Ahamed.

  • Problem in converting spool to PDF file

    Hi guys,
    My spool contains Russian characters which are shown as one special char in pdf file. I guess the russian char. are not recognized by pdf.
    I convert the spool to pdf using following FM
      CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
             EXPORTING
                  src_spoolid   = wa_spool-spool
                  no_dialog     = ' '
             IMPORTING
                  pdf_bytecount = v_numbytes
                  pdf_spoolid   = v_pdfspoolid
                  btc_jobname   = v_jobname
                  btc_jobcount  = v_jobcount
             TABLES
                  pdf           = pdf.
    Then i download the file using FM:
    CALL FUNCTION 'WS_DOWNLOAD'
           EXPORTING
                bin_filesize = v_numbytes
                filename     = v_return1
                filetype     = 'BIN'
           TABLES
                data_tab     = pdf
    Help me....
    Point will be rewarded on helpful answers.
    Regards,
    GURU

    HI
    use my code
    it will do the entire job
    *& Report  Z8VM_SPOOL2PDF                                              *
    report  z8vm_spool2pdf                          .
    **---- Author     :    vivekanand meghmala
    **---- Purpose    :    Create Single PDF file with outputs of
    **----                 Multiple Spools.
    **---- Create Date:    July 05th, 2006
    **---- Analyst    :    Vivek Maheshwari
    **---- Tables
    tables : tsp01.
    **---- Select Options for Multiple spools
    select-options :
      s_spool for tsp01-rqident obligatory.
    **---- Parameters for File Path.
    parameters :
    p_file type localfile default 'C:combined.pdf' obligatory.
    **---- Get the Spool Requests entered in Select-options for Spools.
    data : i_tsp01 like tsp01 occurs 0 with header line.
    **---- Work Areas and Variables
    data:  wa_eof type soli,            "----- End of File Work Area
           v_file type string,          "----- String
           v_size type i,               "----- Size
           v_lines type i.              "----- Lines in Internal Table
    **---- Internal Table for Spool Details and PDF and Document Details
    data : i_spool_table type table of soli,
           i_spool_total type table of soli  with header line,
           i_otf         type table of itcoo with header line,
           i_doc         like table of docs,
           i_pdf         like table of tline.
    **---- Move File name to Variable
    v_file = p_file.
    **---- Clear and Refresh Internal Tables before first use
    clear i_tsp01.            refresh i_tsp01.
    clear i_spool_table.      refresh i_spool_table.
    clear i_spool_total.      refresh i_spool_total.
    **---- Get Spool ID Details from TSP01
    select * from tsp01 into table i_tsp01 where rqident in s_spool.
    **---- Sort Table in Ascending order based on Spool Id
    sort i_tsp01 by rqident.
    **---- Get information about Multiple spools
    loop at i_tsp01.
    **---- Get Multiple Spool information
      call function 'RSPO_RETURN_SPOOLJOB'
        exporting
          rqident              = i_tsp01-rqident
        tables
          buffer               = i_spool_table
        exceptions
          no_such_job          = 1
          job_contains_no_data = 2
          selection_empty      = 3
          no_permission        = 4
          can_not_access       = 5
          read_error           = 6
          type_no_match        = 7
          others               = 8.
      if sy-subrc = 0.
      endif.
    **---- Get the Last line index (Number of Lines)
      describe table i_spool_table lines v_lines.
    **---- Clear Work Area for End of File (EOF) and read
    **---- End of File String into it and Delete it
      clear wa_eof.
      read table i_spool_table index v_lines into wa_eof.
      delete i_spool_table index v_lines.
    **---- Collect All individual Spool Details into one internal table.
      append lines of i_spool_table to i_spool_total.
      at last.
    **---- Append End of File information to Internal table
    **---- Containing information about all the invidual spools -
    **---- Thus forming one single spool
        append wa_eof to i_spool_total.
      endat.
    endloop.
    **---- Clear OTF tables before initial use
    clear i_otf. refresh i_otf.
    **---- Fill in the OTF internal table
    loop at i_spool_total.
      clear i_otf.
      i_otf = i_spool_total.
      append i_otf.
    endloop.
    **---- Convert the OTF information to PDF.
    call function 'CONVERT_OTF_2_PDF'
      exporting
        use_otf_mc_cmd         = 'X'
      importing
        bin_filesize           = v_size
      tables
        otf                    = i_otf
        doctab_archive         = i_doc
        lines                  = i_pdf
      exceptions
        err_conv_not_possible  = 1
        err_otf_mc_noendmarker = 2
        others                 = 3.
    if sy-subrc <> 0.
      message i002(sy) with 'Cannot convert to PDF, exiting....'.
      leave program.
    endif.
    **---- Download PDF file thus formed onto frontend
    call method cl_gui_frontend_services=>gui_download
      exporting
        filename                = v_file
        filetype                = 'BIN'
      changing
        data_tab                = i_pdf
      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
        not_supported_by_gui    = 22
        error_no_gui            = 23
        others                  = 24.
    if sy-subrc <> 0.
      message i002(sy) with 'Cannot download PDF, exiting....'.
      leave program.
    endif.

  • Convert HTML-Spool to PDF

    Hi experts,
    I'm looking for a possibility to conbvert a Spool-request to PDF fomrat.
    Following situation:
    I have a Web Dynpro that creates a page with a few material details. I can now export this to Excel, but now the requeiremt is also to convert it to PDF.
    We don't have ADS, so I can't use Adobe forms. First, I tried to create a Smartform and convert this to PDF which will work. But I have also a few pictures included which come from a Web Service (as JPG). After searchin a while I found a possibilty to convert them to TIF and insert them in SE78 automatically. But this takes to much time and as a result of insert them to SE78, the colors will change (only 256 colors).
    Next idea was to generate a HTML-Mail out of my Smartform (regaring this blog /people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp) what works perfectly now.
    So now I have a Spool in SOST which contains a HTML file. OK, looks great, all pictures are included, takes not much time - but how to convert this to PDF?
    Anybody any ideas?

    Hi experts,
    after searching the whole forum and internet, I don't find any solution.
    Maybe the convertion from Spool to PDF is not possible...
    OK, another idea:
    I read that the wrong colors result from the different color depth (16/24 bit vs 256 colors). So my last idea is to convert the image before inserting into BDS (SE78), automatically done by SAP.
    Is there any function/coding you know which can convert me a image from 24bit to 256 colors? If so, I can convert the image and then insert into BDS...

Maybe you are looking for

  • Using Mail to monitor my work e-mail account

    My employer has its own e-mail server and it uses XP/Outlook. I want all of my work e-mail to show up in my Mac Mail account. (I have my MacBook Pro connected to the internet at all times.) I went through the File/Add Account thing. I then got the fo

  • What are the entities that can be re-used in different servers, SI App, SI instance? And how?

    Greetings, What are the entities that can be re-used in different servers, SI App, SI instance? And how? e.g. can I use a deployed IQStreamable@app1  into app2? can I use a deployed observable/app1/siInstance1/Server1 into another query/app3/siInstan

  • Mac OS X Copying JavaApplicationStub using Java code

    I have a java application that copies files from one folder to another. This works fine on Windows, but on Mac OS X a Unix executable file like JavaApplicationStub appearently does not like to be copied using Java... I have tested the application try

  • How to use stroke outline in PSE 13

    I am trying to use the stroke outline around a picture in PSE 13 and it is greyed out.  Can anyone help me with this? Thank you in advance. Robyn

  • Question about ldst_raw test and sparc in general

    Hi, I'm running ldst_raw test in core1 environment. I was wondering why the code used address of 0x1000144000 instead of 0x144000 to get to HPriv_Reset_Handler? This actually caused DRAM controller to generate an address that's out of its range (thou