Disappearing text in .pdf attachment

I created a .pdf using Photoshop CS3. The original image is a .jpg to which I have added text.
The background to this is I want to send a (relatively) secure letter with company logo.
I attached it to a Mail message.
Mail (v2.1.1) automatically shows me the image (as it does with all graphic files) but the text that I put on it had disappeared.
I then sent it (to myself) The text was still missing.
I then saved it to my desktop and opened it with Adobe reader (v8.1.0). The text re-appeared.
I then opened the the file using Preview (v3.0.9) the text was gone again!
I think this a bug. Can I do anything about this?

Not necessarily a bug, but something different between how Adobe and Preview (and other OS X apps like Mail) handle displaying pdfs (I've noticed a few of these differences, actually).
Most likely the problem in your case is with layering (for example, many tiff image viewers do not support the layered tiff format that photoshop can create). You could try flattening the image before you save.
How did you create the pdf? Save As in CS3? If so, you could try the Print command and then save as a pdf from the button on the bottom, which would use OS X's pdf engine instead of Adobe's.
Let us know if this helps...

Similar Messages

  • Disappearing Text in PDF

    Hello,
    Thanks ahead of time for reading this, and for your help.
    I am in the process of filling out a very important (and, um, large) pdf issued by the IRS, and a very strange thing continues to happen.
    After I type text into fields (or check boxes), save the pdf, and then open it up again, the fields look blank. When I select the field in which I had previously typed, the text becomes visible once again. When I move the cursor into another field, however, the newly-visible text (which had been invisible) becomes invisible again. The text in the new field then becomes visible.
    I've been all over the web trying to find an answer to this problem, and although "disappearing text" seems to be an issue, I've been unable to find an answer.
    Thanks very much for your help.
    I'm using Adobe Acrobat 9.3.3

    Not necessarily a bug, but something different between how Adobe and Preview (and other OS X apps like Mail) handle displaying pdfs (I've noticed a few of these differences, actually).
    Most likely the problem in your case is with layering (for example, many tiff image viewers do not support the layered tiff format that photoshop can create). You could try flattening the image before you save.
    How did you create the pdf? Save As in CS3? If so, you could try the Print command and then save as a pdf from the button on the bottom, which would use OS X's pdf engine instead of Adobe's.
    Let us know if this helps...

  • Disappearing text in pdf form

    Hello,
    we have an application using pdf forms. The reader 9..1.0 reads some data and forms are filled out.
    there are 3 pages datas an 10 pages  for entering text. Each page contains automatically name and birth date of a patient, on the 10 pages the result of treatment is documented.
    Now, sometimes, after opening the text again and changing the text ( e.g. the patient goes home after a week and something has to be entered) the saved text is gone, instead the old text is there though it was said "save". Also some pages are missing ( of the old text )
    Furthermore, today I saw that there is a lot of text at the end of the form. Means, there are 10 pages text, let´s say 6 are filled, all have name and date filled out by our program but enough space to write on page 7. There is a button "reorganize text" and after that there is a message saying that the text is too large for the 10 pages and that the text is hidden. Indeed, all the text on page 7,8,9 and 10 is doubled from the beginning. when I tried to delete some text, there is again text and text and coming into the form and after an hour I could´n delete all the text which is "behind" the real text.
    my first thought was that somebody didn´t insert a text block for lets say 30 lines but copied the whole text several times. But the people working there are much experienced.
    So does anybode has a good inea? I know this is rather complicated but because these text are report of medical treament is is important that nothing is lost and that the text is okay. BTW it worked all the years starting with approval 5.0  over adobe 8 and now 9.
    thanks Joachim

    Export the form data from Menu > View > Tools > Forms > More Form Options > Manage Form Data and save (it will save as a pdf). Then import the form data again from the saved file.

  • PDF attachment for RFx

    Hi Experts,
    SRM 7 EHP1
    Everytime a RFx is created, email is triggered to bidder with detailed text and pdf attachment of the RFx. The email text is configured through document output.
    Please let me know if there is any configuration to control the creation of pdf attachment - ie no pdf should be attached to the email when the bidder is being notified?
    Thanks & Regards,
    Amish

    Hello,
    attachment to Bid document output is managed in standard by PROCESS_BBP_BID_MAI_BCS method from CL_PD_BID_PROCESSING_BBP class.
    See IMG: SAP Implementation Guide > SAP Supplier Relationship Management > SRM Server > Cross-Application Basic Settings > Set Output Actions and Output Format > Condition-Dependent Document Output.
    Regards.
    Laurent.

  • PDF attachment, text disappearing once opened.

    Hi Experts, I have been working on a smartform conversion to PDF email. I have inserted a gui download after the conversion process to check the pdf conversion. When opening the pdf that was downloaded, the pdf is perfect. However, once the pdf is emailed out of SAP to the microsoft exchange server and I open it in Outlook, only one block of text is present and if I scroll the page the text disappears. Has anyone encountered this problem and/or can someone help me fix it?
    Thanks,
    Chris

    Here is my code as of right now. The PDF email is saying the pdf is damaged or could not be repaired, when I try to open it.
    DATA: it_otf   TYPE STANDARD TABLE OF itcoo,
          it_docs  TYPE STANDARD TABLE OF docs,
          it_lines TYPE STANDARD TABLE OF tline WITH HEADER LINE,
          it_soli TYPE STANDARD TABLE OF tline,
          it_table TYPE STANDARD TABLE OF tline,
          st_job_output_info      TYPE ssfcrescl,
          st_document_output_info TYPE ssfcrespd,
          st_job_output_options   TYPE ssfcresop,
          st_output_options       TYPE ssfcompop,
          st_control_parameters   TYPE ssfctrlop,
          v_len_in                TYPE so_obj_len,
          v_language              TYPE sflangu VALUE 'E',
          v_e_devtype             TYPE rspoptype,
          v_bin_filesize          TYPE i,
          v_name                  TYPE string,
          v_path                  TYPE string,
          v_fullpath              TYPE string,
          v_filter                TYPE string,
          v_uact                  TYPE i,
          v_guiobj                TYPE REF TO cl_gui_frontend_services,
          v_filename              TYPE string,
          v_fm_name               TYPE rs38l_fnam.
      DATA:  pdf_length      TYPE i,
             doctab TYPE TABLE OF docs.
      DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
      i_tline TYPE TABLE OF tline WITH HEADER LINE,
      i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
      i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    Objects to send mail.
      DATA: i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
      i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
      it_mess LIKE solisti1 OCCURS 0 WITH HEADER LINE,
      wa_doc_data TYPE TABLE OF sodocchgi1 WITH HEADER LINE,
      it_pcklist TYPE TABLE OF sopcklsti1 WITH HEADER LINE,
      it_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
      tripdata TYPE  zps_appr_dissappr_wf,
      ziflo TYPE  iflo.
    Work Area declarations
      DATA: wa_objhead TYPE soli_tab,
      w_ctrlop TYPE ssfctrlop,
      w_compop TYPE ssfcompop,
      w_return TYPE ssfcrescl,
      wa_doc_chng TYPE sodocchgi1,
      w_data TYPE sodocchgi1,
      wa_buffer TYPE string."To convert from 132 to 255
    Variables declarations
      DATA: v_form_name TYPE rs38l_fnam,
      v_len_out LIKE sood-objlen,
      v_len_outn TYPE i,
      v_lines_txt TYPE i,
      v_lines_bin TYPE i,
      v_lines     TYPE i.
      DATA: itcpo LIKE itcpo,
            tab_lines LIKE sy-tabix.
    Variables for EMAIL functionality
      DATA: maildata   LIKE sodocchgi1.
      DATA: mailpack   LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
      DATA: mailhead   LIKE solisti1 OCCURS 1 WITH HEADER LINE.
      DATA: mailbin    LIKE solisti1 OCCURS 10 WITH HEADER LINE.
      DATA: mailtxt    LIKE solisti1 OCCURS 10 WITH HEADER LINE.
      DATA: mailrec    LIKE somlrec90 OCCURS 0  WITH HEADER LINE.
      DATA: solisti1   LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    *&      Form  smartform_email
          text
         -->C_FORMNAME text
      FORM smartform_email USING c_formname.
        CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
          EXPORTING
            i_language    = v_language
            i_application = 'SAPDEFAULT'
          IMPORTING
            e_devtype     = v_e_devtype.
        st_output_options-tdprinter = v_e_devtype.
    *st_output_options-tdprinter = 'locl'.
        st_control_parameters-no_dialog = 'X'.
        st_control_parameters-getotf = 'X'.
    .................GET SMARTFORM FUNCTION MODULE NAME.................
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
          EXPORTING
            formname           = c_formname
          IMPORTING
            fm_name            = v_fm_name
          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.
    ...........................CALL SMARTFORM............................
        CALL FUNCTION v_fm_name
          EXPORTING
            control_parameters   = st_control_parameters
            output_options       = st_output_options
            tripdata             = zps_appr_dissappr_wf
            ziflo                = iflo
          IMPORTING
            document_output_info = st_document_output_info
            job_output_info      = st_job_output_info
            job_output_options   = st_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.
        ELSE.
    .........................CONVERT TO OTF TO PDF.......................
          CALL FUNCTION 'CONVERT_OTF_2_PDF'
            IMPORTING
              bin_filesize           = v_bin_filesize
            TABLES
              otf                    = st_job_output_info-otfdata
              doctab_archive         = it_docs
              lines                  = it_lines
            EXCEPTIONS
              err_conv_not_possible  = 1
              err_otf_mc_noendmarker = 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.
    ........................GET THE FILE NAME TO STORE....................
          CONCATENATE 'Field Trip' '.pdf' INTO v_name.
          CREATE OBJECT v_guiobj.
          CALL METHOD v_guiobj->file_save_dialog
            EXPORTING
              default_extension = 'pdf'
              default_file_name = v_name
              file_filter       = v_filter
            CHANGING
              filename          = v_name
              path              = v_path
              fullpath          = v_fullpath
              user_action       = v_uact.
          IF v_uact = v_guiobj->action_cancel.
            EXIT.
          ENDIF.
    ..................................DOWNLOAD AS FILE....................
          MOVE v_fullpath TO v_filename.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              bin_filesize            = v_bin_filesize
              filename                = v_filename
              filetype                = 'BIN'
            TABLES
              data_tab                = it_lines
            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.
          IF sy-subrc <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
        ENDIF.
    convert pdf from 132 to 255.
        LOOP AT it_lines.
          TRANSLATE it_lines USING '~'.
          CONCATENATE wa_buffer it_lines INTO wa_buffer.
        ENDLOOP.
        TRANSLATE wa_buffer USING '~'.
        DO.
          i_record = wa_buffer.
          APPEND i_record.
          SHIFT wa_buffer LEFT BY 255 PLACES.
          IF wa_buffer IS INITIAL.
            EXIT.
          ENDIF.
        ENDDO.
    Attachment
        REFRESH:
        i_reclist,
        i_objtxt,
        i_objbin,
        i_objpack.
        CLEAR wa_objhead.
        i_objbin[] = i_record[].
    Create Message Body
    Title and Description
        i_objtxt = 'test with pdf-Attachment!'.
        APPEND i_objtxt.
        DESCRIBE TABLE i_objtxt LINES v_lines_txt.
        READ TABLE i_objtxt INDEX v_lines_txt.
        wa_doc_chng-obj_name = 'smartform'.
        wa_doc_chng-expiry_dat = sy-datum + 10.
        wa_doc_chng-obj_descr = 'smartform'.
        wa_doc_chng-sensitivty = 'F'.
        wa_doc_chng-doc_size = v_lines_txt * 255.
    Main Text
        wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + STRLEN( i_objtxt ).
        CLEAR i_objpack-transf_bin.
        i_objpack-head_start = 1.
        i_objpack-head_num = 0.
        i_objpack-body_start = 1.
        i_objpack-body_num = v_lines_txt.
    Attachment
    (pdf-Attachment)
        i_objpack-transf_bin = 'X'.
        DESCRIBE TABLE i_objbin LINES v_lines_bin.
        READ TABLE i_objbin INDEX v_lines_bin.
        i_objpack-doc_size = v_lines_bin * 255 .
        i_objpack-body_num = v_lines_bin.
        i_objpack-doc_type = 'PDF'.
        i_objpack-obj_name = 'smart'.
        i_objpack-obj_descr = 'test'.
        APPEND i_objpack.
        CLEAR i_reclist.
        i_reclist-receiver = '[email protected]'.
        i_reclist-rec_type = 'U'.
        APPEND i_reclist.
       CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
          EXPORTING
            document_data              = wa_doc_chng
            put_in_outbox              = 'X'
            commit_work                = 'X'
          TABLES
            packing_list               = i_objpack
            object_header              = wa_objhead
            contents_bin               = i_objbin
            contents_txt               = i_objtxt
            receivers                  = i_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.
      ENDFORM.                    "smartform_email

  • How do I add text message to this email with PDF attachment?

    Good day, everyone!
    Okay, we have a "z"-version of program RFFOUS_T and some of its include codes.  One include code, RFFORIO6, has a form called MAIL_PDF_ADVICE.  It is in this form that we are emailing a remittance advice form.  The actual form is attached as a PDF file.
    Unfortunately, there's no text in the body of the email -- it's just the attachment -- so the users would like us to add a couple basic lines in the body of the email that explain the attachment.  I'm pretty new to using this particular FM and emailing the PDF attachment, and I've gotten stuck in my research trying to find out exactly how to do this.  I'm guessing this shouldn't be all that difficult, but I'm not finding the right solution.  Here's the form:
    *&      Form  mail_pdf_advice
          E-mail PDF advice
         -->IT_ADVICE     PDF form (output from Adobe server)
         -->I_PDF_LEN     length of PDF advice in bytes
    FORM mail_pdf_advice USING it_advice   TYPE solix_tab
                               i_pdf_len   TYPE i.
      DATA:
        lt_receivers       TYPE TABLE OF somlreci1 WITH HEADER LINE,
        l_user             LIKE soextreci1-receiver,
        ls_send_doc        LIKE sodocchgi1,
        lt_pdf_attach      TYPE TABLE OF sopcklsti1 WITH HEADER LINE.
      CHECK NOT finaa-intad IS INITIAL.
      CHECK finaa-nacha EQ 'I'.
    *--- determine E-Mail sender and recipient
      IF fsabe-usrnam EQ space.
        l_user = sy-uname.
      ELSE.
        l_user = fsabe-usrnam.         "Office-User des Sachbearb.
      ENDIF.
      lt_receivers-receiver = finaa-intad.
      lt_receivers-rec_type = 'U'.      "E-mail address
      APPEND lt_receivers.
      ls_send_doc-obj_descr =  itcpo-tdtitle.
      lt_pdf_attach-transf_bin = 'X'.
      lt_pdf_attach-doc_type   = 'PDF'.
      lt_pdf_attach-obj_langu  = reguh-zspra.
      lt_pdf_attach-body_start = 1.
      lt_pdf_attach-doc_size   = i_pdf_len.
      DESCRIBE TABLE it_advice LINES lt_pdf_attach-body_num.
      APPEND lt_pdf_attach.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = ls_send_doc
          sender_address             = l_user
        TABLES
          packing_list               = lt_pdf_attach
          contents_hex               = it_advice
          receivers                  = lt_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.
    <error checking code snipped>
    Does someone know how to do this?  <b><REMOVED BY MODERATOR></b>  Thanks so much in advance!
    Dave
    Message was edited by:
            Alvaro Tejada Galindo

    Hi Dave,
    Table <b>contents_bin</b> is used to pass attachment file and <b>contents_txt</b> is used to pass mail body contents. You need to declare one more int table to give contents for mail body.
    For reference check the code below
    ut_message is for message body
    and ut_attach is having attachement file.
      FORM send_file_as_email_attachment TABLES ut_message
                                              ut_attach
                                        USING uv_email
                                              uv_mtitle
                                              uv_format
                                              uv_filename
                                              uv_attdescription
                                              uv_sender_address
                                              uv_sender_addres_type
                                     CHANGING uc_error
                                              uc_reciever.
      DATA:  l_error                TYPE  sy-subrc,
             l_reciever             TYPE  sy-subrc,
             l_mtitle               LIKE  sodocchgi1-obj_descr,
             l_email                LIKE  somlreci1-receiver,
             l_format               TYPE  so_obj_tp ,
             l_attdescription       TYPE  so_obj_nam ,
             l_attfilename          TYPE  so_obj_des ,
             l_sender_address       LIKE  soextreci1-receiver,
             l_sender_address_type  LIKE  soextreci1-adr_typ,
             l_receiver             LIKE  sy-subrc.
      DATA:   lt_packing_list    LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
              lt_contents        LIKE solisti1   OCCURS 0 WITH HEADER LINE,
              lt_receivers       LIKE somlreci1  OCCURS 0 WITH HEADER LINE,
              lt_attachment      LIKE solisti1   OCCURS 0 WITH HEADER LINE,
              lt_object_header   LIKE solisti1   OCCURS 0 WITH HEADER LINE,
              l_cnt TYPE i,
              l_sent_all(1) TYPE c,
              lw_doc_data LIKE sodocchgi1.
      l_email               = uv_email.
      l_mtitle              = uv_mtitle.
      l_format              = uv_format.
      l_attdescription      = uv_attdescription.
      l_attfilename         = uv_filename.
      l_sender_address      = uv_sender_address.
      l_sender_address_type = uv_sender_addres_type.
    Fill the document data.
      lw_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      lw_doc_data-obj_langu = sy-langu.
      lw_doc_data-obj_name  = 'SAPRPT'.
      lw_doc_data-obj_descr = l_mtitle.
      lw_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR lw_doc_data.
      READ TABLE ut_attach INDEX l_cnt.
      lw_doc_data-doc_size =
         ( l_cnt - 1 ) * 255 + STRLEN( ut_attach ).
      lw_doc_data-obj_langu  = sy-langu.
      lw_doc_data-obj_name   = 'SAPRPT'.
      lw_doc_data-obj_descr  = l_mtitle.
      lw_doc_data-sensitivty = 'F'.
      CLEAR lt_attachment.
      REFRESH lt_attachment.
      lt_attachment[] = ut_attach[].
    Describe the body of the message
      CLEAR lt_packing_list.
      REFRESH lt_packing_list.
      lt_packing_list-transf_bin = space.
      lt_packing_list-head_start = 1.
      lt_packing_list-head_num = 0.
      lt_packing_list-body_start = 1.
      DESCRIBE TABLE ut_message LINES lt_packing_list-body_num.
      lt_packing_list-doc_type = 'RAW'.
      APPEND lt_packing_list.
    Create attachment notification
      lt_packing_list-transf_bin = 'X'.
      lt_packing_list-head_start = 1.
      lt_packing_list-head_num   = 1.
      lt_packing_list-body_start = 1.
      DESCRIBE TABLE lt_attachment LINES lt_packing_list-body_num.
      lt_packing_list-doc_type   =  l_format.
      lt_packing_list-obj_descr  =  l_attdescription.
      lt_packing_list-obj_name   =  l_attfilename.
      lt_packing_list-doc_size   =  lt_packing_list-body_num * 255.
      APPEND lt_packing_list.
    Add the recipients email address
      CLEAR lt_receivers.
      REFRESH lt_receivers.
      lt_receivers-receiver = l_email.
      lt_receivers-rec_type = 'U'.
      lt_receivers-com_type = 'INT'.
      lt_receivers-notif_del = 'X'.
      lt_receivers-notif_ndel = 'X'.
      APPEND lt_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = lw_doc_data
          put_in_outbox              = 'X'
          commit_work                = 'X'
        IMPORTING
          sent_to_all                = l_sent_all
        TABLES
          packing_list               = lt_packing_list
          contents_bin               = lt_attachment
          contents_txt               = ut_message
          receivers                  = lt_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.
    Message was edited by:
            Amit Kumar

  • Why can't I "Save as Text" a pdf file received as an email attachment?

    I can "Save as text" a pdf file which I have created in my own computer (that is, it goes into MS notebook that I then can Copy and Save as an MS Word file) but not when I receive a pdf as an email attachment. (The file is saved, but it is empty.) Why would I want to convert my own pdf back to text? Well, in case I no longer have the original Word document I suppose, but the thing is "Save as text" works with my pdf, but not with those I recieve from others. How come? Thanks!

    Is this a scanned PDF? If so, it must first be OCR'd.

  • If email has a PDF attachment, I can't read the text portion of the email

    I noticed that if the message had a PDF attachment, then that icon is all I see. The text portion seems to have been ignored, although I can see it in the "preview" of the message. Very strange.
    Rgds
    Ken

    Have you tried to restart the phone? And how big is the PDF?

  • Want to Send smartform as pdf attachment with a Email to some mail id

    Hi ,
    I want to send a smartform as a PDF attachment with a mail to a mail id. And I can send a mail with the PDF attachment.
    But I am not able to open the PDF. It is throwing some error (Adobe reader could not open u2018fileu2019 because it is either not a supported file type or because the file has been damaged (for example , it was sent as an email attachment and was not correctly decoded)).
    By debugging I come to know that the file which is generating is in some encoding format.
    Please help me regard this. This is very urgent.
    here is the code,
    Main Program :
    REPORT Ztest_report.
    *--Top Include for Global Data Declarations.
    INCLUDE ztest_report_top.
    *--Form Include for Form Routines.
    INCLUDE ztest_report_form.
    START-OF-SELECTION.
    START-OF-SELECTION.
    *--Display data
      Perform display_data.
    END-OF-SELECTION.
    Top declaration :
    Internal table
    DATA :  i_otfdata TYPE tsfotf,          " Smart Forms: Table OTF
            i_tline TYPE TABLE OF tline WITH HEADER LINE,
            i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
            i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
            i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
            w_mailaddr TYPE ppfdmailad,
            w_mailtype TYPE so_escape,
            w_mailrecipient TYPE swotobjid,
            w_control TYPE ssfctrlop,
            w_compop TYPE ssfcompop,
            w_return TYPE ssfcrescl,
            wa_doc_chng TYPE sodocchgi1,
            w_data TYPE sodocchgi1,
            wa_buffer TYPE string, "To convert from 132 to 255
            wa_objhead TYPE soli_tab,
    Variables declarations
            v_form_name TYPE rs38l_fnam,
            v_len_in LIKE sood-objlen,
            v_len_out LIKE sood-objlen,
            v_len_outn TYPE i,
            v_lines_txt TYPE i,
            v_lines_bin TYPE i.
    Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-009.
    PARAMETER:      p_bukrs TYPE bukrs OBLIGATORY,            "Company Code
                    p_belnr TYPE belnr_d OBLIGATORY,          "Document No
                    p_gjahr TYPE gjahr OBLIGATORY,            "document type
                    p_mailid(50) TYPE c OBLIGATORY.
    "Mail Id
    SELECTION-SCREEN END OF BLOCK blk1.
    Form Logic :
    FORM display_data.
    *Local Variable declaration
      DATA: lc_fm TYPE rs38l_fnam,       "local variable to store the
            l_i_document_output_info TYPE ssfcrespd,
            l_i_struc_job_output_info TYPE ssfcrescl,
            l_i_struc_job_output_options TYPE ssfcrescl,
            i_lines TYPE TABLE OF tline WITH HEADER LINE,
            lv_job_output_info      TYPE ssfcrescl,
            lv_document_output_info TYPE ssfcrespd,
            lv_job_output_options   TYPE ssfcresop,
            lv_bin_filesize         LIKE sood-objlen.
    Determine the smartform name
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
           EXPORTING
                formname           = 'ZTEST_SMARTFORM'
           IMPORTING
                fm_name            = lc_fm
           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.
      w_control-getotf = 'X'.
      w_control-no_dialog = 'X'.
      w_control-preview = space.
    w_control-device = 'MAIL'.
    Call the smartform and pass the selection screen parameter
      CALL FUNCTION lc_fm
           EXPORTING
                control_parameters = w_control
                output_options     = w_compop
                user_settings      = 'X'
                t_bukrs            = p_bukrs
                t_belnr            = p_belnr
                t_gjahr            = p_gjahr
           IMPORTING
                job_output_info    = l_i_struc_job_output_info
           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.
    Moving the Smart Forms: Table OTF into an internal table
      i_otfdata[] = l_i_struc_job_output_info-otfdata[].
    CONVERT TO OTF TO PDF.
      CALL FUNCTION 'CONVERT_OTF'
           EXPORTING
                format                = 'PDF'
                max_linewidth         = 132
           IMPORTING
                bin_filesize          = lv_bin_filesize
           TABLES
                otf                   = i_otfdata
                lines                 = i_lines
           EXCEPTIONS
                err_max_linewidth     = 1
                err_format            = 2
                err_conv_not_possible = 3
                err_bad_otf           = 4
                OTHERS                = 5.
    IF sy-batch EQ l_c_no.
    To directly view the print-preview in PDF format
      CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'
           EXPORTING
                i_otf                    = i_otfdata
           EXCEPTIONS
                convert_otf_to_pdf_error = 1
                cntl_error               = 2
                OTHERS                   = 3.
    For Sending the PDF file to a Mail ID.
    LOOP AT i_lines.
       TRANSLATE i_lines USING '~'.
       CONCATENATE wa_buffer i_lines INTO wa_buffer.
    ENDLOOP.
    TRANSLATE wa_buffer USING '~'.
    DO.
       i_record = wa_buffer.
       APPEND i_record.
       SHIFT wa_buffer LEFT BY 255 PLACES.
       IF wa_buffer IS INITIAL.
         EXIT.
       ENDIF.
    ENDDO.
      DATA: BEGIN OF zlines OCCURS 0,
      tline TYPE char255,
      END OF zlines.
    *Change the PDF format from 132 to 255.
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
           EXPORTING
                transfer_bin                = 'X'
           TABLES
                content_in                  = i_lines
                content_out                 = zlines
           EXCEPTIONS
                err_line_width_src_too_long = 1
                err_line_width_dst_too_long = 2
                err_conv_failed             = 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.
    Attachment
      REFRESH: i_reclist,
      i_objtxt,
      i_objbin,
      i_objpack.
      CLEAR wa_objhead.
      i_objbin[] = zlines[].
    Create Message Body Title and Description
      i_objtxt = 'test with pdf-Attachment!'.
      APPEND i_objtxt.
      DESCRIBE TABLE i_objtxt LINES v_lines_txt.
      READ TABLE i_objtxt INDEX v_lines_txt.
      wa_doc_chng-obj_name = 'smartform'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr = 'smartform'.
      wa_doc_chng-sensitivty = 'F'.
      wa_doc_chng-doc_size = v_lines_txt * 255.
    Main Text
      CLEAR i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num = 1.
      i_objpack-body_start = 2.
      i_objpack-body_num = v_lines_txt.
      i_objpack-doc_type = 'RAW'.
      APPEND i_objpack.
    Attachment (pdf-Attachment)
      i_objpack-transf_bin = 'X'.
      i_objpack-head_start = 1.
      i_objpack-head_num = 1.
      i_objpack-body_start = 2.
    I_OBJPACK-DOC_TYPE = 'RAW'.
      DESCRIBE TABLE i_objbin LINES v_lines_bin.
      READ TABLE i_objbin INDEX v_lines_bin.
      i_objpack-doc_size = v_lines_bin * 255 .
      i_objpack-body_num = v_lines_bin.
      i_objpack-doc_type = 'PDF'.
      i_objpack-obj_name = 'smart'.
      i_objpack-obj_descr = 'test'.
      APPEND i_objpack.
      CLEAR i_reclist.
      i_reclist-receiver = p_mailid.
      i_reclist-rec_type = 'U'.
      APPEND i_reclist.
    Send new document with attachments via RFC
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                document_data              = wa_doc_chng
                put_in_outbox              = 'X'
                commit_work                = 'X'
           TABLES
                packing_list               = i_objpack
                object_header              = wa_objhead
                contents_bin               = i_objbin
                contents_txt               = i_objtxt
                receivers                  = i_reclist
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
      IF sy-subrc <> 0.
        WRITE:/ 'Error When Sending the File', sy-subrc.
      ELSE.
        WRITE:/ 'Mail sent'.
      ENDIF.
    ENDFORM.                    " display_data

    hi,
    i wrote a programm.for me it is working.i think it will help for u.
    DATA: t_otfdata TYPE ssfcrescl,
          t_lines LIKE tline OCCURS 0 WITH HEADER LINE,
          t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
          t_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
    Objects to send mail.
    DATA:T_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
         T_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
         T_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
         T_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.
    DATA: w_filesize TYPE i,
          w_bin_filesize TYPE i,
          wa_ctrlop TYPE ssfctrlop,
          wa_outopt TYPE ssfcompop,
          WA_BUFFER TYPE STRING,          "To convert from 132 to 255
          WA_OBJHEAD TYPE SOLI_TAB,
          WA_DOC_CHNG TYPE SODOCCHGI1,
          W_DATA TYPE SODOCCHGI1.
    DATA: form_name TYPE rs38l_fnam,
          V_LINES_TXT TYPE I,
          V_LINES_BIN TYPE I,
          nast-spras type sy-langu value 'DE'.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME                 = 'ZSR_DEMO1'
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
    IMPORTING
       FM_NAME                  = form_name
    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.
    wa_ctrlop-LANGU = nast-spras.
    wa_ctrlop-getotf = 'X'.
    wa_ctrlop-no_dialog = 'X'.
    wa_outopt-tdnoprev = 'X'.
    CALL FUNCTION form_name
      EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
       CONTROL_PARAMETERS         = wa_ctrlop
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
       OUTPUT_OPTIONS             = wa_outopt
       USER_SETTINGS              = 'X'
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
       JOB_OUTPUT_INFO            = t_otfdata
      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.
    t_otf[] = t_otfdata-otfdata[].
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
       FORMAT                      = 'PDF'
       MAX_LINEWIDTH               = 132
      ARCHIVE_INDEX               = ' '
      COPYNUMBER                  = 0
      ASCII_BIDI_VIS2LOG          = ' '
      PDF_DELETE_OTFTAB           = ' '
    IMPORTING
       BIN_FILESIZE                = w_bin_filesize
      BIN_FILE                    =
      TABLES
        OTF                         = t_otf
        LINES                       = t_lines
    EXCEPTIONS
       ERR_MAX_LINEWIDTH           = 1
       ERR_FORMAT                  = 2
       ERR_CONV_NOT_POSSIBLE       = 3
       ERR_BAD_OTF                 = 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.
    loop at t_lines.
    TRANSLATE t_lines USING '~'.
      CONCATENATE WA_BUFFER T_LINES INTO WA_BUFFER.
    ENDLOOP.
    TRANSLATE WA_BUFFER USING '~'.
    DO.
      t_RECORD = WA_BUFFER.
      APPEND t_RECORD.
      SHIFT WA_BUFFER LEFT BY 255 PLACES.
      IF WA_BUFFER IS INITIAL.
        EXIT.
      ENDIF.
    ENDDO.
    Attachment
    REFRESH: T_RECLIST,
    T_OBJTXT,
    T_OBJBIN,
    T_OBJPACK.
    CLEAR WA_OBJHEAD.
    T_OBJBIN[] = T_RECORD[].
    Create Message Body Title and Description
    T_OBJTXT = 'test with pdf-Attachment!'.
    APPEND T_OBJTXT.
    DESCRIBE TABLE T_OBJTXT LINES V_LINES_TXT.
    READ TABLE T_OBJTXT INDEX V_LINES_TXT.
    WA_DOC_CHNG-OBJ_NAME = 'smartform'.
    WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
    WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
    WA_DOC_CHNG-SENSITIVTY = 'F'.
    WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
    Main Text
    CLEAR T_OBJPACK-TRANSF_BIN.
    T_OBJPACK-HEAD_START = 1.
    T_OBJPACK-HEAD_NUM = 0.
    T_OBJPACK-BODY_START = 1.
    T_OBJPACK-BODY_NUM = V_LINES_TXT.
    T_OBJPACK-DOC_TYPE = 'RAW'.
    APPEND T_OBJPACK.
    Attachment (pdf-Attachment)
    T_OBJPACK-TRANSF_BIN = 'X'.
    T_OBJPACK-HEAD_START = 1.
    T_OBJPACK-HEAD_NUM = 0.
    T_OBJPACK-BODY_START = 1.
    DESCRIBE TABLE T_OBJBIN LINES V_LINES_BIN.
    READ TABLE T_OBJBIN INDEX V_LINES_BIN.
    T_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
    T_OBJPACK-BODY_NUM = V_LINES_BIN.
    T_OBJPACK-DOC_TYPE = 'PDF'.
    T_OBJPACK-OBJ_NAME = 'smart'.
    T_OBJPACK-OBJ_DESCR = 'test'.
    APPEND T_OBJPACK.
    CLEAR T_RECLIST.
    T_RECLIST-RECEIVER = 'mail id'.
    T_RECLIST-REC_TYPE = 'U'.
    APPEND T_RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA              = WA_DOC_CHNG
        PUT_IN_OUTBOX              = 'X'
        COMMIT_WORK                = 'X'
      TABLES
        PACKING_LIST               = T_OBJPACK
        OBJECT_HEADER              = WA_OBJHEAD
        CONTENTS_BIN               = T_OBJBIN
        CONTENTS_TXT               = T_OBJTXT
        RECEIVERS                  = T_RECLIST
      EXCEPTIONS
        TOO_MANY_RECEIVERS         = 1
        DOCUMENT_NOT_SENT          = 2
        DOCUMENT_TYPE_NOT_EXIST    = 3
        OPERATION_NO_AUTHORIZATION = 4
        PARAMETER_ERROR            = 5
        X_ERROR                    = 6
        ENQUEUE_ERROR              = 7
        OTHERS                     = 8.
    IF SY-SUBRC <> 0.
      WRITE:/ 'Error When Sending the File', SY-SUBRC.
    ELSE.
      WRITE:/ 'Mail sent'.
    ENDIF.
    please reward me if helpful.

  • Email Invoices to customer as a PDF attachment

    Hi,
    I have a requirement as follows:-
    SAP will get multiple invoice numbers from an external system. I need to send all the invoices(for a given customer) in one pdf and email it to the customer  as an attachment.
    Please provide your expert and detailed advice.
    Thanks,
    Ani

    Hi Ani,
    Go through this u definetly got ur solution.
    Here is the code to send the Smartform to mail as PDF attachment.
    *& Report ZTEST_NREDDY_PDF_MAIL
    REPORT ZTEST_NREDDY_PDF_MAIL.
    Internal Table declarations
    DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
    I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
    I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
    I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    WA_OBJHEAD TYPE SOLI_TAB,
    W_CTRLOP TYPE SSFCTRLOP,
    W_COMPOP TYPE SSFCOMPOP,
    W_RETURN TYPE SSFCRESCL,
    WA_DOC_CHNG TYPE SODOCCHGI1,
    W_DATA TYPE SODOCCHGI1,
    WA_BUFFER TYPE STRING, "To convert from 132 to 255
    Variables declarations
    V_FORM_NAME TYPE RS38L_FNAM,
    V_LEN_IN LIKE SOOD-OBJLEN,
    V_LEN_OUT LIKE SOOD-OBJLEN,
    V_LEN_OUTN TYPE I,
    V_LINES_TXT TYPE I,
    V_LINES_BIN TYPE I.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    FORMNAME = 'ZTEST'
    IMPORTING
    FM_NAME = V_FORM_NAME
    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.
    W_CTRLOP-GETOTF = 'X'.
    W_CTRLOP-NO_DIALOG = 'X'.
    W_COMPOP-TDNOPREV = 'X'.
    CALL FUNCTION V_FORM_NAME
    EXPORTING
    CONTROL_PARAMETERS = W_CTRLOP
    OUTPUT_OPTIONS = W_COMPOP
    USER_SETTINGS = 'X'
    IMPORTING
    JOB_OUTPUT_INFO = W_RETURN
    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.
    I_OTF[] = W_RETURN-OTFDATA[].
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT = 'PDF'
    MAX_LINEWIDTH = 132
    IMPORTING
    BIN_FILESIZE = V_LEN_IN
    TABLES
    OTF = I_OTF
    LINES = I_TLINE
    EXCEPTIONS
    ERR_MAX_LINEWIDTH = 1
    ERR_FORMAT = 2
    ERR_CONV_NOT_POSSIBLE = 3
    OTHERS = 4.
    IF SY-SUBRC <> 0.
    ENDIF.
    LOOP AT I_TLINE.
    TRANSLATE I_TLINE USING '~'.
    CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
    ENDLOOP.
    TRANSLATE WA_BUFFER USING '~'.
    DO.
    I_RECORD = WA_BUFFER.
    APPEND I_RECORD.
    SHIFT WA_BUFFER LEFT BY 255 PLACES.
    IF WA_BUFFER IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    Attachment
    REFRESH: I_RECLIST,
    I_OBJTXT,
    I_OBJBIN,
    I_OBJPACK.
    CLEAR WA_OBJHEAD.
    I_OBJBIN[] = I_RECORD[].
    Create Message Body Title and Description
    I_OBJTXT = 'test with pdf-Attachment!'.
    APPEND I_OBJTXT.
    DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
    READ TABLE I_OBJTXT INDEX V_LINES_TXT.
    WA_DOC_CHNG-OBJ_NAME = 'smartform'.
    WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
    WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
    WA_DOC_CHNG-SENSITIVTY = 'F'.
    WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
    Main Text
    CLEAR I_OBJPACK-TRANSF_BIN.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    I_OBJPACK-BODY_NUM = V_LINES_TXT.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    APPEND I_OBJPACK.
    Attachment (pdf-Attachment)
    I_OBJPACK-TRANSF_BIN = 'X'.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
    READ TABLE I_OBJBIN INDEX V_LINES_BIN.
    I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
    I_OBJPACK-BODY_NUM = V_LINES_BIN.
    I_OBJPACK-DOC_TYPE = 'PDF'.
    I_OBJPACK-OBJ_NAME = 'smart'.
    I_OBJPACK-OBJ_DESCR = 'test'.
    APPEND I_OBJPACK.
    CLEAR I_RECLIST.
    I_RECLIST-RECEIVER = '[email protected]'.
    I_RECLIST-REC_TYPE = 'U'.
    APPEND I_RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    COMMIT_WORK = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_RECLIST
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    OTHERS = 8.
    IF SY-SUBRC <> 0.
    WRITE:/ 'Error When Sending the File', SY-SUBRC.
    ELSE.
    WRITE:/ 'Mail sent'.
    ENDIF.
    If you want to send some text as Body of the Mail then follow this once
    when u r callin the FM'SO_NEW_DOCUMENT_ATT_SEND_API1'.. points to remember
    1.u have to pass the body of content in table CONTENTS_TXT(ia m using I_OBJBIN) (each line a record) then. suppose i have appended 11 records to the table CONTENTS_TXT .
    2.PACKING_LIST(iam usign I_OBJPACK) table u ahve to append a redord as follows
    I_OBJPACK-TRANSF_BIN = ' '.
    I_OBJPACK-HEAD_START = 000000000000001.
    I_OBJPACK-HEAD_NUM = 000000000000001.
    I_OBJPACK-BODY_START = 000000000000002
    I_OBJPACK-BODY_NUM = 000000000000010.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    append I_OBJPACK-.
    by the above code system treat the first line in table I_OBJBIN as header and the 2nd line to 10 lines tread as body.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_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.
    Reward points if helpful.
    Thanks
    Naveen khan

  • Sending an email of the layout in PDF attachement

    Hello All,
    I have written a program to send the layout in PDF format to send in a mail to the customer.
    The email is going fne with the PDF attachement in the development box, but it is not working in Quality box.
    In the Quality box the email is going but the attachement is not opening.
    I have used CONVERT_OTF function module for converting OTF format to PDF format. As per my analysis it is returning the PDF format properly in Developement box but not the same in Quality. In Quality the the data returning in PDF format is not in proper manner. It is giving some junk data with symbols like traingle, rectange..etc..
    I am using FM SO_OBJECT_SEND for sending an email.
    Can you please suggest me what may be problem?
    Valuable answers will be rewarded.
    Thanks & Regards,
    Satish.

    Hi,
    you need to save the File in PDF format not in the text format.
    check whether the file is saved in pdf format or not.
    Regards,
    Raj.

  • Smartform to OTF to PDF attached to an email ERROR

    Hi everyone... I have this problem... I need to send a smartform attached to an email... I'm doing the following:
    - Create the OTF using the smartform function importing job_output_info.
    - Convert the OTF (job_output_info-otfdata) to PDF using CONVERT_OTF_2_PDF.
    - Change the table line's width using SX_TABLE_LINE_WIDTH_CHANGE.
    - Send the email using SO_NEW_DOCUMENT_ATT_SEND_API1.
    Everything seems to be OK. But When I check the PDF file attached in the email and open it, everything there is a mess. The letters are superimposed over each other and the grills are not painted (instead it shows a black block).
    Any ideas how to solve this???
    Thanks a lot!!!

    Try this out..!
    <removed by moderator>
    To convert the script out put to PDF.
    CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF' u201C FOR out put format
          max_linewidth         = 132 u201CFor ASCII format: Number of lines in LINES-TDLINE
        IMPORTING
          bin_filesize          = gv_bin_filesize u201CFile size reference
        TABLES
          otf                   = gt_otf u201CInput table with OTF format
          lines                 = gt_pdf_tab " Output table with target format
    To mail Order in PDF format:
    Data declaration part :
    DATA: gt_reclist TYPE TABLE OF somlreci1, " SAPoffice: Structure of the API Recipient List
           gt_pdf_tab TYPE TABLE OF tline, " SAPscript: Text Lines
           gt_otf TYPE TABLE OF itcoo, " OTF Structure
           gt_objbin TYPE TABLE OF solisti1, " SAPoffice: Single List with Column Length 255
           gt_objpack TYPE TABLE OF sopcklsti1. " SAPoffice: Description of Imported Object Components
    DATA: gv_form_name TYPE rs38l_fnam, " Used to store the function module generated by Smartform
    gv_bin_filesize TYPE i, " Store the file size
    gv_pos TYPE i,
    gv_len TYPE i,
    gv_tab_lines TYPE i.
    DATA : gc_text(11) TYPE c VALUE 'Form Output',
    gc_tst(3) TYPE c VALUE 'TST',
    gc_testing(30) TYPE c VALUE 'Zellar Sales Document'.
    1. Assigning the Description of the object sent in the mail
      CLEAR gs_docdata.
      gs_docdata-obj_name = gc_tst.
      gs_docdata-obj_descr = gc_testing.
    Assigning the email id to Structure of the API Recipient List table
      CLEAR : gt_reclist, gs_reclist. u201C variables used
      gs_reclist-receiver = mail address'. u201CTo whom this mail should go
      GS_RECLIST-REC_TYPE = 'U'.
      APPEND gs_reclist TO gt_reclist. u201C Internal table for storing mail address
    2.Passing the Smart form  text lines to SAP office: Single List with Column Length 255 table ,this logic is used to get all the data into PDF file while you send an attachment through mail..
    CLEAR: gs_objbin, gs_pdf_tab.
      LOOP AT gt_pdf_tab INTO gs_pdf_tab. u201CLoop the content of PDF table
        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. u201CTable contains Single List with Column Length 255 table
      ENDIF.
    3. 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 = 'ATTACHMENT'.
        gs_objpack-obj_descr = 'test'.
        APPEND gs_objpack TO gt_objpack.
      ENDIF.
    4. Sending the Form Output in the PDF format to email
    data: WK_OBJHEAD TYPE SOLI_TAB.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' u201Cfunction module used for sending mail
        EXPORTING
          document_data              = gs_docdata u201CAttributes of new document
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = gt_objpack u201CInformation about structure of data tables
          OBJECT_HEADER              = WK_OBJHEAD u201CHeader data for document (spec.header)
          contents_bin               = gt_objbin   u201CData which is to be sent as pdf attachment
          receivers                  = gt_reclist  u201Cmailing list
        EXCEPTIONS                                 u201CException Handling
          too_many_receivers         = 1 
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        WRITE 'Sent Successfully'.
      ENDIF.
    Edited by: Thomas Zloch on Jul 16, 2010 10:38 PM

  • Naming of the PDF attachment when mailing from Bursting engine

    Hi,
    We have a xml publisher report for which we have implemented Bursting Engine to archive the and burst the PDF output.
    We have a requirement now to send the PDF output as attachment to external email ids(to suppliers).I am trying to test using e the below control file to send the PDFs as attachments but the name of the PDF attachment in the mail is numeric '3','6','9' etc...
    I would like to know how do we name the PDF output attachment of the bursting engine.
    -------------------------Burst Control File------------------------------------------
    <xapi:requestset xmlns:xapi="http://xmlns.oracle.com/oxp/xapi" type="bursting">
    <xapi:globalData location="stream">
    </xapi:globalData >
    <xapi:request select="/XXX_XMLPUB_ARINV/LIST_G_INVOICES/G_INVOICES">
    <xapi:delivery>
    <xapi:email server="127.0.0.1"
    port="25"
    from="[email protected]"
    reply-to="[email protected]"
    >
    <xapi:message id="123"
    to="${PURCHASE_ORDER_NUM}"
    bcc=""[email protected]""
    attachment="true"
    subject="${TRX_NUMBER}"
    >
    <html><body>test</body></html>
    </xapi:message>
    </xapi:email>
    </xapi:delivery>
    <xapi:document output-type="pdf" delivery="123">
    <xapi:template type="rtf" location="${XMLPUB_RTF_TEMPLATE}" filter=".//G_INVOICES[PRINTING_COUNT='0']">
    </xapi:template>
    </xapi:document>
    </xapi:request>
    </xapi:requestset>
    Thanks,
    Krishnan
    Edited by: Krishnan-Apps on Dec 23, 2009 2:30 AM

    Hi,
    I seriously doubt your control file is a working one. Can you upload your working/correctly formatted file?
    Or check this working sample below. Hope this helps.
    <?xml version="1.0" encoding="UTF-8"?>
    <xapi:requestset xmlns:xapi="http://xmlns.oracle.com/oxp/xapi">
    <xapi:request select="/">
         <xapi:delivery>
           <xapi:email server="xxmail.mail.com" port="25" from="[email protected]" reply-to ="[email protected]">
             <xapi:message id="${TRX_NUMBER}" to="[email protected]" cc="" bcc=""
              attachment="true" content-type="text/html" subject="${TRX_TYPE_NAME} Number ${TRX_NUMBER}">
           </xapi:message>
           </xapi:email>
         </xapi:delivery>
         <xapi:document output="Invoice_Number_${TRX_NUMBER}" output-type="pdf" delivery="${TRX_NUMBER}">
           <xapi:template type="rtf" location="xdo://AR.XXRAXINV_SEL.en.US/?getSource=true" filter="">
           </xapi:template>
         </xapi:document>
    </xapi:request>
    </xapi:requestset>regards,
    Rownald

  • Error while opening the Pdf Attachment  at the time sending mail ..

    Hi Frn's ,
       i am sending a mail with pdf attachment ... but the pdf is not opening ...it is giving error "There was and error opening this document . This file can not be open because it has no page ."
    Please resolve the problem ...below is the code pasted ..
    REPORT  ZPRI_TEST_LDB.
    DATA: it_pdf LIKE tline OCCURS 0 WITH HEADER LINE .
    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.
    DATA:  w_recsize TYPE i.
    DATA: gd_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.
    data:     gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    PARAMETER: p_email1 LIKE somlreci1-receiver
                                        DEFAULT 'abc,
              p_sender LIKE somlreci1-receiver
                                        DEFAULT 'abc'.
    perform write_output .
    perform create_pdf .
    PERFORM process_email .
    FORM WRITE_OUTPUT .
      write:'Listed below are the employees in your area who are due a Performance Appraisal'.
      write:'during the month of May 2009 .A performance appraisal form can be found on-line'.
      write: 'in the MUD template section .The Performance Appraisal is to be completed and' .
      write:'discussed with the employee by the immediate supervisor .Signed forms should be '.
      write: 'returned to the Human Resource Department by May 31,2009 .'.
      skip 2 .
      write: 'employee name' .
      write: 'Job Date' .
      write: 'Date of last appraisal' .
    ENDFORM.                    " WRITE_OUTPUT
    FORM CREATE_PDF .
      DATA:  spoolno LIKE tsp01-rqident.
      DATA : p_repid LIKE sy-repid .
      DATA: v_len  TYPE i , v_len1  TYPE i .
      DATA: v_temp(8) TYPE c .
      DATA: p_uname LIKE sy-uname .
      DATA: it_tsp01 TYPE STANDARD TABLE OF tsp01 WITH HEADER LINE .
    DATA: it_pdf LIKE tline OCCURS 0 WITH HEADER LINE .
      TABLES: tsp01.
      data: var  type c .
    *-- STRUCTURES
      DATA:
        lc_rq2name LIKE tsp01-rq2name.
      DATA:
        mstr_print_parms LIKE pri_params,
        mc_valid(1)      TYPE c,
        mi_bytecount     TYPE i,
        mi_length        TYPE i,
        mi_rqident       LIKE tsp01-rqident.
    *-- INTERNAL TABLES
      DATA:
        mtab_pdf    LIKE tline OCCURS 0 WITH HEADER LINE,
        mc_filename LIKE rlgrap-filename.
    *-- SELECTION SCREEN
      DATA:
        p_linsz LIKE sy-linsz VALUE 132, " Line size
        p_paart LIKE sy-paart VALUE 'X_65_132'.  " Paper Format
    *-- 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.
    *-- 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.
    importing variable value set at first time to restrict the infinite loop .
      IMPORT var FROM MEMORY ID 'abc' .
      var = var + 1 .
      p_uname = sy-uname .
      p_repid = sy-repid .
    *checking variable to restricted scecond time exction of this block of code
      IF var = 1 .
       v_memid = 1 .
        EXPORT var TO MEMORY ID 'abc' .
    start ----p3d(02/13/2009)
    EXPORT it_pernr it_pernr_quali v_memid it_pernr_status
               p_file  p_file1 rb_pres rb_app rb2 TO MEMORY ID 'bcd' .
       EXPORT it_pernr it_pernr_quali v_memid it_pernr_status it_notqualified
                        p_file  p_file1 rb_pres rb_app rb1 rb2 rb3 rb4 TO MEMORY ID 'bcd' .
        EXPORT it_pernr it_pernr_quali v_memid it_pernr_status it_notqualified
                    p_file  p_file1 rb_pres rb_app rb3 rb4 TO MEMORY ID 'bcd' .
    end ----p3d(02/13/2009)
    submitting the spool request
        SUBMIT (p_repid) TO SAP-SPOOL
                         SPOOL PARAMETERS mstr_print_parms
                         WITHOUT SPOOL DYNPRO
                         AND RETURN.
      ENDIF.
      FREE MEMORY ID 'abc'.
      FREE MEMORY ID 'bcd'.
    *Calculating the lenth of report name
      v_len = STRLEN( p_repid ) .
    *consutrucing the database variable  rq2name to search the spool request
      IF v_len >= 9 .
        CONCATENATE p_repid+0(9)
                    p_uname+0(3) INTO lc_rq2name .
      ELSE.
        v_len1 = 9 - v_len .
        DO v_len1 TIMES .
          CONCATENATE v_temp '_' INTO v_temp .
        ENDDO.
        CONCATENATE p_repid v_temp
                    p_uname INTO lc_rq2name .
      ENDIF.
    *selecting the spool request using the above consructed varibale
      SELECT * FROM tsp01 INTO TABLE it_tsp01
              WHERE rq2name = lc_rq2name .
    *sorting the interbla table
      SORT  it_tsp01 BY rqcretime DESCENDING .
    *reading the first spool request
      READ TABLE it_tsp01 INDEX 1.
    *converting the spool request into pdf
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
        EXPORTING
          src_spoolid              = it_tsp01-rqident
         dst_device               = 'LP01'
        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.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    CHECK sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf.
        TRANSLATE it_pdf USING ' ~'.
        CONCATENATE gd_buffer it_pdf INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.                    " CREATE_PDF
    FORM SEND_eMAIL using p_email .
    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.                    " SEND_MAIL
    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_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.
    Thanks and Regards ..
    Priyank

    hi this is the part of code ...
    PERFORM process_email .
    CHECK sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf.
        TRANSLATE it_pdf USING ' ~'.
        CONCATENATE gd_buffer it_pdf INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.                    " CREATE_PDF
    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 using p_email .
    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.                    " SEND_MAIL
    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.

  • Error when reading a pdf attachment file in sap inbox

    Hi all,
    I have created a RFC which sends mail from an external user to my sap inbox with attachment.
    the problem is with the PDF attachment where when i received the mail in my sap inbox in sbwp, it says that there is an error that it wasnt correctly decode.
    I used the class cl_document_bcs...
    and used the method add_attachment...
    would plz help me out

    this is my code
    FUNCTION ZMAIL_READ.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(SUBJECT) TYPE  SO_OBJ_DES
    *"     VALUE(TEXT) TYPE  STRING
    *"     VALUE(SENDER) TYPE  ADR6-SMTP_ADDR
    *"     VALUE(RECEIVER) TYPE  ADR6-SMTP_ADDR
    *"     VALUE(ATTACHMENTS) TYPE  Z_T_XATTACH OPTIONAL
    *"  EXPORTING
    *"     VALUE(MESSAGE) TYPE  STRING
    DATA: lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,
          lo_bcs_send_request TYPE REF TO cl_bcs,
          l_send type ADR6-SMTP_ADDR ,
          l_rec type  ADR6-SMTP_ADDR .
    data: it_text type table of soli,
          wa_text type soli.
    DATA: lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
    DATA: lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.
    DATA: lv_recipient_uid TYPE uname,
          lv_recipient_mail TYPE adr6-smtp_addr.
    data: lo_message type ref to cx_send_req_bcs value is initial,
          text_val type string.
    data: it_userlist type table of BAPIUSNAME,
          wa_userlist type BAPIUSNAME.
    data: it_selection_range type table of BAPIUSSRGE,
          wa_selection_range type BAPIUSSRGE.
    data: wa_attachment TYPE ZXATTACH,
          attachment_sub type SO_OBJ_DES.
    DATA: xstr type xstring,
          str TYPE string,
          str1 type string,
          it_str2 type table of soli,
          wa_STR2 TYPE SOLI.
    DATA: LOC_CONV TYPE REF TO CL_ABAP_CONV_IN_CE,
          wa_solix type solix,
          it_solix type table of solix,
          wa_soli type soli,
          it_soli type table of soli.
    data result TYPE boolean.
    data: i_ext(10) type c,
          i_type type soodk-objtp.
    wa_text-line = text.
    append wa_text to it_text.
    CLASS cl_bcs DEFINITION LOAD.
    try.
    lo_send_request = cl_bcs=>create_persistent( ).
    catch cx_send_req_bcs.
    endtry.
    * Message body and subject
    data: lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
    try.
    lo_document = cl_document_bcs=>create_document(
         i_type = 'RAW'
         i_text =  it_text
         i_subject = subject ).
    catch cx_send_req_bcs.
    catch cx_document_bcs.
    catch cx_address_bcs.
    endtry.
    loop at attachments into wa_attachment.
    attachment_sub = wa_attachment-file_name.
    it_str2 = wa_attachment-attach.
    loop at it_str2 into wa_str2.
      str1 = wa_str2-line.
    try.
    CALL FUNCTION 'SSFC_BASE64_DECODE'
      EXPORTING
        B64DATA                        = str1
    *   B64LENG                        =
    *   B_CHECK                        =
      IMPORTING
        BINDATA                        = xstr
    * EXCEPTIONS
    *   SSF_KRN_ERROR                  = 1
    *   SSF_KRN_NOOP                   = 2
    *   SSF_KRN_NOMEMORY               = 3
    *   SSF_KRN_OPINV                  = 4
    *   SSF_KRN_INPUT_DATA_ERROR       = 5
    *   SSF_KRN_INVALID_PAR            = 6
    *   SSF_KRN_INVALID_PARLEN         = 7
    *   OTHERS                         = 8
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    catch cx_sy_dyn_call_illegal_type.
    endtry.
    CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
          EXPORTING
            INPUT       = xstr
            ENCODING    = 'UTF-8'
    *        REPLACEMENT = '?'
    *        IGNORE_CERR = ABAP_TRUE
          RECEIVING
            CONV        = loc_CONV.
    TRY.
        CALL METHOD LOC_CONV->READ
          IMPORTING
            DATA = STR.
    CATCH CX_SY_CONVERSION_CODEPAGE.
    CATCH CX_SY_CODEPAGE_CONVERTER_INIT.
    CATCH CX_PARAMETER_INVALID_TYPE.
    CATCH CX_PARAMETER_INVALID_RANGE.
    ENDTRY.
    wa_solix-line = xstr.
    append wa_solix to it_solix.
    wa_soli-line = str.
    append wa_soli to it_soli.
    endloop.
    try.
    CALL FUNCTION 'SA_KW_RFC_FILENAME_EXT_GET'
      EXPORTING
       AREA            = 'IWBSOLAR'
        MIMETYPE        = wa_attachment-type
    IMPORTING
       EXTENSION       = i_ext
    catch cx_sy_dyn_call_illegal_type.
    endtry.
    i_type = i_ext.
    if i_ext <> 'pdf'.
    try.
      lo_document->add_attachment(
      EXPORTING
        i_attachment_type = i_type
        i_attachment_subject = attachment_sub
        i_att_content_hex = it_solix ).
           CATCH cx_document_bcs.
    endtry.
    clear wa_solix.
    refresh it_solix.
    else.
    TRY.
      CALL METHOD LO_DOCUMENT->ADD_ATTACHMENT
        EXPORTING
          I_ATTACHMENT_TYPE     = i_type
          I_ATTACHMENT_SUBJECT  = attachment_sub
    *      I_ATTACHMENT_SIZE     =
    *      I_ATTACHMENT_LANGUAGE = SPACE
          I_ATT_CONTENT_TEXT    = it_soli
    *      I_ATT_CONTENT_HEX     =
    *      I_ATTACHMENT_HEADER   =
       CATCH CX_DOCUMENT_BCS .
      ENDTRY.
    ENDIF.
    endloop.
    try.
    lo_send_request->set_document( lo_document ).
    CATCH cx_send_req_bcs.
    endtry.
    wa_selection_range-PARAMETER = 'address'.
    wa_selection_range-field = 'e_mail'.
    wa_selection_range-sign = 'I'.
    wa_selection_range-option = 'EQ'.
    wa_selection_range-low = receiver.
    append wa_selection_range to it_selection_range.
    try.
    CALL FUNCTION 'BAPI_USER_GETLIST'
    * EXPORTING
    *   MAX_ROWS              = 0
    *   WITH_USERNAME         = ' '
    * IMPORTING
    *   ROWS                  =
    TABLES
        SELECTION_RANGE       = it_selection_range
    *   SELECTION_EXP         =
        USERLIST              = it_userlist
    *   RETURN                =
    catch cx_sy_dyn_call_illegal_type.
    endtry.
    read table it_userlist into wa_userlist index 1.
    try.
      lo_sender = cl_cam_address_bcs=>create_internet_address( sender ).
      lo_send_request->set_sender(
         EXPORTING
         i_sender = lo_sender ).
    catch cx_send_req_bcs.
    catch cx_document_bcs.
    catch cx_address_bcs.
      return.
    endtry.
    try.
        lo_recipient = cl_sapuser_bcs=>create( wa_userlist-USERNAME ).
        lo_send_request->add_recipient(
           EXPORTING
             i_recipient = lo_recipient ).
    *         i_express = 'X' ).
      catch cx_send_req_bcs.
      catch cx_document_bcs.
      catch cx_address_bcs.
    endtry.
    try.
    ** Send email
         LO_SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).
         lo_send_request->send( EXPORTING
         i_with_error_screen = ' '
         RECEIVING
         result = result ).
         COMMIT WORK.
    CATCH CX_DOCUMENT_BCS.
    CATCH CX_SEND_REQ_BCS INTO lo_message.
    CATCH CX_ADDRESS_BCS.
    text_val = lo_message->IF_MESSAGE~GET_TEXT( ).
    endtry.
    if result = 'X'.
      message = 'E-Mail sent'.
    else.
      message = 'E-Mail not sent'.
    endif.
    ENDFUNCTION.

Maybe you are looking for

  • Struts : creation of new row problem.

    I have a problem with creation of a new row, using struts. I've created simple struts browse-edit page. From browse page I go to 'edit-new' page. My object have a primary key - ID. I'm initializing it from sequence in create() method after call to su

  • Short dump in trx VL02N and MIGO after upgrade to ECC 6.0

    Hello, We are doing an upgrade from R/3 46C to ECC 6.0 and we face a shortdump in trx MIGO (upon saving the document). DBIF_RSQL_INVALID_REQUEST a BKPF_INSERT in program SAPLF005 The same shortdump happens when doing a Goods Issue on the SD side. Loo

  • Hr abap- macro

    there is a problem in hr abap with the macros like rp-provide from frst and rp-provide from last. is there any solution in the form of sample codes it will be very helpful. the exact problem with the code is that rp-provide from last and frst are pro

  • How To Use Parallels and EVDO Card at Same Time

    For those of you trying to get Windows to access the internet via your EVDO card connected to your MacBook Pro, we have directions posted at: http://www.evdoinfo.com/Tips/PC5220/MacBook_Sharing_EVDO_with_Parallels20061113849/ G5 Dual 2.5 GHZ, MaBook

  • Migration Values on assets as investment measure

    Hi Gurus, I have a problem about AS92 for asset as investment measure. I have created a WBS in PS module with an investment profile and, when a have realised the WBS elements, the system has created assets as investment measure. I tried to migrate va