PDF Conversion Error in Email

Hi Experts,
my task is to convert a smartform into pdf & download & email. in two different programs
download program i converted smartform using 'CONVERT_OTF_2_PDF' and its working fine with no problem.
and in email program when tried the same one, I have a error as the PDF file is damaged and could not be repaired.
So I used 'CONVERT_OTF', its working fine and can send emails to external systems with no errors.
Now my problem is in the email, when i open the attachement, i getting a error in Pdf file.
"Cannot extract the embedded font Arial. Some characters may not be display or print correctly".
Please tell me how to close this error.
Thanks & regards,
Dileep .C

hi,
      Report BCS_EXAMPLE_6
      Email documents using PDF based forms
REPORT bcs_example_6.
DATA: carr_id TYPE sbook-carrid.
PARAMETER:      p_custid  TYPE scustom-id DEFAULT 12.
SELECT-OPTIONS: s_carrid FOR carr_id     DEFAULT 'AA' TO 'ZZ'.
PARAMETER:      p_email   TYPE adr6-smtp_addr OBLIGATORY.
DATA: customer          TYPE scustom,
      bookings          TYPE ty_bookings,
      connections       TYPE ty_connections,
      fm_name           TYPE rs38l_fnam,
      fp_docparams      TYPE sfpdocparams,
      fp_outputparams   TYPE sfpoutputparams,
      error_string      TYPE string.
DATA  ls_formoutput     TYPE fpformoutput.
DATA  lx_fp_api         TYPE REF TO cx_fp_api.
data  lp_form           TYPE tdsfname  value 'FP_TEST_03'.
data  lp_langu          TYPE langu     value 'D'.
data  lp_countr         TYPE land1     value 'DE'.
BCS data
DATA  send_request       TYPE REF TO cl_bcs.
DATA  text               TYPE bcsy_text.
DATA  document           TYPE REF TO cl_document_bcs.
DATA  recipient          TYPE REF TO if_recipient_bcs.
DATA: bcs_exception      TYPE REF TO cx_bcs.
DATA  sent_to_all        TYPE os_boolean.
DATA  pdf_content        TYPE solix_tab.
DATA  lp_pdf_size        TYPE so_obj_len.
get data
SELECT SINGLE * FROM scustom INTO customer WHERE id = p_custid.
CHECK sy-subrc = 0.
SELECT * FROM sbook INTO TABLE bookings
         WHERE customid = p_custid
         AND   carrid   IN s_carrid
         ORDER BY PRIMARY KEY.
SELECT * FROM spfli INTO TABLE connections
         FOR ALL ENTRIES IN bookings
         WHERE carrid = bookings-carrid
         AND   connid = bookings-connid
         ORDER BY PRIMARY KEY.
Print data:
First get name of the generated function module
TRY.
    CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
      EXPORTING
        i_name     = lp_form
      IMPORTING
        e_funcname = fm_name.
  CATCH cx_fp_api INTO lx_fp_api.
  exception handling
    MESSAGE ID lx_fp_api->msgid TYPE lx_fp_api->msgty
      NUMBER lx_fp_api->msgno
        WITH lx_fp_api->msgv1 lx_fp_api->msgv2
             lx_fp_api->msgv3 lx_fp_api->msgv4.
    EXIT.
ENDTRY.
Set output parameters and open spool job
fp_outputparams-nodialog = 'X'.   " no print preview
fp_outputparams-getpdf = 'X'.    " request PDF
CALL FUNCTION 'FP_JOB_OPEN'
  CHANGING
    ie_outputparams = fp_outputparams
  EXCEPTIONS
    cancel          = 1
    usage_error     = 2
    system_error    = 3
    internal_error  = 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.
Set form language and country (->form locale)
fp_docparams-langu   = lp_langu.
fp_docparams-country = lp_countr.
Now call the generated function module
CALL FUNCTION fm_name
  EXPORTING
    /1bcdwb/docparams  = fp_docparams
    customer           = customer
    bookings           = bookings
    connections        = connections
  IMPORTING
    /1bcdwb/formoutput = ls_formoutput
  EXCEPTIONS
    usage_error        = 1
    system_error       = 2
    internal_error     = 3
    OTHERS             = 4.
IF sy-subrc <> 0.
  CALL FUNCTION 'FP_GET_LAST_ADS_ERRSTR'
    IMPORTING
      e_adserrstr = error_string.
  IF NOT error_string IS INITIAL.
    we received a detailed error description
    WRITE:/ error_string.
    EXIT.
  ELSE.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDIF.
Close spool job
CALL FUNCTION 'FP_JOB_CLOSE'
  IMPORTING
    E_RESULT             =
  EXCEPTIONS
    usage_error          = 1
    system_error         = 2
    internal_error       = 3
    OTHERS               = 4.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
------------ Call BCS interface ----------------------------------
TRY.
  ---------- create persistent send request ----------------------
    send_request = cl_bcs=>create_persistent( ).
  ---------- add document ----------------------------------------
  get PDF xstring and convert it to BCS format
    lp_pdf_size = XSTRLEN( ls_formoutput-pdf ).
    pdf_content = cl_document_bcs=>xstring_to_solix(
        ip_xstring = ls_formoutput-pdf ).
    document = cl_document_bcs=>create_document(
          i_type    = 'PDF'
          i_hex     = pdf_content
          i_length  = lp_pdf_size
          i_subject = 'test created by BCS_EXAMPLE_6' ). "#EC NOTEXT
  add document to send request
    send_request->set_document( document ).
  ---------- add recipient (e-mail address) ----------------------
    recipient = cl_cam_address_bcs=>create_internet_address(
        i_address_string = p_email ).
  add recipient to send request
    send_request->add_recipient( i_recipient = recipient ).
  ---------- send document ---------------------------------------
    sent_to_all = send_request->send(
        i_with_error_screen = 'X' ).
    IF sent_to_all = 'X'.
      message i022(so).
    ENDIF.
  ---------- explicit 'commit work' is mandatory! ----------------
    COMMIT WORK.
*            exception handling
* replace this very rudimentary exception handling
* with your own one !!!
  CATCH cx_bcs INTO bcs_exception.
    WRITE: text-001.
    WRITE: text-002, bcs_exception->error_type.
    EXIT.
ENDTRY.

Similar Messages

  • Smartfomrs to PDF conversion error

    Dear Experts,
    I have a requirement to convert smart forms to PDF.
    After converting smartforms to PDF, I am getting the following errors.
    1. Special signs like u201C&u201D, are shown as <& > in PDF.
    2. Some line breaks which are in smartforms are not appearing in the PDF.
    (How to handle the same during smartforms to PDF)
    Thanks in Advance.
    sri

    Hi,
    in more than once I´ve experimented the same problem. What I do is to replace the text in my form:
    REPLACE ALL OCCURENCES OF '&gt;'   IN aux_text WITH '"'.
    REPLACE ALL OCCURENCES OF '&lt;'   IN aux_text WITH '"'.
    you can insert a line break like this:
    CL_ABAP_CHAR_UTILITIES=>CR_LF
    but in both cases you must set a break point in your form where the text is processed to find out what´s wrong. It could be that system cannot understand some characters as HTML escape code. This is the case in web development when working with text boxes.

  • PDF conversion error

    Hi all,
    while converting a spool request to PDF through the program RSTXPDFT4, a PDf file is getting generated but with an error of 'Japanese fonts not available'.
    Please suggest a solution if some one has encountered it before.
    thanks

    Hi Arun,
    Contact your Basis team. You will have to upload Japanese Fonts in your system.
    Regards,
    Chetan.
    PS: Reward points if this helps.

  • How fix Explorer 11 PDF Conversion Error Messages - used to work fine!

    Using Win7 and Explorer 11. Acrobat 9.5.xx PDF Reader/Creator.
    Works fine on one PC at home and other PC (same config and settings) gives error message "Could not access Acrobat Web Capture Facility".
    Tried repairing Acrobat 9.5.xx with same error results.
    Suggested solution so I can get back to creating PDFs of Websites??

    Not a reply. Screen shot of error message when trying to convert web page to PDF using Acrobat 9.5.5
    Any suggestions how to repair?
    /Mike

  • Adobe 9 PDF Conversion Error

    Hey Guys,
    my system at work is a:
    Adobe 9 Pro Extended
    Word 2007 (German)
    Windows XP SP3
    I have a document saved with several graphics made from text boxes and the drawing tools from Word 2007. In addition, I have a header that is on some pages overlapped by a white un-transperent text box.
    When I save it as .doc and convert it to pdf, using unmodified standard settings, it works perfectly.
    However, when I save it as .docx and then convert it to pdf, the overlapped header shows although the textbox is put on top of it. In addition, only text and not graphical elements are to be seen in the pdf.
    Has anyone experienced a similar problem? I would be very grateful if you could help me. This seems to be a strange error. The cause must lie somehwere in the settings although this is an out-of-the-box installation..
    Thank you very much,
    Stefan

    Good. That simplifies things a bit and makes sure it may be related to the Adobe PDF printer. I was just keying off WORD 2007 as a potential problem for the export, but that is not the case. It is possible that you need to update the software. WORD typically has updates also and it might be possible that an update would solve the issue. It sounds strange that it is affected by saving as a DOCX file rather than a DOC file. That sure suggests an issue with WORD, but I am not sure.

  • What does the "conversion error" I get when converting a pdf file to Microsoft word?

    What is the "conversion error" I get when converfting a pdf file to aMicrosoft word?

    Adobe reader with export to PDF
    Sent from my iPhone 5
    Marty Kennedy

  • Error - While converting Smartform to PDF and send in Email

    HI all,
    I am getting error while opening the PDF file.  i searched in SDN but I am not able to figure out what is the correct issues.
    Please find the piece of code.
    * Assigning the OTFDATA to OTF Structure table
              CLEAR gt_otf.
              gt_otf[] = ls_jobout_info-otfdata[].
    * Convert the OTF DATA to SAP Script Text lines
              CLEAR gt_pdf_tab.
              CALL FUNCTION 'CONVERT_OTF'
                EXPORTING
                  format                = 'PDF'
    **              max_linewidth         = 134
                  max_linewidth         = 132
                IMPORTING
    **              bin_file              = ts_file
                  bin_filesize          = gv_bin_filesize
                TABLES
                  otf                   = gt_otf
                  lines                 = gt_pdf_tab
                EXCEPTIONS
                  err_max_linewidth     = 1
                  err_format            = 2
                  err_conv_not_possible = 3
                  OTHERS                = 4.
    * Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table
              DATA:
    *           gv_bin_filesize TYPE i, " Store the file size
              gv_pos TYPE i,
              gv_len TYPE i,
              gv_tab_lines TYPE i.
              CLEAR : gs_objbin, gs_pdf_tab.
              LOOP AT gt_pdf_tab INTO gs_pdf_tab.
                gv_pos = 255 - gv_len.
                IF gv_pos > 134.                             "length of pdf_table
                  gv_pos = 134.
                ENDIF.
                gs_objbin+gv_len = gs_pdf_tab(gv_pos).
                gv_len = gv_len + gv_pos.
                IF gv_len = 255.                            "length of out (contents_bin)
                  APPEND gs_objbin TO gt_objbin.
                  CLEAR: gs_objbin, gv_len.
                  IF gv_pos < 134.
                    gs_objbin = gs_pdf_tab+gv_pos.
                    gv_len = 134 - gv_pos.
                  ENDIF.
                ENDIF.
              ENDLOOP.
              IF gv_len > 0.
                APPEND gs_objbin TO gt_objbin.
              ENDIF.
    * Filling the details in SAPoffice: Description of Imported Object Components table
              DESCRIBE TABLE gt_objbin LINES gv_tab_lines.
              CLEAR gs_objbin.
              READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.
              IF sy-subrc = 0.
                gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gs_objbin ).
                gs_objpack-transf_bin = 'X'.
                gs_objpack-head_start = 1.
                gs_objpack-head_num = 0.
                gs_objpack-body_start = 1.
                gs_objpack-body_num = gv_tab_lines.
                gs_objpack-doc_type = 'PDF'.
                gs_objpack-obj_name = l_title.
                gs_objpack-obj_descr = w_output-tdtitle.
                APPEND gs_objpack TO gt_objpack.
              ENDIF.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = p_doc_chng
          put_in_outbox              = 'X'
          sender_address             = p_w_sender
          sender_address_type        = 'INT'
        TABLES
          packing_list                     = p_objpack
    **      object_header                    = p_objhead
          contents_bin                     = p_objbin
    **      contents_txt                     = p_objtxt
    *     CONTENTS_HEX                     =
    *     OBJECT_PARA                      =
    *     OBJECT_PARB                      =
          receivers                        = p_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
    kindly help...email is coming but when i tried to open the PDF file, error saying, " There is error opening a file. thie file is damages and cannot be opened'
    thanks

    HI all,
    I am getting error while opening the PDF file.  i searched in SDN but I am not able to figure out what is the correct issues.
    Please find the piece of code.
    * Assigning the OTFDATA to OTF Structure table
              CLEAR gt_otf.
              gt_otf[] = ls_jobout_info-otfdata[].
    * Convert the OTF DATA to SAP Script Text lines
              CLEAR gt_pdf_tab.
              CALL FUNCTION 'CONVERT_OTF'
                EXPORTING
                  format                = 'PDF'
    **              max_linewidth         = 134
                  max_linewidth         = 132
                IMPORTING
    **              bin_file              = ts_file
                  bin_filesize          = gv_bin_filesize
                TABLES
                  otf                   = gt_otf
                  lines                 = gt_pdf_tab
                EXCEPTIONS
                  err_max_linewidth     = 1
                  err_format            = 2
                  err_conv_not_possible = 3
                  OTHERS                = 4.
    * Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table
              DATA:
    *           gv_bin_filesize TYPE i, " Store the file size
              gv_pos TYPE i,
              gv_len TYPE i,
              gv_tab_lines TYPE i.
              CLEAR : gs_objbin, gs_pdf_tab.
              LOOP AT gt_pdf_tab INTO gs_pdf_tab.
                gv_pos = 255 - gv_len.
                IF gv_pos > 134.                             "length of pdf_table
                  gv_pos = 134.
                ENDIF.
                gs_objbin+gv_len = gs_pdf_tab(gv_pos).
                gv_len = gv_len + gv_pos.
                IF gv_len = 255.                            "length of out (contents_bin)
                  APPEND gs_objbin TO gt_objbin.
                  CLEAR: gs_objbin, gv_len.
                  IF gv_pos < 134.
                    gs_objbin = gs_pdf_tab+gv_pos.
                    gv_len = 134 - gv_pos.
                  ENDIF.
                ENDIF.
              ENDLOOP.
              IF gv_len > 0.
                APPEND gs_objbin TO gt_objbin.
              ENDIF.
    * Filling the details in SAPoffice: Description of Imported Object Components table
              DESCRIBE TABLE gt_objbin LINES gv_tab_lines.
              CLEAR gs_objbin.
              READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.
              IF sy-subrc = 0.
                gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gs_objbin ).
                gs_objpack-transf_bin = 'X'.
                gs_objpack-head_start = 1.
                gs_objpack-head_num = 0.
                gs_objpack-body_start = 1.
                gs_objpack-body_num = gv_tab_lines.
                gs_objpack-doc_type = 'PDF'.
                gs_objpack-obj_name = l_title.
                gs_objpack-obj_descr = w_output-tdtitle.
                APPEND gs_objpack TO gt_objpack.
              ENDIF.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = p_doc_chng
          put_in_outbox              = 'X'
          sender_address             = p_w_sender
          sender_address_type        = 'INT'
        TABLES
          packing_list                     = p_objpack
    **      object_header                    = p_objhead
          contents_bin                     = p_objbin
    **      contents_txt                     = p_objtxt
    *     CONTENTS_HEX                     =
    *     OBJECT_PARA                      =
    *     OBJECT_PARB                      =
          receivers                        = p_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
    kindly help...email is coming but when i tried to open the PDF file, error saying, " There is error opening a file. thie file is damages and cannot be opened'
    thanks

  • When I select "Convert" using the Adobe PDF conversion - I get "Error signing in"

    When I select "Convert" using the Adobe PDF conversion - I get "Error signing in"

    You need the CreatePDF forum

  • I am getting an error message when I try to combine three PDF files"Your PDF conversion request fail

    I am getting an error message when I try to combine three PDF files "Your PDF conversion request failed. Try again later" 
    Thank you,
    Lori Jans

    Hi,
    Please let me know if your files are big. complex, or image files?
    If you sill have the same error message then please share your files with us so that we can look at them using below site: 
    https://adobeformscentral.com/?f=qJiclooYWGGNFtWfj8g3wg#
    Thank you.
    Hisami

  • Unable to convert pdf to any other format. Tried cloud as well as acrobat reader. Reader error message "unable to contact service" and Cloud message "conversion error". I tried multiple pdf documents and checked security settings on all of them. Help Plea

    nable to convert pdf to any other format. Tried cloud as well as acrobat reader. Reader error message "unable to contact service" and Cloud message "conversion error". I tried multiple pdf documents and checked security settings on all of them. Help Please!

    Hi skydivingsnowman,
    I'm sorry you're having such trouble using the ExportPDF service. What browser are you using?
    Please try clearing your browser cache, or using a different browser (here's a list of supported browsers:   http://www.adobe.com/acom/systemreqs/.
    Please let me know if that works.
    Best,
    Sara

  • I have paid for a year subscription, but all the PDF's I attempt to export to Word give me a "Conversion Error" message, citing that the "file's security settings do not allow export." I want a refund. Adobe, please advise. Thank you.

    I have paid for a year subscription, but all the PDF's I attempt to export to Word give me a "Conversion Error" message, citing that the "file's security settings do not allow export." I want a refund. Adobe, please advise. Thank you.

    Hi la recruiter,
    There are a few types of files that Acrobat can't convert--and PDF files with security applied is one on them. I'm happy to cancel your subscription, if you decide that it's not going to work out for you. Please confirm that you'd like me to proceed with the cancelation, and I'll take care of it right away.
    Best,
    Sara

  • Please help.  Keep getting a conversion error when trying to convert a PDF to a .docx. Advice?

    Please help.  Keep getting a conversion error when trying to convert a PDF to a .docx. Advice?

    Sara,
    Please see my answers in bold below.
    What browser are you using? Try clearing the cache, or using a different browser. N/A
    Are you converting from within Reader, or directly via the ExportPDF website. Within Reader.I disabled the OCR and this did not work either. Try converting from within Reader, and disable OCR as detailed in this document: How to disable Optical Character Recognition (OCR) when converting PDF to Word or Excel.
    Are you on a networked computer? Make sure that there aren't any firewall/proxy settings that are preventing you from uploading files to the Internet. Not having problems uploading the file--that works fine.
    Make sure the file is within the file-size limit of 100 MB. It is <40.
    I get the error message, "File failed to be converted using Adobe ExportPDF online."
    Thanks for your help in advance.

  • I want to manage my pdf conversion to word account, but when I click on manage I get an error message saying Heading too Large.  How do I get into manage

    I want to manage my pdf conversion to word account, but when I click on manage I get an error message saying Heading too Large.  How do I get into manage

    Hi,
    May i know which service you are using?
    Would it be possible for you to send me the screenshot of the error?
    Regards,
    Florence

  • Automated report/ PDF conversion with AppleScript

    Hello-
    I am attempting to PDF a spreadsheet from Dropbox, and email it to a set list of recipients with AppleScript.  Much of this I have been able to figure out, but I am having some issues with the PDF conversion.  As you can see below, I am still working on sending the xls file, and have not yet been able to get AppleScript to convert a specific tab of the file to aPDF.  I expect scheduling to be handled theough crontab.
    Current script is as follows:
    tell application "Finder"
              set folderPath to folder "Macintosh HD:Users:user:Dropbox:folder:Calculated PO Sheet"
              set theFile to first file in folderPath as alias
              set fileName to name of theFile
    end tell
    set theSubject to "Current PO Report" date
    set theBody to "See attached."
    set theAddress to "recipient email"
    set theAttachment to "CALCULATED PO SHEET.xlsx"
    set theSender to "sender email"
    tell application "Mail"
              set theNewMessage to make new outgoing message with properties{subject:theSubject, content:theBody & return & return, visible:true}
              tell theNewMessage
                        set visibile to true
                        set sender to theSender
      make new to recipient at end of to recipients with properties {address:theAddress}
                        try
      make new attachment with properties {file name:theAttachment} at after the last word ofthe last paragraph
                                  set message_attachment to 0
                        on error errmess -- oops
      log errmess -- log the error
                                  set message_attachment to 1
                        end try
                        log "message_attachment = " & message_attachment
      #send
              end tell
    end tell

    Hi,
    there is a special setup for this requirement. Please see the following support note
    Reference
    Oracle Reports Output For Indian Languages Like Gujarati, Marathi [ID 980554.1]
    Roberto

  • Sending smartform output as PDF attachment, Error opening PDF attachment

    Hi Experts,
    I am using the code form the following link to send a smartform output as PDF attachment. I can able to see the message, but can not open PDF document.
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/convertSmartformtoPDFformat&
    The information should be on my smartform are some text, company logo and a barcode.
    With all of these received error: "There was an error opening this document. The file is damaged and could not be repaired."
    I tried different ways like only text, text with company logo, text with barcode. I got the following errors:
    An unrecognized token 'Td0' was found
    There was problem reading this document(16).
    There was problem reading this document(111).
    Does anyone have idea of these ? Your help is greatly appreciated.
    Thank you,
    Surya

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

Maybe you are looking for

  • How can I use comma in the return values of a static list of values

    Hi all, I want to create a select list (static LOV) like the following: Display Value / Return Value both are "Y" / 'YY' one is "Y" / 'YN','NY' I write the List of values definition is like this: STATIC:both are "Y"; 'YY',one is "Y";'YN', 'NY' Howeve

  • How can I get my photos off the old family album programme without buying a new photoshop programme?

    The pop up to register my adobe photshop starter edition keeps coming up on screen.  I have many family pictures I want to view, copy, print etc.  I cannot get the code to unlock it as it states this programme is no longer available and the links for

  • Display Macbbok Pro on TV

    Hello, I am a new Mac user, and I have the DVI adapter, and the DVI to HDMI adapter, now when I hook it up to the TV I want to display everything in 1080 on the TV, and just use the Macbook for the mouse, and keyboard, how do I do this ? I can get Mi

  • Named Pipes Provider, error: 40 - Could not open a connection to SQL Server

    This was originally posted in the SSIS Forum, but a member of the IS team suggested it be moved here.  "Most recently I got this error (Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) so does this mean that SQL Server is

  • Deploying old process in GA

    Hello, I installed GA and I´m trying to deploy my old BPEL processes into the Oracle BPEL GA Server but It gave me an Internal Server Error. Version incorrecta del esquema de base de datos. La version del esquema "2.0.37" de la base de datos no coinc