Send email through SO_NEW_DOCUMENT_ATT_SEND_API1 with PDF attachement of smartforms.

Hi,
I am converting a smartform to PDF and then sending it as an attachment to email using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
But I am getting this error. 'Error calling FM <SBCOMS_SEND_REQUEST_CREATE> in <SO_DOCUMENT_SEND_API1> with SY-SUBRC <1>'
I am passing below entries to packaging list table.
Packing list for Email Text
        ls_packing_list-head_start = 1.
        ls_packing_list-head_num   = 1.
        ls_packing_list-body_start = 1.
        ls_packing_list-doc_type   = 'RAW'.
Packing list for PDF
        ls_packing_list-transf_bin = 'X'
        ls_packing_list-head_start = 1.
        ls_packing_list-head_num   = 1.
        ls_packing_list-body_start = 1.
        ls_packing_list-doc_type   = 'PDF'.
Please let me know if I am missing anything.
Regards,
Nishant

Hi Nishant,
               Please refer my below code last week only i have implemented this logic.
call function 'CONVERT_OTF'
     exporting
       format                = 'PDF'
       max_linewidth         = 132
     importing
       bin_filesize          = w_bin_filesize
     tables
       otf                   = t_otf
       lines                 = t_pdf_tab
     exceptions
       err_max_linewidth     = 1
       err_format            = 2
       err_conv_not_possible = 3
       err_bad_otf           = 4.
pdf_output[] = t_pdf_tab[].
loop at pdf_output.
     translate pdf_output using ' ~'.
     concatenate gd_buffer 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.
   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.
   free t_attachment.
   t_attachment[] = it_attach[].
  clear it_attach[].
  refresh  it_attach[].
  free  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.
   free t_receivers.
   clear : email.
   select single usrid_long into email from pa0105 where pernr = wa_pernr-pernr
     and subty = '0010' and seqnr = ''.
   t_receivers-receiver = email.
   t_receivers-rec_type = 'U'.
   t_receivers-com_type = 'INT'.
   t_receivers-notif_del = 'X'.
   t_receivers-notif_ndel = 'X'.
   append t_receivers.
   ld_sender_address = 'HRD1'.
   ld_sender_address_type = 'B'.
   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.
check it and Revert back .
Regards,
Thangam.P

Similar Messages

  • Is anyone else having a problem sending a mail message with PDF attached?

    Is anyone else having a problem sending a mail message with PDF attached? I receive the following message:
    Sending the message content to the server failed.
    Select a different outgoing mail server from the list below or click Try Later to leave the message in your Outbox until it can be sent.
    Is there a fix for this?

    Anyone?  I was hoping my problem would just 'fix itself'...  but I still have some clients telling me they're not receiving any email from me.  I've since deleted that account on my computers and re-added it.  But still having the same issue. 

  • Sending an e-mail with pdf attachment and logo as a signature

    Hi,
    My task is to send an email with pdf attachement. And an image file need to be added as a signature. Is it possible, if so, can anyone please guide me?
    Thanking you.
    Kumar.

    Hi
    I'm having the same issue, except my application actually sends the email but the attachment is 0 octet and it doesn't even give me an error... Any chance you found a solution for this and could share it ?
    Thanks

  • TS3276 When I try sending emails through Mail with my iCloud account, it says "Unable to Sign Message"

    I cannot send messgaes through Mail with my iCloud account. Whenever I try sending them, it tells me "Unable to sign message".
    Does anybody know how to fix it?

    Check if you have set the correct language and country in your Apple TV. Maybe you are trying to connect to the wrong iTunes store.

  • Sending email to IPad with PDF file attachement

    I am helping a friend set up his Ipad and when we send a PDF document by email to the Ipad the attachment is in the format of winmail.dat not pdf and so we cannot open it on the IPad. What am I not doing correctly?

    What email program is being used to send the email? What option is set for attachments in that program?

  • When sending email PO in a PDF attachment, the attachment can not be openen

    Hi all,
    We are trying to send an email with the PO in PDF format.  We got the email but the attachment can not be opened. 
    Error reads: Adobe could not open test.pdf because  it is either  not a supported file type  or because  the file has been damaged (for example , it was send as a email attachemnet and was not  correctly decoded).
    Could any body bring some light?   We know that everything in SCOT is fine because we can email the PO through configuration to the vendor without problem. It is just these extra copies that do not work.
    a) We are modifying our custom Print program to add the code below after closing the form.
    in few words:
    a) We are getting the OTF from closing the form.
    b) Converting the OTF to PDF
    c) Sending the PDF as attachment.
    data: lt_docs      TYPE TABLE OF docs.
    data: pdf_bytecount TYPE i.
    data: begin of pdfout occurs 0,
       tline type tline,
    end of pdfout.
    Ende Formulardruck --------------------------------------------------*
      CALL FUNCTION 'CLOSE_FORM'
           IMPORTING
                result = result
           tables
                otfdata = otf.
      IF RESULT-TDSPOOLID NE SPACE.
        SPOOLID = RESULT-TDSPOOLID.
        PERFORM PROTOCOL_UPDATE USING '320' SPOOLID SPACE SPACE SPACE.
      ENDIF.
      if result-userexit eq 'C' or
          result-userexit eq 'E'.
        retco = '9'.
      endif.
      CALL FUNCTION 'CONVERT_OTF_2_PDF'
        IMPORTING
          bin_filesize           = pdf_bytecount
        TABLES
          otf                    = otf
          doctab_archive         = lt_docs
          lines                  = pdfout
        EXCEPTIONS
          err_conv_not_possible  = 1
          err_otf_mc_noendmarker = 2
          OTHERS                 = 3.
    Creation of the document to be sent File Name
       maildata-obj_name = 'TEST'.
    Mail Subject
       maildata-obj_descr = 'Subject'.
    Mail Contents
       append mailtxt.
      describe table mailtxt lines tab_lines.
      read table mailtxt index tab_lines.
      maildata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( mailtxt ).
    Creation of the entry for the compressed document
      clear mailpack-transf_bin.
      mailpack-head_start = 1.
      mailpack-head_num = 0.
      mailpack-body_start = 1.
      mailpack-body_num = tab_lines.
      mailpack-doc_type = 'RAW'.
      append mailpack.
    Move OTF code to structure SOLI form email
    CLEAR solisti1. REFRESH solisti1.
    LOOP AT otf.
      solisti1-line = otf.
      APPEND solisti1.
    ENDLOOP.
    Move pdf code to structure soli form email
      clear solisti1. refresh solisti1.
      loop at pdfout.
        solisti1-line = pdfout.
        append solisti1.
      endloop.
      loop at solisti1.
         move-corresponding solisti1 to mailbin.
         append mailbin.
      endloop.
      describe table mailbin lines tab_lines.
    mailhead = 'TEST.OTF'.
      mailhead = 'TEST.PDF'.
      append mailhead.
    Creation of the entry for the compressed attachment
      mailpack-transf_bin = 'X'.
      mailpack-head_start = 1.
      mailpack-head_num = 1.
      mailpack-body_start = 1.
      mailpack-body_num = tab_lines.
    mailpack-doc_type = 'OTF'.
      mailpack-doc_type = 'PDF'.
      mailpack-obj_name = 'TEST'.
      mailpack-obj_descr = 'Subject'.
      mailpack-doc_size = tab_lines * 255.
      append mailpack.
      mailrec-receiver = '[email protected]'.
      mailrec-rec_type = 'U'.
      append mailrec.
      mailrec-receiver = '[email protected]'.
      mailrec-rec_type = 'U'.
      append mailrec.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
              EXPORTING
                   DOCUMENT_DATA              = maildata
              TABLES
                   PACKING_LIST               = mailpack
                   OBJECT_HEADER              = mailhead
                   CONTENTS_TXT               = mailtxt
                   RECEIVERS                  = mailrec
              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.

    Dear Monica,
      You need to configure the system with respect to functional point of view and need to write the following code in print program. i have done this and solution is as follows.
    <b>  Reward me for this solution.</b>
    Process 11 (MM)     Sending RFQs and POs to vendors directly from the system instead of sending thru Courier or Fax     
    Existing Process (AS-IS)     Presently system is not supporting this requirement
    Business Requirements     RFQ’s to be linked with vendor master with e-mail to send enquiries directly through system instead of courier/fax. Vice versa P.O’s.  Specifications, drawings should also go to vendor along with mail.
    To-Be     
    Configuration Settings:                  
    1) Spro – Materials management – Purchasing – Messages – Output control – Message types – Define message types for RFQ/ PO
    •     Created ZEK1,ZMI and ZEK2 for RFQs
    •     Created ZIK,ZOC,ZOK,ZOM,ZSI, ZSK2 and ZSM for Pos
    •     The above New output types Included with existing Print Forms and Programs but modified with External send(5) medium, and added company’s letter head thru ABAP developments (details provided below)
    •     The above new output types also maintained for Fine- tuned control (thru same navigation) for New(1) and Change(2) operations
          2) Spro – Materials management – Purchasing – Messages – Output control – Message   determination schemas – Define message schema for RFQ/ PO
    •     Maintained the new output types in the control data
    3)     Maintain Condition records for the New out put types (copied same document types from the existing old output types)
    Easy access – Logistics – Materials management – Purchasing – Master data – Messages – MN01 (for RFQs)/ MN04 (for Pos)
    4)     Maintain Email id of Vendor in Vendor master.
    Developments (ABAP):
    1)  Copied the existing print programs and forms of the corresponding out types.
    2) Addition of header window in each corresponding form (HEADER window). Uploaded the HEADER3 graphics in the header window.
    INCLUDE HEADER3 OBJECT GRAPHICS ID BCOL LANGUAGE EN
    3) Added the the following code in TOP includes
                       TYPE-POOLs szadr.
               INCLUDE:  LMEDRUCKF09.
    data: intnast         LIKE snast,
          lvs_recipient   LIKE swotobjid,       "Internet
          lvs_sender      LIKE swotobjid,       "Internet
          lvs_comm_type   TYPE ad_comm,
          lvs_comm_values TYPE szadr_comm_values,
          p_retco         TYPE i.
    5)     Addition of the perform to SOS include for header window display
           PERFORM WRITE_FORM_HEADER.
    *&      Form  WRITE_FORM_HEADER
          text
    -->  p1        text
    <--  p2        text
    FORM WRITE_FORM_HEADER.
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
       ELEMENT                        = 'HE1'
       FUNCTION                       = 'SET'
       TYPE                           = 'BODY'
       WINDOW                         = 'HEADER'
    IMPORTING
       PENDING_LINES                  =
    EXCEPTIONS
       ELEMENT                        = 1
       FUNCTION                       = 2
       TYPE                           = 3
       UNOPENED                       = 4
       UNSTARTED                      = 5
       WINDOW                         = 6
       BAD_PAGEFORMAT_FOR_PRINT       = 7
       SPOOL_ERROR                    = 8
       CODEPAGE                       = 9
       OTHERS                         = 10
    ENDFORM.
    6)     In the corresponding FORM include the following code has been added.
    DATA:  lvs_comm_type     TYPE   ad_comm,
            lvs_comm_values   TYPE   szadr_comm_values,
            xprogramm         type   sy-repid.
      ... use stratagy to get communication type
          CALL FUNCTION 'ADDR_GET_NEXT_COMM_TYPE'
               EXPORTING
                    strategy           = nast-tcode
                    address_number     = lfa1-adrnr
               IMPORTING
                    comm_type          = lvs_comm_type
                    comm_values        = lvs_comm_values
               EXCEPTIONS
                    address_not_exist  = 1
                    person_not_exist   = 2
                    no_comm_type_found = 3
                    internal_error     = 4
                    parameter_error    = 5
                    OTHERS             = 6.
          IF sy-subrc <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    convert communication data
          MOVE-CORRESPONDING nast TO intnast.
          MOVE sy-repid           TO xprogramm.
    7) By using the function module we can get sender and reciepient mail ids to variables lvs_recipient    lvs_sender
          CALL FUNCTION 'CONVERT_COMM_TYPE_DATA'
               EXPORTING
                    pi_comm_type              = lvs_comm_type
                    pi_comm_values            = lvs_comm_values
                    pi_country                = lfa1-land1
                    pi_repid                  = xprogramm
                    pi_snast                  = intnast
               IMPORTING
                    pe_itcpo                  = itcpo
                    pe_device                 = xdevice
                    pe_mail_recipient         = lvs_recipient
                    pe_mail_sender            = lvs_sender
               EXCEPTIONS
                    comm_type_not_supported   = 1
                    recipient_creation_failed = 2
                    sender_creation_failed    = 3
                    OTHERS                    = 4.
          IF sy-subrc <> 0.
          Avoids cancellation with message TD421
            p_retco = '1'.                                           "831984
            PERFORM protocol_update USING '740' space space space space.
          dummy message to make the message appear in the where-used list
            IF 1 = 2.
              MESSAGE S740(me).
            ENDIF.
            EXIT.
          ENDIF.
          IF xdevice = 'MAIL'.                                       "885787
        Check validity of email address to avoid cancellation with TD463
            CALL FUNCTION 'SX_ADDRESS_TO_DEVTYPE'                    "831984
              EXPORTING
                recipient_id            = lvs_recipient
                sender_id               = lvs_sender
              EXCEPTIONS
                err_invalid_route       = 1
                err_system              = 2
                OTHERS                  = 3.
            IF SY-SUBRC <> 0.
              p_retco = '1'.
              PERFORM protocol_update USING '740' space space space space.
           dummy message to make the message appear in the where-used list
              IF 1 = 2.
                MESSAGE S740(me).
              ENDIF.
              EXIT.
            ENDIF.
          ENDIF.
    8)     Attaching the new print program and form in NACE transaction.
    Steps for End user:
    1)     Creating the Purchase Order or RFQ with suitable document type through ME21N or ME41 .
    2)     Executing the transaction ME9F and in selecting the suitable output type.
    3)     Executing the transaction ZSEND_PDOC using INT as input.
    4) With above steps we can able to send purchase order or RFQ to vendor as an attachment through e-mail in PDF format.
    Regards
    Badari

  • Issue to send email (using sp_send_dbmail) with an attachement located in other server within the same network

    I have two servers. One is for databases (DB) with the mail server configured and the other is for SSIS without mail server. Both servers are in the same network. On the SSIS server the SSIS package exports data from the DB server table
    to xls file. The file is saved in SSIS server. When I created a task to send the email (using sp_send_dbmail) to attach that file, I got the error message:
    Error: Executing the query "EXECUTE [msdb].[dbo].[sp_send_dbmail]
     @profile_na..." failed with the following error: "Attachment file H:\test.xls is invalid.".
    Any help will be appreciated. Thanks.
    A Fan of SSIS, SSRS and SSAS

    Where are you running this?
    If its in the other server (DB) you need to use UNC path to the SSIS server folder where file resides
    Also the executing account should have access to the folder as well as the file. So If you're running this from a job make sure you either provider folder and file access to sql agent job service account or create a separate proxy account with the required
    permissions and configure the job to use the account
    see
    http://www.databasejournal.com/features/mssql/article.php/3789881/Proxy-Accounts-in-SQL-Server.htm
    http://www.codeproject.com/Articles/28918/SQL-Server-Agent-Proxy
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Problem sending email through Comcast with Mac Mail

    I have seen this problem discussed here but no solution that I follow. Is there an
    easy fix to this. I am able to receive emails but...
    Here's the error message I get when I try to send from Mail:
    This message could not be delivered and will remain in your Outbox until it can be delivered.
    The sender address [email protected] was rejected by the server.
    I have tried changing the email address and the user name..but without success.
    The "Connection Doctor" in the Windows Menu went through a check and determined that my settings (POP Account and Internet connection status) were correct, as far as incoming and outgoing servers. ("connection to server succeeded") Didn't mention any other problems.
    Any help appreciated, thanks

    I managed to get things working by deleting my mail account then recreating. Although this has been suggested before, I encountered a comcast glitch during the process that may explain some of this misbehavior. Comcast asked us to create new 8 character passwords. However, the incoming mail server still wants you to log in to your old password, while the smtp server wants the new password.
    Although this may be more work than necessary, here is how I got my mail working again.
    Create temporary folder in Filed Mail and move messages in your inbox to the temporary folder.
    Delete your comcast acount.
    Recreate comcast account, using automatic setup.
    enter old password at first prompt.
    enter new password at second prompt when it looks for the correct PW to enable outgoing mail.

  • Send Invoice email with pdf attachement through DI?

    Hi all,
    is it possible to send an Invoice email with pdf attachement through DI as it can be done through UI?
    Best Regards,
    Vangelis

    Hi Vangelis,
    I Don't think that the DI API has that functionality (but I am not sure).
    However with .Net's System.Net.Mail it should be quite easy to build.
    Good luck,
    Johan

  • I work for a retailer who sends out e-receipts as pdf attachements.  When the email arrives on any apple product, i see the email with the paperclip icon showing that there is an attachment but i cannot ever see or find the actual attachment.  Any ideas?

    i work for a retailer who sends out e-receipts as pdf attachements.  When the email arrives on any apple product, i see the email with the paperclip icon showing that there is an attachment but i cannot ever see or find the actual attachment.  Any ideas?

    i have scrolled left, right, up and down on iphone4, iphone5 and ipad and the attachment simply does not exist.  It has to be something with the apple mail client setup because for any mail client, if they go to the webemail thru safari, the attachment is there and it can be viewed without issue.
    I know there are plenty of people out there with this issue with the mail clients set up that you access thru the email icon on the iphone and ipad but i cannot find anyone with a resolution.  I cannot find any settings in the mail client setup that has anything to do with attachments or for what attachments can or cannot be read or seen.
    Hopefully someone out there has figured something out because this is an odd one.

  • Sending an email with pdf attachment in Ecc6

    we were in 4.6 c and recentely upgraded to ECC6. we have a program which we are sending email with pdf attachments. now it is breaking, we are able to display the pdf in the screen, but once it became the attachment , it is not going.
    we are running the program in forground and not reading the spool and sending it. any idea

    http://www.sap-img.com/abap/sending-email-with-attachment.htm
    Sending mail to an external maild with PDF attachment.
    Creating a PDF attachment and send it via Email
    Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface
    How to send a ttachment with email.
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-Sendthespooldatatoanemail+address.
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/convertSpoolrequesttoPDFandsendase-mail
    Friend just have a look in the forum itself, there are many posts for ur query, you definetly get exact solution no need to wait for answers/solutions.
    All the best

  • External Send PO as email with PDF attachment not working

    hi,
    we are using ECC6, and in txn NACT, Processing routine we can use Sapscript External send > SAPFM06P > ENTRY_NEU > MEDRUCK > PDF and in MN04/5 i create Output record, and in SCOT my PO is ready for transmission from either ME21N/2 and ME9F - works well - email sent with pdf PO attached.
    <b>HOWEVER,</b> we have just created a SMARTFORM PO, and with similar settings, i cannot create External send OUTPUT!!! (Output failed in ME9F/ME23N) NACT settings External Send > /SMB40/FM06P > Z_MMPO_A > PDF
    In SCOT > SMTP > Internet X > Sapscript/SmartForm = PDF.
    Does special code need to be entered into Smartform to generate PDF email similar to Sapscript? Any code would be appreciated.
    regards Adam

    Hi,
    You need to build a code to create the Spool OTF output into PDF.
    This can be done in Print program, which converts the spool into PDF & sends a mail with PDF attachment.
    Please refer this sample program:
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    Best regards,
    Prashant

  • Send Mail with PDF Attachment in ABAP

    Hi Experts,
    I have a requirement where I need to convert internal table data into PDF format and send it as an E-Mail with PDF attachment to Outlook mail using ABAP.
    How do I achieve this .
    Can anyone send me example code for doing this.
    Thanks
    Kumar

    hiii
    check following code for PDF attachment and mail
    ** Check for any ATTACHMENTS...
    IF d_desired_type = 'RAW'.           " Set to RAW?
    *    PERFORM convert_to_abaplist.       " YES - convert it
      ENDIF.                               " end...
      IF d_desired_type = 'ALI'.           " Set to ALI?
        PERFORM convert_to_alilist.        " YES - convert it
      ENDIF.                               " end...
    * Check for any ATTACHMENTS...
      IF NOT t_soli[] IS INITIAL.          " attachment?
        h_real_type = d_desired_type.      " ENABLE
        h_transf_type = 'X'.               " Transfer type BINARY...
    *   Write PDF/ALI formatted data to BINARY table...
        t_con_bin[] = t_soli[].
    *   Add Packing List (attachment) for PDF...
        DESCRIBE TABLE t_con_bin LINES h_tab_cntr.
        READ TABLE t_con_bin INDEX h_tab_cntr.
        h_doc_data-doc_size = h_doc_data-doc_size
                            + ( ( h_tab_cntr - 1 )
                            * 255 + STRLEN( t_con_bin ) ).
        h_doc_data-obj_descr  = mail_subject.
        h_body_start = 1.
        h_body_num = h_tab_cntr.
    *   Write RAW data if that's what it is (adds to TEXT)...
        IF h_real_type = 'RAW'.
          DESCRIBE TABLE t_con_text LINES h_body_start.
          h_body_start = h_body_start + 1.
          h_transf_type = space.           " Transfer type TEXT...
          LOOP AT t_con_bin.               " Zip thru TEXT stuff
            t_con_text = t_con_bin.        " set TEXT table header..
            APPEND t_con_text.             " add to what's there!
          ENDLOOP.
          CLEAR: t_con_bin.                " clear BINARY header..
          REFRESH: t_con_bin.              " reset BINARY table...
        ENDIF.
        CLEAR t_pak_list.
        IF h_transf_type = 'X'.            " Binary=PDF/ALI?
          t_pak_list-transf_bin = 'X'.
          t_pak_list-head_start = 1.
          t_pak_list-head_num   = 0.
          t_pak_list-body_start = 1.
          t_pak_list-body_num   = h_tab_cntr.
          t_pak_list-doc_type   = h_real_type.
          t_pak_list-obj_name   = 'ATTACHMENT'.
          t_pak_list-obj_descr  = 'Document'(001).
          t_pak_list-doc_size   = ( h_tab_cntr - 1 )
                                * 255 + STRLEN( t_con_bin ).
        ELSE.
          DESCRIBE TABLE t_con_text LINES h_tab_cntr.
          READ TABLE t_con_text INDEX h_tab_cntr.
          t_pak_list-transf_bin = ' '.     " Binary=RAW
          t_pak_list-head_start = 1.
          t_pak_list-head_num   = 0.
          t_pak_list-body_start = h_body_start.
          t_pak_list-body_num   = h_tab_cntr.
          t_pak_list-doc_type   = h_real_type.
          t_pak_list-obj_name   = 'ATTACHMENT'(002).
          t_pak_list-obj_descr  = 'Report'(003).
          t_pak_list-doc_size   = ( h_body_num - 1 )
                                * 255 + STRLEN( t_con_text ).
        ENDIF.
        APPEND t_pak_list.
      ENDIF.
    * Send the EMAIL out with SAP function...
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = h_doc_data
          put_in_outbox              = 'X'
    *      commit_work                = 'X'
        TABLES
          packing_list               = t_pak_list
          contents_bin               = t_con_bin
          contents_txt               = t_con_text
          receivers                  = t_receivers
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorization = 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
      IF syst-subrc NE 0.
    *    RAISE send_failed.
        CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
          EXPORTING
            msg_arbgb = '00'
            msg_nr    = '001'
            msg_ty    = 'E'
            msg_v1    = 'O/P Could not be issued '(001)
            msg_v2    = ' Due to No Mail ID'(002)
            msg_v3    = syst-msgv3
            msg_v4    = syst-msgv4
          EXCEPTIONS
            OTHERS    = 1.
    * Check General incompletion status of the header
        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'.
        ENDIF.
      ELSE.
    *    commit work.
      ENDIF.
    ENDFORM.                               " SEND_MAIL_FAX
    *&      Form  convert_otf_2_pdf
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM convert_otf_2_pdf .
      DATA: "t_line            LIKE tline OCCURS 0 WITH HEADER LINE,
            t_objcont         LIKE soli  OCCURS 0 WITH HEADER LINE,
            d_doc_size(12)    TYPE c,
            d_fle1(2)         TYPE p,
            d_fle2(2)         TYPE p,
            d_off1            TYPE p,
            d_hltlines        TYPE i,
            d_hfeld(500)      TYPE c,
            w_indx            LIKE sy-tabix.
      CLEAR: t_line, t_objcont, d_off1.
      REFRESH: t_line, t_objcont.
    * Check/set DEFAULT Desired-type attachment...
      IF d_desired_type IS INITIAL.        " Entered Desired type?
        d_desired_type = 'PDF'.            " NO  - default to PDF
      ENDIF.                               "
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = d_desired_type
        IMPORTING
          bin_filesize          = d_doc_size
        TABLES
          otf                   = t_itcoo
          lines                 = t_line
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          OTHERS                = 4.
      IF sy-subrc > 0.
        RAISE otf_convert_failed.
      ENDIF.
    ENDFORM.                               " convert_otf_2_pdf
    *&      Form  convert_otf_2_pdf_sx
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM convert_otf_2_pdf_sx .
      DATA:
        t_otf          LIKE solisti1 OCCURS 0 WITH HEADER LINE,"ENABLE
        t_pdf          LIKE tline    OCCURS 0 WITH HEADER LINE,"ENABLE
        doc_size(12)   TYPE n,
        len_out        TYPE i,
        x_real         LIKE  soodk-objtp,
        x_idx_b        LIKE sy-tabix,
        x_idx_e        LIKE sy-tabix.
      IF d_desired_type = 'PDF'.
        d_desired_type = 'OTF'.
      ENDIF.
      CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
        EXPORTING
          rqident              = d_spool_id
          desired_type         = d_desired_type
        IMPORTING
          real_type            = x_real
        TABLES
          buffer               = t_otf
          buffer_pdf           = t_pdf
        EXCEPTIONS
          no_such_job          = 1
          job_contains_no_data = 2
          selection_empty      = 3
          no_permission        = 4
          can_not_access       = 5
          read_error           = 6
          type_no_match        = 7
          OTHERS               = 8.
      IF sy-subrc <> 0.
        IF sy-subrc = 1.
          RAISE invalid_spool_id.
        ELSE.
          RAISE otf_convert_failed.
        ENDIF.
      ENDIF.
    * Check Desired-Type vs. Real-Type (if any)...
      IF d_desired_type IS INITIAL.
        IF x_real = 'OTF'.
          d_desired_type = 'PDF'.
        ELSE.
          d_desired_type = x_real.
        ENDIF.
      ELSE.
        IF ( d_desired_type = 'PDF' OR
             d_desired_type = 'OTF' ) AND
           ( x_real = 'OTF' OR
             x_real = 'PDF' ).
          d_desired_type = 'PDF'.
        ELSE.
          IF d_desired_type <> x_real.
            RAISE type_no_match.
          ENDIF.
        ENDIF.
        IF ( d_desired_type = 'ALI' OR
             d_desired_type = 'RAW' ) AND
             x_real = 'OTF'.
          RAISE type_no_match.
        ENDIF.
      ENDIF.
    * Check if ABAP-LIST and not SapScript...
      IF d_desired_type = 'ALI' OR
         d_desired_type = 'RAW'.
        t_soli[] = t_otf[].
        EXIT.
      ENDIF.
    * Load OTF data gotten from spool...
      LOOP AT t_otf.
        t_itcoo = t_otf.
        APPEND t_itcoo.
    *   if Vendor P/O (SapScript = Z_MEDRUCK) then
    *      trap INDEX for "Terms & Conditions" on BACK...
        IF t_itcoo-tdprintcom =  'IN' AND
           t_itcoo-tdprintpar =  '01EZ_MEDRUCK       BACK'.
          x_idx_b = sy-tabix.
        ENDIF.
        IF t_itcoo-tdprintcom =  'IN' AND
           t_itcoo-tdprintpar =  '01EZ_MEDRUCK       NEXT'.
          x_idx_e = ( sy-tabix - 1 ).
        ENDIF.
      ENDLOOP.
    * Drop from table if INDEX'S are set (see above)...
      IF ( x_idx_b > 0 AND
         ( x_idx_e > x_idx_b ) ) .
        DELETE t_itcoo FROM x_idx_b
                     TO x_idx_e.
      ENDIF.
      PERFORM convert_otf_2_pdf.
    ENDFORM.                               " convert_otf_2_pdf_sx
    *&      Form  CONVERSION_OF_SIZE                                       *
    * *"Converting the file to get a 255 char single line internal table   *
    * The PDF file that is generated out of the above function module     *
    * cannot be transported as it needs to be of 255 chars. Hence         *
    * converting the file to get a 255 char single line,internal table.   *
    FORM conversion_of_size .
    "Declaring Local Constants............................................
      CONSTANTS:
         cnv_hexconst_zero TYPE x VALUE '00'.
    * Internal table to hold 255 Char's Single Line.                      *
      DATA:
        lv_big_lines(268) TYPE c
                          OCCURS 0 WITH HEADER LINE.
    *"Local Work Variables.................................................
      DATA:
        lfl_flag          TYPE c,
        lv_left_t(268)    TYPE c,
        lv_left_i         TYPE i,
        tv_left_i         TYPE i,
        lv_curr_i         TYPE i.
      FIELD-SYMBOLS: <f>.
    * Get the lines into a table of 268 char as the first step to put it in
    * the pdf file of 255 chars
      CLEAR lfl_flag.
      LOOP AT t_line.
        IF lfl_flag EQ ' '.
          CLEAR lv_big_lines.
          ASSIGN lv_big_lines(134) TO <f>.
          <f> = t_line.
          lfl_flag = 'X'.
        ELSE.
          lv_big_lines+134 = t_line.
          APPEND lv_big_lines.
          CLEAR: lfl_flag.
        ENDIF.                             " If lfl_flag = ''..
      ENDLOOP.                             " Loop at t_pdf
      IF lfl_flag EQ 'X'.
        APPEND lv_big_lines.
      ENDIF.                               " If lflf_flag eq 'X'..
    * Next fill it into a 255 char table
      CLEAR: lv_left_t, lv_left_i, tv_left_i.
      lv_curr_i = 255.
      LOOP AT lv_big_lines.
        IF lv_left_i NE 0.
          IF lv_curr_i NE 0.
            wa_objcont(lv_left_i)           = lv_left_t(lv_left_i).
            wa_objcont+lv_left_i(lv_curr_i) = lv_big_lines(lv_curr_i).
          ELSE.
            wa_objcont = lv_left_t(lv_left_i).
          ENDIF.                           " IF lv_curr_i NE 0
        ELSE.
          wa_objcont = lv_big_lines(lv_curr_i).
        ENDIF.                             " IF lv_left_i NE 0
        APPEND wa_objcont TO t_objcont.
        tv_left_i = 268 - lv_curr_i.
        IF tv_left_i > 255.
          wa_objcont = lv_big_lines+lv_curr_i(255).
          APPEND wa_objcont TO t_objcont.
          lv_left_i = tv_left_i - 255.
          tv_left_i = 255 + lv_curr_i.
          lv_curr_i = 255 - lv_left_i.
          lv_left_t = lv_big_lines+tv_left_i.
        ELSE.
          lv_left_t = lv_big_lines+lv_curr_i.
          lv_left_i = 268 - lv_curr_i.
          lv_curr_i = 255 - lv_left_i.
        ENDIF.                             " IF tv_left_i > 255
      ENDLOOP.                             " LOOP AT lv_big_lines.
      CLEAR wa_objcont .
      ASSIGN wa_objcont(lv_left_i) TO <f>.
      <f> = lv_left_t(lv_left_i).
      APPEND wa_objcont TO t_objcont.
        h_transf_type = 'X'.                 " Transfer type BINARY...
      IF NOT t_objcont[] IS INITIAL.
        t_soli[]     = t_objcont[].        " SapScript doc to Objects...
      ENDIF.
    regards
    twinkal

  • Custome FM to create Email with PDF attachment

    Hi Experts,
    I am working in Smart form.  my requriment is to create a Custom Function module , for sending  email  with PDF attachment  to the customer. PDF is nothing but which ever I create smart form.
    How can I approach , please give me a suggestion or send me a sample code, if any one create.
    1. This FM should work like : convert form to PDF and send Email to particular customer.

    Hi,
    Steps to convert Smartform to PDF,
    1 Call smartform through FM SSF_FUNCTION_MODULE_NAME.
       CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    2  Converting Smartform to OTF and in turn to PDF
       Set Following parameter in order to convert Smartform into OTF.
      gs_cparam-no_dialog = 'X'.   " Suppressing the dialog box
      gs_cparam-preview = 'X'.     " for print preview
      gs_cparam-getotf = 'X'.     " To get Output in OTF
        CALL FUNCTION g_fmodule
          EXPORTING
            control_parameters = gs_cparam
            output_options     = gs_outoptions
          IMPORTING
            job_output_info    = gt_otf_from_fm
          TABLES
            gt_final           = gt_final
         gt_otf[] = gt_otf_from_fm-otfdata [].
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format                = 'PDF'
            max_linewidth         = 132
          IMPORTING
            bin_filesize          = g_bin_filesize
          TABLES
            otf                   = gt_otf
            lines                 = gt_pdf_tab
        CHECK sy-subrc = 0.
        g_bin_filesize = g_bin_filesize + 1.
    Transfer the 132-long strings to 255-long strings
        LOOP AT gt_pdf_tab into gs_pdf_tab.
          TRANSLATE gs_pdf_tab USING ' ~'.
          CONCATENATE g_buffer gs_pdf_tab INTO g_buffer.
        ENDLOOP.
        TRANSLATE g_buffer USING '~ '.
        DO.
          gs_mess_att = g_buffer.
          APPEND gs_mess_att to gt_mess_att.
          SHIFT g_buffer LEFT BY 255 PLACES.
          IF g_buffer IS INITIAL.
            EXIT.
          ENDIF.
        ENDDO.
    3 For Sending Mail use following mail,
    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = ls_doc_data
          put_in_outbox              = 'X'
          sender_address             = l_sender_address
          sender_address_type        = l_sender_address_type
          commit_work                = 'X'
        TABLES
          packing_list               = lt_packing_list
          contents_bin               = lt_attachment
          contents_txt               = lt_message
          receivers                  = lt_receivers
    I hope this could help you,
    Please let me know if any issue.
    Thanks & regards,
    ShreeMohan
    Edited by: ShreeMohan Pugalia on Jul 18, 2009 8:02 AM
    Edited by: ShreeMohan Pugalia on Jul 18, 2009 8:03 AM
    Edited by: ShreeMohan Pugalia on Jul 18, 2009 8:05 AM

  • Error occured when sending mail with PDF attachment

    Dear Experts
    When i trigger email through SMTP server with PDF attachment using application server 10g , i got following error :
    REP-50159: Executed successfully but there were some errors when distribute the output
    i am using web.show_document utility
    str1:='http://erp.ruchi.com:7777/reports/rwservlet?destype=mail'||'&desname='||c1rec.hist_email||'&from=[email protected]'||'&subject=Your Payslip for Month '||to_char(c1rec.tran_month,'Mon-YYYY')||'&desformat=PDF&server=rep_erp_bi&report=/asdeploy/webutil/pay/reports/payslip.rdf&userid=qwqwqw/aasasas@DIAMOND'||'&COMPANY='||:parameter.para_comp_code||'&LOCATION='||:parameter.para_loc_code||'&MONTH='||to_char(:sdate,'MM/YYYY')||'&ECODE='||c1rec.tran_ecode;
    WEB.SHOW_DOCUMENT(str1,'_SELF');
    previously i had successfully using this utility but now i am facing above error
    Pl suggest
    regards
    shailesh

    Dear Experts
    I already configured application server configuration file with specifying SMTP mail server IP in pluginParam parameter
    <pluginParam name="mailServer">202.157.161.76</pluginParam>
    <property name="enableSSL" value="no"/>
    <property name="mailUserName" value="%[email protected]%"/>
    <property name="mailPassword" value="%soyacl#123%"/>
    what is the issue
    Pl clarify
    Please reply it's urgent

Maybe you are looking for