BPEL process to create a PDF and send it as attachment in SOAP response

We have a requirement to have a webservice created using BPEL, which can receive input from a client and create a PDF using the input and send the PDF as attachment in the SOAP response.
We have found the below link in Oracle docs and our basic understanding on the functionality given is that the MIMEService is being used to read a SOAP attachment from some other service and send it as an attachment in the SOAP response to the requester. As explained above, this doesn't completely satisfy our requirement.
http://docs.oracle.com/cd/E11036_01/integrate.1013/b28981/manipdoc.htm#BABCJIAH
Please suggest if there is any other approach that suites our requirement.
Thanks.

Hi,
I have a Weblogic webservice which returns me a PDF attachment as resposne ( here I have MIME related stuff).I need to get attachment as bpel response.
I have created a BPEL process to invoke the weblogic webservice. I have explictly added the MIME part in bpel.wsdl same as weblogic webservice wsdl.
I tried to assign the response variable( of type base64binary) of bpel.wsdl and my webservice .wsdl . I am getting some error with no attachment.
Below is my xsd used in BPEL.wsdl*
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified"
     elementFormDefault="qualified"
     targetNamespace="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1"
     xmlns="http://www.w3.org/2001/XMLSchema">
     <complexType name="process">
               <sequence>
                    <element name="input" type="string"/>
               </sequence>
     </complexType>
     <complexType name="processResponse">
               <sequence>
                    <element name="result" type="string"/>
               </sequence>
     </complexType>
<complexType name="GetAttachmentPDF">
<sequence>
<element minOccurs="0" name="Pdf" nillable="false" type="base64Binary"/>
</sequence>
</complexType>
</schema>
Below is my BPEL.wsdl*
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="BPELProcess1"
targetNamespace="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:client="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1"
xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/">
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     TYPE DEFINITION - List of services participating in this BPEL process
     The default output of the BPEL designer uses strings as input and
     output to the BPEL Process. But you can define or import any XML
     Schema type and use them as part of the message types.
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1"
schemaLocation="xsd/BPELProcess1.xsd"/>
</schema>
</wsdl:types>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     MESSAGE TYPE DEFINITION - Definition of the message types used as
     part of the port type defintions
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<wsdl:message name="BPELProcess1RequestMessage">
<wsdl:part name="payload" type="client:process"/>
</wsdl:message>
<wsdl:message name="BPELProcess1ResponseMessage">
<wsdl:part name="payload" type="client:processResponse"/>
<wsdl:part name="attachment" type="client:GetAttachmentPDF"/>
</wsdl:message>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     PORT TYPE DEFINITION - A port type groups a set of operations into
     a logical service unit.
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- portType implemented by the BPELProcess1 BPEL process -->
<wsdl:portType name="BPELProcess1">
<wsdl:operation name="process">
<wsdl:input message="client:BPELProcess1RequestMessage"/>
<wsdl:output message="client:BPELProcess1ResponseMessage"/>
</wsdl:operation>
</wsdl:portType>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     PARTNER LINK TYPE DEFINITION
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<plnk:partnerLinkType name="BPELProcess1">
<plnk:role name="BPELProcess1Provider">
<plnk:portType name="client:BPELProcess1"/>
</plnk:role>
</plnk:partnerLinkType>
<wsdl:binding name="BPELProcess1SOAP11Binding" type="client:BPELProcess1">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="process">
<soap:operation style="rpc"
soapAction="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1/process"/>
<wsdl:input>
<soap:body use="literal"
namespace="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1"/>
</wsdl:input>
<wsdl:output>
<mime:multipartRelated>
<mime:part>
<soap:body use="literal"
namespace="http://xmlns.oracle.com/MIMEApp/test/BPELProcess1"/>
</mime:part>
<mime:part>
<mime:content part="attachment" type="application/pdf"/>
</mime:part>
</mime:multipartRelated>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
Below is my WL WS WSDL*
<?xml version="1.0" encoding="UTF-8"?>
<WL5G3N0:definitions
name="NewWSDLFile"
targetNamespace="http://www.example.org/NewWSDLFile/"
xmlns:WL5G3N5="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:WL5G3N4="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:WL5G3N3="http://www.example.org/NewWSDLFile/"
xmlns:WL5G3N2="java:com.rogers.service"
xmlns:WL5G3N0="http://schemas.xmlsoap.org/wsdl/"
xmlns:WL5G3N1="http://www.w3.org/2001/XMLSchema"
>
<WL5G3N0:types>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="java:com.rogers.service"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="java:com.rogers.service"
xmlns:s0="http://schemas.xmlsoap.org/wsdl/" xmlns:s1="http://www.w3.org/2001/XMLSchema"
xmlns:s2="java:com.rogers.service" xmlns:s3="http://www.example.org/NewWSDLFile/"
xmlns:s4="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s5="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/NewWSDLFile/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="GetAttachmentPDF">
<xsd:sequence>
<xsd:element minOccurs="0" name="Pdf" nillable="false" type="xs:base64Binary"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="GetAttachmentResult">
<xsd:sequence>
<xsd:element minOccurs="1" name="Message" nillable="true" type="xs:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</WL5G3N0:types>
<WL5G3N0:message name="NewOperationRequest">
<WL5G3N0:part name="GetAttachment" type="WL5G3N1:string"/>
</WL5G3N0:message>
<WL5G3N0:message name="NewOperationResponse">
<WL5G3N0:part name="NewOperationResponse" type="WL5G3N2:GetAttachmentResult"/>
<WL5G3N0:part name="attachment" type="WL5G3N2:GetAttachmentPDF"/>
</WL5G3N0:message>
<WL5G3N0:portType name="NewWSDLFile">
<WL5G3N0:operation name="NewOperation">
<WL5G3N0:input message="WL5G3N3:NewOperationRequest"/>
<WL5G3N0:output message="WL5G3N3:NewOperationResponse"/>
</WL5G3N0:operation>
</WL5G3N0:portType>
<WL5G3N0:binding name="NewWSDLFileSOAP" type="WL5G3N3:NewWSDLFile">
<WL5G3N4:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<WL5G3N0:operation name="NewOperation">
<WL5G3N4:operation soapAction="http://www.example.org/NewWSDLFile/NewOperation"/>
<WL5G3N0:input>
<WL5G3N4:body use="literal" namespace="http://www.example.org/NewWSDLFile/"/>
</WL5G3N0:input>
<WL5G3N0:output>
<WL5G3N5:multipartRelated>
<WL5G3N5:part>
<WL5G3N4:body use="literal" namespace="http://www.example.org/NewWSDLFile/"/>
</WL5G3N5:part>
<WL5G3N5:part>
<WL5G3N5:content part="attachment" type="application/pdf"/>
</WL5G3N5:part>
</WL5G3N5:multipartRelated>
</WL5G3N0:output>
</WL5G3N0:operation>
</WL5G3N0:binding>
<WL5G3N0:service name="NewWSDLFile">
<WL5G3N0:port name="NewWSDLFileSOAP" binding="WL5G3N3:NewWSDLFileSOAP">
<WL5G3N4:address location="http://localhost:7001/something/NewWSDLFileImpl"/>
</WL5G3N0:port>
</WL5G3N0:service>
</WL5G3N0:definitions>
I refered the below link:
http://docs.oracle.com/cd/B14099_19/integrate.1012/b14448/manipdoc.htm.
4.16.1.1 WSDL File Contents
They are using ra:writeBinaryToFile() and ora:ReadBinaryFromFile(). I couldnt get a proper sample to understand the use of these functions.
Please advise.
Regards
Ipsita

Similar Messages

  • Smartform (otf) as pdf and sending as email-attachment

    Hello everybody,
    when trying to convert a smartform to pdf and sending it with the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' i get an error when opening the pdf-file. It says ' a non identified Token w62.10 was found' and the pdf is all empty.
    The problem seems to be somewhere between getting the pdf output data from the FM 'convert_otf' and trying to create a bin-object for the attachment.
    Here is the code:
      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.
    *   Fehlerhandling
      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
      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
      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-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.
      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.
    * Länge des Attachment ermitteln
      describe table i_objbin lines v_lines_bin.
      read table i_objbin index v_lines_bin.
      i_objpack-doc_size = ( v_lines_bin - 1 ) * 255 + strlen( i_objbin ).
      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 = receiver.
      i_reclist-rec_type = RECEIVER_TYPE.
      append i_reclist.
      if not receiver is initial.
        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.

    Hi,
    I just observed the following.
    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.
    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.
      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.
    Länge des Attachment ermitteln
      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 just tried with your coding and then changed to the below coding.Now I am able to open the PDF in 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           = 'ZZZ_TEST1'
         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.
    *   Fehlerhandling
      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
    *  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.
      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.
    * Länge des Attachment ermitteln
      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'
             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 your problem is solved,kindly close the thread and reward points.If you need clarifications,get back.

  • Convert spool to PDF and send as email attachment

    When i try to convert SAP spool to PDF and send it as email attachment,  size of PDF document becomes large as compared to size of the PDF cocument i download using the same spool.
    I am using following FMs.
    CONVERT_ABAPSPOOLJOB_2_PDF to convert spool to PDF
    and
    SO_NEW_DOCUMENT_ATT_SEND_API1 to send email with attchment.
    some times size of attchment exceeds 2MB and email results in error in SAP connect (SOST).
    Any idea on how to compress the PDF attchment??
    Thanks

    Hi Venkat,
    Can you plesae assist me.
    I have a requirement to convert spool to pdf
    send an email to users
    issue is that attachement is big cant go through
    I have used compress, but when I open the pdf file error that file was not correclty decoded
    please assist, anyone

  • Converting Smartform to PDF and send as email attachment

    Hi
    I want to send the Smartform to mail as PDF attachment.
    I found the program in code gallery., it name was 'ZTEST_NREDDY_PDF_MAIL' .
    I used this program and it send the Smartform to mail as PDF attachment but when open the pdf file it gave me error.
    error : 'An unrecognized token Qq was found'.
    Please help me out.
    Thanks
    Anina

    Hi,
    Following is the code logic:
        Tables for OTF to PDF Conversion
    DATA: g_t_docs      TYPE STANDARD TABLE OF docs,                      " Table for Stored Document
          g_t_lines     TYPE STANDARD TABLE OF tline.                     " Table for Text lines
        Objects to send mail.
    DATA: g_t_objpack   LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,        " SAPoffice: Description of Imported Object Components
          g_t_objtxt    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          g_t_objbin    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          g_t_contout   LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          g_t_reclist   LIKE somlreci1  OCCURS 0 WITH HEADER LINE.        " SAPoffice: Structure of the API Recipient List
        Addresses (Business Address Services)
    DATA: g_t_adrc      LIKE adrc  OCCURS 0,
          g_t_adrc2     LIKE adrc  OCCURS 0,
          g_t_adrc3     LIKE adrc  OCCURS 0,
          g_t_adrc_wa   TYPE adrc,
          g_t_adrc2_wa  TYPE adrc,
          g_t_adrc3_wa  TYPE adrc.
        Sales Document: Partner
    DATA: g_t_vbpa_wa   TYPE vbpa.
        E-Mail Addresses (Business Address Services)
    DATA: g_t_adr6      LIKE adr6  OCCURS 0,
          g_t_adr6_2    LIKE adr6  OCCURS 0,
          g_t_adr6_wa   TYPE adr6,
          g_t_adr6_2_wa TYPE adr6.
    DATA:
        Work Area declarations
          g_wa_objhead   TYPE soli_tab,                                    " Work Area for Objcont and Objhead as Table Type
          g_wa_doc_chng  TYPE sodocchgi1,                                  " Work Area - Data of an object which can be changed
        Variables declarations
          g_lines_txt    TYPE i,
          g_lines_bin    TYPE i,
          g_email_id(40) VALUE '',                         " E-mail Address
        PDF related data declarations
          g_wa_job_output_info      TYPE   ssfcrescl,                      " Smart Forms: Return value at end of form printing
          g_wa_control_parameters   TYPE   ssfctrlop,"#EC NEEDED           " Smart Forms: Control structure
          g_name                    TYPE   string,
          g_path                    TYPE   string,
          g_fullpath                TYPE   string,
          g_filename                TYPE   string,
          g_filter                  TYPE   string,
          g_bin_filesize            TYPE   i,
          g_uact                    TYPE   i,
          g_guiobj                  TYPE   REF TO cl_gui_frontend_services.
      PERFORM f0100_download_pdf.    
      PERFORM f200_convert_to_pdf.
      PERFORM f300_attach_and_mail_pdf.   
    *&      Form  f0100_download_pdf
          To Download the PDF Format of SmartForm on
          Presentation Server
    FORM f0100_download_pdf.                                    "#EC CALLED
    Downloading PDF File
      CREATE OBJECT g_guiobj.
      CALL METHOD g_guiobj->file_save_dialog
        EXPORTING
          default_extension = 'pdf'
          default_file_name = g_name
          file_filter       = g_filter
        CHANGING
          filename          = g_name
          path              = g_path
          fullpath          = g_fullpath
          user_action       = g_uact.
      IF g_uact = g_guiobj->action_cancel.
        EXIT.
      ENDIF.
      MOVE g_fullpath TO g_filename.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          bin_filesize = g_bin_filesize
          filename     = g_filename
          filetype     = 'BIN'
        TABLES
          data_tab     = g_t_lines.
    ENDFORM.                    "f0100_download_pdf
    *&      Form  f0200_convert_to_pdf
          To convert the SmartForm to PDF format
    FORM f0200_convert_to_pdf .                                 "#EC CALLED
      CALL FUNCTION 'CONVERT_OTF_2_PDF'
        IMPORTING
          bin_filesize   = g_bin_filesize
        TABLES
          otf            = g_wa_job_output_info-otfdata
          doctab_archive = g_t_docs
          lines          = g_t_lines.
      CONCATENATE text-001 g_sales_order_no '.pdf' INTO g_name.
    ENDFORM.                    " f0200_convert_to_pdf
    *&      Form  f0300_attach_and_mail_pdf
          To E-Mail the PDF form as an Attachment
    FORM f0300_attach_and_mail_pdf .                            "#EC CALLED
    Attachment
      REFRESH: g_t_reclist,
               g_t_objtxt,
               g_t_objbin,
               g_t_objpack.
      CLEAR g_wa_objhead.
    Create Message Body Title and Description
      g_t_objtxt = g_name.
      APPEND g_t_objtxt.
      DESCRIBE TABLE g_t_objtxt LINES g_lines_txt.
      READ TABLE g_t_objtxt INDEX g_lines_txt.
      g_wa_doc_chng-obj_name = g_name.
      g_wa_doc_chng-expiry_dat = sy-datum + 10.
      g_wa_doc_chng-obj_descr = g_name.
      g_wa_doc_chng-sensitivty = 'F'.
      g_wa_doc_chng-doc_size = g_lines_txt * 255.
    Main Text
      CLEAR g_t_objpack-transf_bin.
      g_t_objpack-head_start = 1.
      g_t_objpack-head_num = 0.
      g_t_objpack-body_start = 1.
      g_t_objpack-body_num = g_lines_txt.
      g_t_objpack-doc_type = 'RAW'.
      APPEND g_t_objpack.
    Attachment (PDF-Attachment)
      g_t_objpack-transf_bin = 'X'.
      g_t_objpack-head_start = 1.
      g_t_objpack-head_num = 0.
      g_t_objpack-body_start = 1.
    Convert TLINE to SOLISTI1
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
        EXPORTING
          line_width_src              = 134
          line_width_dst              = 255
        TABLES
          content_in                  = g_t_lines
          content_out                 = g_t_contout
        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 s000(0k) WITH text-002.
        EXIT.
      ENDIF.
    Create Message Attachment
      APPEND LINES OF g_t_contout[] TO g_t_objbin[].
      DESCRIBE TABLE g_t_objbin LINES g_lines_bin.
      READ TABLE g_t_objbin INDEX g_lines_bin.
      g_t_objpack-doc_size = g_lines_bin * 255 .
      g_t_objpack-body_num = g_lines_bin.
      g_t_objpack-doc_type = 'PDF'.
      g_t_objpack-obj_name = text-003.
      g_t_objpack-obj_descr = text-004.
      APPEND g_t_objpack.
      CLEAR g_t_reclist.
      g_t_reclist-receiver = g_email_id.
      g_t_reclist-rec_type = 'U'.
      APPEND g_t_reclist.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data = g_wa_doc_chng
          put_in_outbox = 'X'
          commit_work   = 'X'
        TABLES
          packing_list  = g_t_objpack
          object_header = g_wa_objhead
          contents_bin  = g_t_objbin
          contents_txt  = g_t_objtxt
          receivers     = g_t_reclist.
    ENDFORM.                    " f0300_attach_and_mail_pdf

  • Conver SAPscript data to PFD and send mail as attachement

    Hi all,
    I have reqirement as conver SAP script data to PDF and send id as attachemetn to respective email ids.
    I have data in t_tdline internal table after CLOSE_FORM. Now I'm able to convert to PDF and sending a mail (checking in SOST). But not able to send as an attachement.
    Can anybody suggest the steps with respective function modules to convert to pdf and send as an attachement.
    Thanks in advance.

    So once you have the data in TDLINE, you have to convert it to PDF attachment using below code
    DATA : l_o_send_request TYPE REF TO cl_bcs,
      l_o_document TYPE REF TO cl_document_bcs,
      l_o_sender TYPE REF TO cl_sapuser_bcs,
    *  l_o_recipient TYPE REF TO cl_cam_address_bcs,
      l_o_recipient TYPE REF TO cl_sapuser_bcs,
      bcs_exception TYPE REF TO cx_bcs,
      l_v_ret TYPE os_boolean,
      l_it_contents TYPE bcsy_text,
      l_wa_contents TYPE LINE OF bcsy_text,
      l_it_attachment TYPE solix_tab,
      l_s_attachment  TYPE solix.
    CALL METHOD cl_document_bcs=>xstring_to_solix
      EXPORTING
        ip_xstring = pdfobject-pdf
      receiving
        rt_solix   = l_it_attachment
      TRY.
          l_o_send_request = cl_bcs=>create_persistent( ).
          l_o_sender = cl_sapuser_bcs=>create( sy-uname ).
    *      l_o_sender = cl_cam_address_bcs=>create_internet_address( '<SY-UNAME>' ).
          l_o_send_request->set_sender( i_sender = l_o_sender ).
          " recipient TO
    *      l_o_recipient = cl_cam_address_bcs=>create_internet_address( 'abcd<at>email' ).
          l_o_recipient = cl_sapuser_bcs=>create( '<SY-UNAME>' ).
          l_o_send_request->add_recipient(
          i_recipient = l_o_recipient
          i_copy = '' " CC indicator
          " email contents
          CLEAR l_wa_contents.
          l_wa_contents-line = 'Find attached the output of the Adobe Forms'.
          APPEND l_wa_contents TO l_it_contents.
          " create documents
          l_o_document = cl_document_bcs=>create_document(
          i_type = 'RAW' " RAW document format
          i_text = l_it_contents
          i_subject = 'This Is The Subject for Email With Attachment'
          l_o_document->add_attachment(
          i_attachment_type = 'PDF' " add PDF attachment
          i_attachment_subject = 'PDF attachment'
          i_att_content_hex = l_it_attachment
          l_o_send_request->set_document( l_o_document ).
          " send email
          l_o_send_request->set_send_immediately( 'X' ).
          l_v_ret = l_o_send_request->send( ).
        CATCH cx_bcs INTO bcs_exception.
      ENDTRY.
      COMMIT WORK.

  • I have created a pdf and then want to send it to my boss.  When he recieves it it is saved in the 14 X 8.5 inches version.  How can I saved it on my end as a 11 x 8.5 inch so he doesn't have to uncheck "Choose paper source by PDF page size"?

    I have created a pdf and then want to send it to my boss.  When he recieves it it is saved in the 14 X 8.5 inches version.  How can I saved it on my end as a 11 x 8.5 inch so he doesn't have to uncheck "Choose paper source by PDF page size"?

    Hi heathers,
    You would need to print the file to a new PDF with the appropriate page size.
    Best,
    Sara

  • Can I hide the Adobe Reader panel with "Export, Create and Edit PDF and Send and Store Files"? I don't use it and it takes up space

    Can I hide the Adobe Reader panel with "Export, Create and Edit PDF and Send and Store Files"? I don't use it and it takes up space

    If you just mean, can I close it, sure. In Reader XI click the Tools button to close or reopen it.

  • Creating a PDF and e-mailing it using CF

    I used a tutorial online to create a PDF with data from a
    form. The problem that I am having is I don't know how to take that
    PDF and send it through an e-mail to a recipient. Either the file
    processes and displays a PDF and sends me the e-mail of the form
    data (which it was set to do before) or one of the other ways I
    tried it, it sent me a link that I used (in the code below) to the
    blank PDF form.
    1) How do I e-mail the filled form to a recipient without
    them seeing the completed form. I want it to go to a confirmation
    page afterwards (CFIF statement in the same page) and send the data
    and PDF in the same e-mail
    2) How can I set this up to differentiate the file names of
    the sent forms? I don't want all of the forms to come to the
    recipient with the exact same file name.
    The client is asking for this ASAP and I don't know what
    version of CF is running on the web server (it is the clients
    server)
    Any and all suggestions are welcome!
    Thanks,
    Jeremiah

    Hi Dan,
    Thanks for the pointer, I've got the page generating PDF's,
    how do I attach that PDF to the e-mail response? I don't know how
    to call the name of the generated PDF and attach it using
    <cfmailparam>. Do i have to save the file to the server and
    then call it using a path? We had another developer build us an
    upload set once that would send us files as attachments, I tried to
    incorporate that code, but it dealt with a directory on the server,
    and I don't know how to make that work.
    Thanks,
    Jeremiah

  • Reg: HRforms converted to PDF and send email to individual employee

    Hi Experts,
    The requirement is convert the HR form output to pdf and send email to respective employee in standard transaction. I copied RPCEDTX0 to  ZRPCEDTX0 and include RPCEDS09 to ZRPCEDS09, the changes need to be done for individual PERNR, I have modified the include as shown below.
       CALL FUNCTION 'HRPY_PROCESS_SET_PERNR_STATUS' after this, i have written my code
    * start of changes ARAFIQUE
      DATA: formname TYPE tdsfname VALUE 'HR_ESS_PAYSLIP_TO_PDF',
            fm_name TYPE rs38l_fnam,
            pinfo LIKE pc407 OCCURS 0 WITH HEADER LINE,
            pform type tt_pc408,
            pform_l like pc408 OCCURS 0 WITH HEADER LINE.
      IF xform[] IS NOT INITIAL.
        pform_l = xform.
        APPEND pform_1 TO pform.
        pinfo-molga = '99'.
        pinfo-forml = 'ZACC'.
        APPEND pinfo.
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
          EXPORTING
            formname                 = formname
    *       VARIANT                  = ' '
    *       DIRECT_CALL              = ' '
         IMPORTING
           fm_name                  = 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 FUNCTION fm_name
          EXPORTING
            pinfo                      =
            pform                      = xform[]
    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.
      ENDIF.
    * end of changes ARAFIQUE
    I found out in internet that the smartform 'HR_ESS_PAYSLIP_TO_PDF' will convert to PDF and then i can send email to PERNRS.

    Hi Experts,
    I have written the below code, the payslip is getting converted to PDF and it is getting saved in presentation server. I need to pick this file and mail, I created a customized function module for sending mail. I'm not able to send email to external addresses.
    Please find my code below. I will post the function module later.
    * start of changes ARAFIQUE
      DATA: "formname TYPE tdsfname VALUE 'HR_ESS_PAYSLIP_TO_PDF',
            "fm_name TYPE rs38l_fnam,
            p_info LIKE pc407 OCCURS 0 WITH HEADER LINE,
            "pform type tt_pc408,
            p_form LIKE pc408 OCCURS 0 WITH HEADER LINE,
            pdf_content TYPE xstring,
            pdf_fsize TYPE i,
            lv_output_length TYPE i,
            lt_binary_data TYPE STANDARD TABLE OF sdokcntbin,
            it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            it_message LIKE solisti1 OCCURS 0 WITH HEADER LINE.
      IF xform[] IS NOT INITIAL.
        p_form[] = xform[].
        p_info-molga = '99'.
        p_info-forml = 'ZACC'.
        p_info-pcols = 1.
        p_info-psize = 1.
        APPEND p_info.
        CALL FUNCTION 'CONVERT_PAYSLIP_TO_PDF'
          EXPORTING
            p_info      = p_info
          IMPORTING
            pdf_content = pdf_content
            pdf_fsize   = pdf_fsize
          TABLES
            p_form      = p_form[]
          EXCEPTIONS
            empty_form  = 1
            OTHERS      = 2.
        IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
          EXPORTING
            buffer        = pdf_content
          IMPORTING
            output_length = lv_output_length
          TABLES
            binary_tab    = lt_binary_data.
        CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              filename                        = 'C:\Test\Testing.pdf'
              filetype                        = 'BIN'
            TABLES
              data_tab                        = lt_binary_data
    *     FIELDNAMES                      =
           EXCEPTIONS
             file_write_error                = 1
             no_batch                        = 2
             gui_refuse_filetransfer         = 3
             invalid_type                    = 4
             no_authority                    = 5
             unknown_error                   = 6
             header_not_allowed              = 7
             separator_not_allowed           = 8
             filesize_not_allowed            = 9
             header_too_long                 = 10
             dp_error_create                 = 11
             dp_error_send                   = 12
             dp_error_write                  = 13
             unknown_dp_error                = 14
             access_denied                   = 15
             dp_out_of_memory                = 16
             disk_full                       = 17
             dp_timeout                      = 18
             file_not_found                  = 19
             dataprovider_exception          = 20
             control_flush_error             = 21
             OTHERS                          = 22
        it_receivers-receiver = 'gmailid'.
        it_receivers-rec_type = 'U'.
        it_receivers-com_type = 'INT'.
        APPEND it_receivers .
        it_message-line = 'Test for sending email'.
        APPEND it_message.
        CALL FUNCTION 'ZSEND_MAIL_ATTACHMENT'
          EXPORTING
            v_file_path  = 'C:\Test\Testing.pdf'
            v_subject    = 'Test Mail'
          TABLES
            it_receivers = it_receivers[]
            it_message   = it_message[].
        IF sy-subrc EQ 0.
          COMMIT WORK.
    *   Push mail out from SAP outbox
          SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.
        ENDIF.

  • Convertion of Smart form to pdf and sending mail to vendor for Invoice

    Hi All...
    now I am getting the output form of Invoice by the T-code  VF02
    here Im using Zreport & Zform...
    my requirment is to convert smartform output to PDF and send as an e-mail attachment on my Existing report
    where I  use the FM - CONVERT_OTF_2_PDF ..
    here my code
    REPORT  yinvoice_is.
    TABLES: vbrk,vbrp, vbak, vbap, vbkd .
    DATA : it_vbap TYPE STANDARD TABLE OF vbap WITH HEADER LINE ,
           it_vbrk LIKE STANDARD TABLE OF vbrk with header line,
           it_vbkd TYPE STANDARD TABLE OF vbkd WITH HEADER LINE ,
           it_vbrp TYPE STANDARD TABLE OF vbrp WITH HEADER LINE ,
           it_vbrp1 TYPE STANDARD TABLE OF vbrp WITH HEADER LINE ,
           it_vbfa TYPE STANDARD TABLE OF vbfa WITH HEADER LINE ,
           it_adrc1 TYPE STANDARD TABLE OF adrc WITH HEADER LINE,
           it_adrc2 TYPE STANDARD TABLE OF adrc WITH HEADER LINE.
    DATA: sum TYPE vbrp-kzwi5.
    DATA: v_vkbur  TYPE vkbur,
          v_adrnr1 TYPE adrnr,
          v_adrnr2 TYPE adrnr,
          v_vbelv  TYPE vbelv,
          v_delch  TYPE vbeln,
          v_bstkd  TYPE bstkd,
          v_kdmat  TYPE kdmat,
          v_kwert  TYPE kwert.
    DATA : fm_name TYPE rs38l_fnam.
    PARAMETER p_inv_no LIKE vbrk-vbeln OBLIGATORY  .
    Selecting Data
    SELECT VBELN
            ERDAT
            VKORG
            KUNRG
            STCEG
            NETWR
            MWSBK
            KNUMV
            KUNAG
            REGIO
      FROM vbrk
      INTO CORRESPONDING FIELDS OF TABLE it_vbrk
      WHERE vbeln = p_inv_no .
    SELECT matnr
           kzwi1
           kzwi2
           kzwi3
           kzwi4
           kzwi5
           netwr
           mwsbp
           meins
           fklmg
           arktx
           FROM vbrp
      INTO CORRESPONDING FIELDS OF TABLE it_vbrp
      WHERE vbeln = p_inv_no .
    Selecting Sales Order No.
    SELECT  SINGLE vbelv
      FROM  vbfa
      INTO  v_vbelv
      WHERE vbeln = p_inv_no
      AND   vbtyp_v = 'C'.
    IF sy-subrc = 0.
    Selecting Delivery Challan...
      SELECT  SINGLE vbeln
        FROM  vbfa
        INTO  v_delch
        WHERE vbelv = v_vbelv
        AND   vbtyp_n = 'J'.
      SELECT SINGLE bstkd
        FROM vbkd
        INTO v_bstkd
        WHERE vbeln = v_vbelv .
      SELECT matnr kdmat
        FROM vbap
        INTO CORRESPONDING FIELDS OF TABLE it_vbap
        WHERE vbeln = v_vbelv.
    ENDIF.
    READ TABLE it_vbrk INDEX 1.
    IF sy-subrc = 0.
      SELECT SINGLE kwert
        FROM konv
        INTO v_kwert
        WHERE knumv = iT_vbrk-knumv
        AND   kschl = 'HD00'.
    ENDIF.
    Selecting From Address
    SELECT SINGLE vkbur
      FROM vbak
      INTO v_vkbur
      WHERE vbeln = v_vbelv.
    IF sy-subrc = 0.
      SELECT SINGLE adrnr
        FROM tvbur
        INTO v_adrnr1
        WHERE vkbur = v_vkbur.
      IF sy-subrc = 0.
        SELECT SINGLE *
          FROM adrc
          INTO CORRESPONDING FIELDS OF it_adrc1
          WHERE addrnumber = v_adrnr1.
          APPEND it_adrc1.
      ENDIF.
    ENDIF.
    APPEND it_adrc.
    Selecting TO Address
    SELECT SINGLE adrnr
      FROM vbpa
      INTO v_adrnr2
      WHERE vbeln = p_inv_no
      AND   parvw = 'RE'.
    IF sy-subrc = 0.
      SELECT SINGLE *
        FROM adrc
        INTO CORRESPONDING FIELDS OF it_adrc2
        WHERE addrnumber = v_adrnr2.
        APPEND it_adrc2.
    ENDIF.
    Calling Function Module
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname                 = 'YINVOICE_IS'
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
    IMPORTING
       fm_name                  = 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.
    Calling Function Module
    CALL FUNCTION fm_name
    *'/1BCDWB/SF00000496'
      EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
      CONTROL_PARAMETERS         =
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
      OUTPUT_OPTIONS             =
      USER_SETTINGS              = 'X'
        i_vbelv                    = v_vbelv
        i_bstkd                    = v_bstkd
        i_kdmat                    = v_kdmat
        i_kwert                    = v_kwert
        i_delch                    = v_delch
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
      JOB_OUTPUT_INFO            =
      JOB_OUTPUT_OPTIONS         =
      TABLES
        it_vbrk                    = it_vbrk
        it_vbrp                    = it_vbrp
        it_vbap                    = it_vbap
        it_adrc1                   = it_adrc1
        it_adrc2                   = it_adrc2
    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.
    ENDFORM.                    "ENTRY

    hi,
    use this code..
    DATA: i_otf    TYPE itcoo OCCURS 0 WITH HEADER LINE,
          i_tline  TYPE TABLE OF tline 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,
    Variables declarations
          v_len_in LIKE sood-objlen,                            "#EC NEEDED
          v_lines_txt TYPE i,
          v_lines_bin TYPE i,
    Work Area declarations
          w_ctrlop    TYPE ssfctrlop,
          w_return    TYPE ssfcrescl,
          w_compop    TYPE ssfcompop,
          wa_objhead  TYPE soli_tab,
          wa_doc_chng TYPE sodocchgi1,
          wa_buffer   TYPE string.            "To convert from 132 to 255
    Put a IF ELSE condition whether u want form output or E-mail output..
    if it is a E-mail.. then call a small Sub-routine within your program..
    FORM f_email .
      w_ctrlop-getotf    = 'X'.
      w_ctrlop-no_dialog = 'X'.
      w_compop-tdnoprev  = 'X'.
      CALL FUNCTION fnam
        EXPORTING
          control_parameters = w_ctrlop
          output_options     = w_compop
          nast               = nast
          v_tcode            = v_tcode
        IMPORTING
          job_output_info    = w_return
        TABLES
          it_vbdkr           = it_tvbdkr[]
          it_vbdpr           = tvbdpr[]
          it_zglentitycode   = it_zglentitycode[]
          it_vttk            = it_vttk[]
          it_kna1            = it_kna1[]
          it_t005            = it_t005[]
          it_adrc            = it_adrc[]
          it_ekpo            = it_ekpo[]
          it_ekko            = it_ekko[]
          it_vbrp            = it_vbrp[]
          it_mara            = it_mara[]
          it_vbrk            = it_vbrk[]
          it_likp            = it_likp[]
          it_vttp            = it_vttp[]
          it_t001            = it_t001[]
          it_zlogdely        = it_zlogdely[]
          it_prod            = it_prod[]
          it_lineitems       = it_lineitems[]
          it_tvzbt           = it_tvzbt[]
          it_t173t           = it_t173t[]
          it_t005t           = it_t005t[]
          it_zplant          = it_zplant[]
          it_stxbitmaps      = it_stxbitmaps[]
          it_prod_desc       = it_prod_desc[].
      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[].
    *Converting the  OFT format data  to  PDf format
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format        = 'PDF'
          max_linewidth = 132
        IMPORTING
          bin_filesize  = v_len_in
        TABLES
          otf           = i_otf
          lines         = i_tline.
      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 = 'COMMERCIAL INVOICE'.
      APPEND i_objtxt.
      DESCRIBE TABLE i_objtxt LINES v_lines_txt.
      READ TABLE i_objtxt INDEX v_lines_txt.
      wa_doc_chng-obj_name   = 'COMMERCIAL INVOICE'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr  = 'COMMERCIAL INVOICE'.
      wa_doc_chng-sensitivty = 'F'.
      wa_doc_chng-doc_size   = v_lines_txt * 255.
      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  = 'COMMERCIAL INVOICE'.
      i_objpack-obj_descr = 'COMMERCIAL INVOICE'.
      APPEND i_objpack.
      IF it_adr6[] IS NOT INITIAL.
        LOOP AT it_adr6 INTO wa_adr6.
          CLEAR i_reclist.
          i_reclist-receiver = wa_adr6-smtp_addr.
          i_reclist-rec_type = 'U'.
          i_reclist-com_type = 'INT'.
          APPEND i_reclist.
        ENDLOOP.
        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.
      ENDIF.
    ENDFORM.                    " f_email
    regards
    vijay

  • Convert smartforms to pdf and sending it as email

    hi,
    i am converting smart form into PDF and sending it as an attachment with the e-mail. the e-mail is getting delivered but i am unable to open the PDF. it shows error saying "unable to open as it is not a supported file type or  it has been damaged".
    can any one please help me.

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

  • Smart form to PDF and send it by mail

    Hi ,
    I have smartform whihc i have to conver into pdf and send by mail. nay inputs is higghly appreciated

    Hi,
    You call the smartform-function module from within your printprogram.
    That smartform-function module has some standard import en export
    parameters(tables).
    One of the parameters (OTF) you have to mark (X).
    Than after the processing of the smartform(-function module) you get your
    otf back in an internal table.
    You have to convert this table to pdf with FM convert_to_pdf (or something
    like that).
    The output of this FM can be downloaded to the presentation server (pc) (FM
    gui_download) or written to the application server (SAP server) (transfer
    statement).
    Then use this link to send mail
    http://www.sap-img.com/abap/sending-email-with-attachment.htm
    Reward if useful!

  • I have created a PDF and password protected it for view. However, when reading the PDF in Adobe Reader app on the iPad the commenting and annotation options are not available. Is there a way to allow commenting and annotation in the app while password pro

    I have created a PDF and password protected it for view. However, when reading the PDF in Adobe Reader app on the iPad the commenting and annotation options are not available. Is there a way to allow commenting and annotation in the app while password protecting the document?

    Is there a setting that needs to be set to allow the annotation features?  I set password protection to open and then password for editing and set it to Any except page extraction, but it still did not give the annotation option

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

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

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

  • How to convert sap script to pdf and send it as email attachment

    hi,
    my requirement is to convert a standard sales order form to pdf and send it as email attachment. get me some sample code for the same
    thanks in advance

    Hi
    See this sample code and after that use the fun module to send the mail
    SO_NEW_DOCUMENT_ATT_SEND_API1
    REPORT zzz_jaytest .
    Types Declaration
    TYPES : BEGIN OF ty_pa0001,
    pernr TYPE pa0001-pernr,
    bukrs TYPE pa0001-bukrs,
    werks TYPE pa0001-werks,
    END OF ty_pa0001.
    Internal Table Declaration
    DATA : i_pa0001 TYPE STANDARD TABLE OF ty_pa0001, "For pa0001 Details
    i_otf TYPE STANDARD TABLE OF itcoo, "For OTF data
    i_content_txt TYPE soli_tab, "Content
    i_content_bin TYPE solix_tab, "Content
    i_objhead TYPE soli_tab,
    Work Area Declaration
    w_pa0001 TYPE ty_pa0001, "For pa0001 Details
    w_res TYPE itcpp, "SAPscript output
    "parameters
    w_otf TYPE itcoo, "For OTF
    w_pdf TYPE solisti1, "For PDF
    w_transfer_bin TYPE sx_boolean, "Content
    w_options TYPE itcpo, "SAPscript output
    "interface
    Variable Declaration
    v_len_in TYPE so_obj_len,
    v_size TYPE i.
    Constants Declaration
    CONSTANTS : c_x TYPE c VALUE 'X', "X
    c_locl(4) TYPE c VALUE 'LOCL', "Local Printer
    c_otf TYPE sx_format VALUE 'OTF', "OTF
    c_pdf TYPE sx_format VALUE 'PDF', "PDF
    c_printer TYPE sx_devtype VALUE 'PRINTER', "PRINTER
    c_bin TYPE char10 VALUE 'BIN', "BIN
    c_name TYPE string VALUE 'C:\ZZZ_JAYTEST.PDF',"Downloading
    "File Name
    c_form(11) TYPE c VALUE 'ZZZ_JAYTEST'. "Form Name
    START-OF-SELECTION.
    Selecting the records from pa0001
    SELECT pernr bukrs werks FROM pa0001
    INTO TABLE i_pa0001 UP TO 10 ROWS.
    Setting the options
    w_options-tdcopies = 1 ."Number of copies
    w_options-tdnoprev = c_x."No print preview
    w_options-tdgetotf = c_x."Return of OTF table
    w_options-tddest = c_locl."Spool: Output device
    Opening the form
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    form = c_form
    device = c_printer
    language = sy-langu
    OPTIONS = w_options
    IMPORTING
    RESULT = w_res.
    LOOP AT i_pa0001 INTO w_pa0001.
    Writting into the form
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    element = 'MAIN'
    window = 'MAIN'.
    ENDLOOP.
    Closing the form
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
    RESULT = w_res
    TABLES
    otfdata = i_otf
    EXCEPTIONS
    unopened = 1
    bad_pageformat_for_print = 2
    send_error = 3
    spool_error = 4
    codepage = 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.
    Converting OTF data to single line
    LOOP AT i_otf INTO w_otf.
    CONCATENATE w_otf-tdprintcom w_otf-tdprintpar
    INTO w_pdf.
    APPEND w_pdf TO i_content_txt.
    ENDLOOP.
    Converting to PDF Format
    CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
    EXPORTING
    format_src = c_otf
    format_dst = c_pdf
    devtype = c_printer
    CHANGING
    transfer_bin = w_transfer_bin
    content_txt = i_content_txt
    content_bin = i_content_bin
    objhead = i_objhead
    len = v_len_in
    EXCEPTIONS
    err_conv_failed = 1
    OTHERS = 2.
    v_size = v_len_in.
    Downloading the PDF File
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    bin_filesize = v_size
    filename = c_name
    filetype = c_bin
    TABLES
    data_tab = i_content_bin.
    If you r using this function module check it once....
    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.
    Fehlerhandling
    if sy-subrc <> 0.
    endif.
    or u can use the standard program RSTXPDFT4 to download the script into PDF format onto a particular location
    follow this link for sample program.
    http://searchsap.techtarget.com/tip/0,289483,sid21_gci1121833,00.html
    check...
    How to send smart form via email
    /people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp
    Regards
    Anji

Maybe you are looking for