Make Smartform to PDF and send it by email

Hi,
I need to design a pdf file with smartforms and want to send it after that by email. I have made a function, that is using so_object_send to send html emails. Can I also use that one to send emails with attachment?
When I´m writing a report, that is calling the function of my smartform, how can I "print" this smartform as a pdf then? And where is the file stored, that I can send it by mail afterwards?
I hope, I described my problem clear enough.
Thank You for every answer!
Arne

Hi Arne,
check this link hope this solves your problem.
Re: Smartforms to PDF
regards,
venu.

Similar Messages

  • 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

  • Smartform to PDF and send it to email

    Hi.
    I created a Smartform. In that i used 'SSF_FUNCTION_MODULE_NAME'.
    It is working fine.
    I converted it into PDF format by using this function module 'CONVERT_OTF'.
    it is also converted fine.
    Now i want send that PDF Document to my gmail ID.
    How i will use ''SO_DOCUMENT_SEND_API1'' Function module i did not understand.
    So, The Problem is how i use this 'SO_DOCUMENT_SEND_API1' function module and how i know it is reached to my gmail id. How to check that one in the Sent mails.
    In SAP how to check the Sent Box.  Is it possible or not. If possible plz tell me with screen shorts.
    Thank You.
    B. Krishna.

    Hi Krishna,
    here is the code.
    Code
    REPORT Z_SEND_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
    w_objhead      TYPE soli_tab,
    w_ctrlop      TYPE ssfctrlop,
    w_compop      TYPE ssfcompop,
    w_return      TYPE ssfcrescl,
    w_doc_chng      TYPE sodocchgi1,
    w_data      TYPE sodocchgi1,
    w_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_TEST2'
    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.
    The contents of w_return-otfdata contain the records in OTF format.
    i_otf[] = w_return-otfdata[].
    *Convert the OTF 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
    EXCEPTIONS
    err_max_linewidth = 1
    err_format = 2
    err_conv_not_possible = 3
    OTHERS = 4.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    *Convert the PDF from line size 132 to 255.
    LOOP AT i_tline.
    Replacing space by ~
    TRANSLATE i_tline USING ' ~'.
    CONCATENATE w_buffer i_tline INTO w_buffer.
    ENDLOOP.
    Replacing ~ by space
    TRANSLATE w_buffer USING '~ '.
    Appending 255 characters as a record
    DO.
    i_record = w_buffer.
    APPEND i_record.
    SHIFT w_buffer LEFT BY 255 PLACES.
    IF w_buffer IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    Refresh: i_reclist,
    i_objtxt,
    i_objbin,
    i_objpack.
    clear w_objhead.
    Object with PDF.
    i_objbin[] = i_record[].
    DESCRIBE TABLE i_objbin LINES v_lines_bin.
    Object with main text of the mail.
    i_objtxt = 'Find attached the output of the smart form.'.
    APPEND i_objtxt.
    i_objtxt = 'Regards,'.
    APPEND i_objtxt.
    i_objtxt = 'J.Jayanthi'.
    APPEND i_objtxt.
    DESCRIBE TABLE i_objtxt LINES v_lines_txt.
    Document information.
    w_doc_chng-obj_name = 'Smartform'.
    w_doc_chng-expiry_dat = sy-datum + 10.
    w_doc_chng-obj_descr = 'Smart form output'.
    w_doc_chng-sensitivty = 'F'. "Functional object
    w_doc_chng-doc_size = v_lines_txt * 255.
    Pack to main body as RAW.
    Object to be transported not in binary form
    CLEAR i_objpack-transf_bin.     
    Start line of object header in transport packet
    I_objpack-head_start = 1.
    Number of lines of an object header in object packet
    I_objpack-head_num = 0.
    Start line of object contents in an object packet
    I_objpack-body_start = 1.
    Number of lines of the object contents in an object packet
    I_objpack-body_num = v_lines_txt.
    Code for document class
    I_objpack-doc_type = 'RAW'.
    APPEND i_objpack.
    Packing as PDF.
    i_objpack-transf_bin = 'X'.
    i_objpack-head_start = 1.
    i_objpack-head_num = 1.
    i_objpack-body_start = 1.
    i_objpack-body_num = v_lines_bin.
    i_objpack-doc_type = 'PDF'.
    i_objpack-obj_name = 'Smartform'.
    CONCATENATE 'Smartform_output' '.pdf'
    INTO i_objpack-obj_descr.
    i_objpack-doc_size = v_lines_bin * 255.
    APPEND i_objpack.
    *Populating the recipient internet addresses where mails are to be sent in the table *i_reclist to be passed on the function module.
    CLEAR i_reclist.
    i_reclist-receiver = su-uname.
    i_reclist-express = 'X'.
    i_reclist-rec_type = 'B'. "Internal Address
    APPEND i_reclist.
    Sending mail.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = w_doc_chng
    put_in_outbox = 'X'
    TABLES
    packing_list = i_objpack
    object_header = w_objhead
    contents_hex = i_objbin
    contents_txt = i_objtxt
    receivers = i_reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8.
      IF sy-subrc <> 0.
    *MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    *WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        WRITE 'Sent Successfully'.
      ENDIF.
      SUBMIT rsconn01
      WITH mode EQ 'INT'
      AND RETURN.
    after that go to transaction SOST and there you can check it in the sent mail .
    Or you go to SAP Business workplace and there check your outbox.
    Regards.
    Mona

  • 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

  • In apple mail client, is it possible to open an email sent to me, make comments on it and send the amended email back to the sender?

    In apple mail client, is it possible to open an email sent to me, make comments on it and send the amended email back to the sender?

    No. Make your comments in your reply and send that.

  • Convert Smartform to PDF and send to SAP Workplace user

    Hi to all.
    I need help of somebody expert in SMARTFORM's.
    I need to convert a smartform into PDF format and to send as attachement for SAP workplace
    of the user.
    I developed the next code.
    IT is to function and to send the mail for SAP workplace, but it happens that smartform
    contains images (logos) and tables, when the user tries to open the file pdf in inbox gives
    to error - "An unrecognized token ' q0 ' was found".
    I tried to call a smartform only with text and functioned well.
    Somebody can help me?
    My code:
    Begin ***********************************************
    REPORT zteste_nsa_send_pdf_sap_office.
    DATA: t_print LIKE zeps_fm04 OCCURS 0 WITH HEADER LINE,
    v_size TYPE i.
    DATA: ls_bil_invoice TYPE lbbil_invoice.
    TABLES: nast.
    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.
    START-OF-SELECTION.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    formname = 'ZFPS_FICHA_VALORIZACAO'
    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'
    is_bil_invoice = ls_bil_invoice
    is_nast = nast
    is_repeat = 'X'
    IMPORTING
    job_output_info = w_return
    TABLES
    t_list = t_print
    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
    bin_filesize = v_len_in
    TABLES
    otf = i_otf
    lines = i_tline
    EXCEPTIONS
    err_max_linewidth = 1
    err_format = 2
    err_conv_not_possible = 3
    OTHERS = 4.
    IF sy-subrc EQ 0.
    ENDIF.
    Convert PDF from 132 to 255.
    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.
    SEND MAIL
    REFRESH: i_reclist,
    i_objtxt,
    i_objbin,
    i_objpack.
    CLEAR wa_objhead.
    Object with PDF.
    i_objbin[] = i_record[].
    Object with main text of the mail.
    i_objtxt = 'Fichas de Valorização e Esquemas Tipo'.
    APPEND i_objtxt.
    Document information.
    wa_doc_chng-obj_name = 'SMART'.
    wa_doc_chng-expiry_dat = sy-datum + 10.
    wa_doc_chng-obj_descr = 'Ficha de Valorização'.
    wa_doc_chng-sensitivty = 'F'. "Functional object
    wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + STRLEN( i_objtxt ).
    Pack to main body as RAW.
    Obj. to be transported not in binary form
    DESCRIBE TABLE i_objtxt LINES v_lines_txt.
    READ TABLE i_objtxt INDEX v_lines_txt.
    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.
    Packing as PDF.
    Obj. to be transported in binary form
    DESCRIBE TABLE i_objbin LINES v_lines_bin.
    READ TABLE i_objbin INDEX v_lines_bin.
    i_objpack-transf_bin = 'X'.
    i_objpack-head_start = 1.
    i_objpack-head_num = 0.
    i_objpack-body_start = 1.
    i_objpack-body_num = v_lines_bin.
    i_objpack-doc_type = 'PDF'.
    i_objpack-obj_name = 'SMART'.
    CONCATENATE 'Ficha_Valorizacao' '.pdf' INTO i_objpack-obj_descr.
    i_objpack-doc_size = ( v_lines_bin - 1 ) * 255 + STRLEN( i_objbin ).
    APPEND i_objpack.
    e-mail receivers.
    CLEAR i_reclist.
    i_reclist-receiver = sy-uname.
    i_reclist-rec_type = 'B'.
    i_reclist-express = 'X'.
    APPEND i_reclist.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = wa_doc_chng
    put_in_outbox = 'X'
    commit_work = ' '
    TABLES
    packing_list = i_objpack
    object_header = wa_objhead
    contents_bin = i_objbin
    contents_txt = i_objtxt
    receivers = i_reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8.
    IF sy-subrc EQ 0.
    ENDIF.
    End *************************************************
    Thanks very much to all and Happy New year...
    Nelson

    Hi
    See this report as example:
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    I believe before converting the print to pdf, you should print your document, get the spool and convert it.
    Max

  • 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

  • Convert SMARTFORM report to PDF and send as an email attachment

    Hi
    I am using the CONVERT_OTF function module to convert a SMARTFORM report in the "spool" to a PDF file. When I use the DOWNLOAD function module, the resulting file can be opened in acrobat.
    I would like to email the report in PDF format as an attachment. I am using the function module SO_NEW_DOCUMENT_ATT_SEND_API1 to create an attachment however the attached file is not being created correctly and When try to open, it gives 'File is damaged and could not be repaired' error message. I believe that somehow I am not using the SO_NEW_DOCUMENT_ATT_SEND_API1 function module correctly.
    Please help me to correct this
    Thanks
    Rohitha
    see my code below,
    I_OTF[] = W_RETURN-OTFDATA[].
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          FORMAT                = 'PDF'
          MAX_LINEWIDTH         = 132
        IMPORTING
          BIN_FILESIZE          = V_LEN_IN
        TABLES
          OTF                   = I_OTF
          LINES                 = I_TLINE
        EXCEPTIONS
          ERR_MAX_LINEWIDTH     = 1
          ERR_FORMAT            = 2
          ERR_CONV_NOT_POSSIBLE = 3
          OTHERS                = 4.
      IF SY-SUBRC <> 0.
      ENDIF.
      LOOP AT I_TLINE.
        TRANSLATE I_TLINE USING '~'.
        CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
      ENDLOOP.
      TRANSLATE WA_BUFFER USING '~'.
      DO.
        I_RECORD = WA_BUFFER.
        APPEND I_RECORD.
        SHIFT WA_BUFFER LEFT BY 132 PLACES.
        IF WA_BUFFER IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
      REFRESH:  I_RECLIST,
                I_OBJTXT,
                I_OBJBIN,
                I_OBJPACK.
      CLEAR WA_OBJHEAD.
      I_OBJBIN[] = I_RECORD[].
      I_OBJTXT = '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_to_PDF'.
      WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
      WA_DOC_CHNG-OBJ_DESCR = 'Smartform to PDF'.
      WA_DOC_CHNG-SENSITIVTY = 'F'.
      WA_DOC_CHNG-DOC_SIZE = STRLEN( I_OBJTXT ) + ( ( V_LINES_TXT - 1 ) * 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.
      I_OBJPACK-TRANSF_BIN = 'X'.
      I_OBJPACK-HEAD_START = 1.
      I_OBJPACK-HEAD_NUM = 1.
      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 = 'ATTACHMENT'.
      I_OBJPACK-OBJ_DESCR = 'test'.
      APPEND I_OBJPACK.
      CLEAR I_RECLIST.
      I_RECLIST-RECEIVER = 'my email address u2019.
      I_RECLIST-REC_TYPE = 'U'.
      APPEND I_RECLIST.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          DOCUMENT_DATA              = WA_DOC_CHNG
          PUT_IN_OUTBOX              = 'X'
          COMMIT_WORK                = 'X'
        TABLES
          PACKING_LIST               = I_OBJPACK
          OBJECT_HEADER              = WA_OBJHEAD
          CONTENTS_BIN               = I_OBJBIN
          CONTENTS_TXT               = I_OBJTXT
          RECEIVERS                  = I_RECLIST
        EXCEPTIONS
          TOO_MANY_RECEIVERS         = 1
          DOCUMENT_NOT_SENT          = 2
          DOCUMENT_TYPE_NOT_EXIST    = 3
          OPERATION_NO_AUTHORIZATION = 4
          PARAMETER_ERROR            = 5
          X_ERROR                    = 6
          ENQUEUE_ERROR              = 7
          OTHERS                     = 8.
      IF SY-SUBRC <> 0.
        WRITE:/ 'Error ', SY-SUBRC.
      ELSE.
        WRITE:/ 'Mail sent'.
      ENDIF.

    Hi rohitha.wijewardena ,
    Please find the below code which i followed and succeed ,
    CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
        EXPORTING
          pi_nast       = nast
          pi_country    = lv_dlv-land
          pi_addr_key   = lv_addr_key
          pi_repid      = sy-repid
          pi_screen     = lc_x
        IMPORTING
          pe_returncode = gv_retcode
          pe_itcpo      = lv_itcpo
          pe_device     = lv_device
          pe_recipient  = lv_recipient
          pe_sender     = lv_sender.
      IF gv_retcode = 0.
    *moving the data to composer and control parameters for output
        MOVE-CORRESPONDING lv_itcpo TO lv_composer_param.
        lv_control_param-device      = lv_device.
        lv_control_param-no_dialog   = lc_x.
        lv_control_param-preview     = lc_x.
        lv_control_param-getotf      = lv_itcpo-tdgetotf.
        lv_control_param-langu       = nast-spras.
        lv_composer_param-tdnoprint = space.
      ENDIF.
    *Getting the Smartform Function module using Standard Function module
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname                 = lv_formname           "Smartform Name
       IMPORTING
         fm_name                  = lv_fm_name
       EXCEPTIONS
         no_form                  = 1
         no_function_module       = 2
         OTHERS                   = 3
      IF sy-subrc <> 0.
        gv_retcode = sy-subrc.
        PERFORM protocol_update.
        PERFORM add_smfrm_prot.
      ENDIF.
    **Smartform function module to get the output
      CALL FUNCTION lv_fm_name
        EXPORTING
       control_parameters         = lv_control_param
       mail_recipient             = lv_recipient
       mail_sender                = lv_sender
         output_options             = lv_composer_param
         user_settings              = ' '
          is_bil_invoice             = lv_bil_invoice
          gt_header                  = gt_header
       IMPORTING
         job_output_info            = gv_job_output
        TABLES
          gt_item                    = gt_item
       EXCEPTIONS
         formatting_error           = 1
         internal_error             = 2
         send_error                 = 3
         user_canceled              = 4
         OTHERS                     = 5
      IF sy-subrc <> 0.
        gv_retcode = sy-subrc.
        PERFORM protocol_update.
        PERFORM add_smfrm_prot.
      ENDIF.
      IF nast-nacha = lc_mail.
        gt_otfdata[] = gv_job_output-otfdata[].
    *           Converting Smartform to PDF                          *
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format                = lc_pdf
            max_linewidth         = 10
          IMPORTING
            bin_filesize          = gv_binfilesize
            bin_file              = gv_pdf_xstring
          TABLES
            otf                   = gt_otfdata[]
            lines                 = gt_pdftab[]
          EXCEPTIONS
            err_max_linewidth     = 1
            err_format            = 2
            err_conv_not_possible = 3
            err_bad_otf           = 4
            OTHERS                = 5.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    *           Sending PDF to Email  using Class                     *
        IF NOT lv_email IS INITIAL .
          TRY.
             gv_send_request = cl_bcs=>create_persistent( ).
              gv_pdf_content = cl_document_bcs=>xstring_to_solix( gv_pdf_xstring ).
              gv_document = cl_document_bcs=>create_document(
                    i_type    = lc_pdf
                    i_hex     = gv_pdf_content
                    i_length  = gv_pdf_size
                    i_subject = lc_subject ).            "Subject for Email
              gv_send_request->set_document( gv_document ).
             gv_recipient = cl_cam_address_bcs=>create_internet_address( lv_email ).
              gv_send_request->add_recipient( gv_recipient ).
              gv_sent_to_all = gv_send_request->send( i_with_error_screen = lc_x ).
              COMMIT WORK.
              IF gv_sent_to_all IS INITIAL.
                MESSAGE i500(sbcoms) WITH lv_email.
              ELSE.
                MESSAGE s022(so).
              ENDIF.
            CATCH cx_bcs INTO gv_bcs_exception.
              MESSAGE i865(so) WITH gv_bcs_exception->error_type.
          ENDTRY.
        ENDIF.

  • How to convert smartform into pdf and send through mail

    Hi Guru,
    I want to send smartform to mail after converting into pdf format.
    if anyof u gives solution its greate.
    Thanks & Regards,
    Lakshmi..

    Hi,
    i can help you till
    downloading the smartform as pdf format
    check this
    DATA: GIT_BSIK LIKE BSIK OCCURS 0 WITH HEADER LINE.
    Variable declarations
    DATA:
    W_FORM_NAME TYPE TDSFNAME VALUE 'ZFII_EDD001',
    W_FMODULE TYPE RS38L_FNAM,
    W_CPARAM TYPE SSFCTRLOP,
    W_OUTOPTIONS TYPE SSFCOMPOP,
    W_BIN_FILESIZE TYPE I, " Binary File Size
    W_FILE_NAME TYPE STRING,
    W_FILE_PATH TYPE STRING,
    W_FULL_PATH TYPE STRING.
    Internal tables declaration
    Internal table to hold the OTF data
    DATA:
    T_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
    Internal table to hold OTF data recd from the SMARTFORM
    T_OTF_FROM_FM TYPE SSFCRESCL,
    Internal table to hold the data from the FM CONVERT_OTF
    T_PDF_TAB LIKE TLINE OCCURS 0 WITH HEADER LINE.
    This function module call is used to retrieve the name of the Function
    module generated when the SMARTFORM is activated
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
        FORMNAME = W_FORM_NAME
        VARIANT = ' '
        DIRECT_CALL = ' '
        IMPORTING
        FM_NAME = W_FMODULE
        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 the SMARTFORM using the function module retrieved above
    GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
    format of the output
    W_CPARAM-NO_DIALOG = 'X'.
    W_CPARAM-PREVIEW = SPACE. " Suppressing the dialog box
    " for print preview
    W_CPARAM-GETOTF = 'X'.
    Printer name to be used is provided in the export parameter
    OUTPUT_OPTIONS
    W_OUTOPTIONS-TDDEST = 'ZPC_'.
          CALL FUNCTION W_FMODULE
          EXPORTING
          ARCHIVE_INDEX =
          ARCHIVE_INDEX_TAB =
          ARCHIVE_PARAMETERS =
          CONTROL_PARAMETERS = W_CPARAM
          MAIL_APPL_OBJ =
          MAIL_RECIPIENT =
          MAIL_SENDER =
          OUTPUT_OPTIONS = W_OUTOPTIONS
          USER_SETTINGS = 'X'
          IMPORTING
          DOCUMENT_OUTPUT_INFO =
          JOB_OUTPUT_INFO = T_OTF_FROM_FM
          JOB_OUTPUT_OPTIONS =
               TABLES
                ITAB                       = GIT_BSIK
          EXCEPTIONS
          FORMATTING_ERROR = 1
          INTERNAL_ERROR = 2
          SEND_ERROR = 3
          USER_CANCELED = 4
          OTHERS = 5.
          IF SY-SUBRC <> 0.
            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    T_OTF[] = T_OTF_FROM_FM-OTFDATA[].
    Function Module CONVERT_OTF is used to convert the OTF format to PDF
          CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
          FORMAT = 'PDF'
          MAX_LINEWIDTH = 132
          ARCHIVE_INDEX = ' '
          COPYNUMBER = 0
          ASCII_BIDI_VIS2LOG = ' '
          PDF_DELETE_OTFTAB = ' '
          IMPORTING
          BIN_FILESIZE = W_BIN_FILESIZE
          BIN_FILE =
          TABLES
          OTF = T_OTF
          LINES = T_PDF_TAB
          EXCEPTIONS
          ERR_MAX_LINEWIDTH = 1
          ERR_FORMAT = 2
          ERR_CONV_NOT_POSSIBLE = 3
          ERR_BAD_OTF = 4
          OTHERS = 5
          IF SY-SUBRC <> 0.
            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    *To display File SAVE dialog window
    CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
    WINDOW_TITLE =
    DEFAULT_EXTENSION =
    DEFAULT_FILE_NAME =
    FILE_FILTER =
    INITIAL_DIRECTORY =
    WITH_ENCODING =
    PROMPT_ON_OVERWRITE = 'X'
    CHANGING
    filename = w_FILE_NAME
    path = w_FILE_PATH
    fullpath = w_FULL_PATH
    USER_ACTION =
    FILE_ENCODING =
    EXCEPTIONS
    CNTL_ERROR = 1
    ERROR_NO_GUI = 2
    NOT_SUPPORTED_BY_GUI = 3
    others = 4
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
    presentation server
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = W_bin_filesize
    filename = w_FULL_PATH
    FILETYPE = 'BIN'
    APPEND = ' '
    WRITE_FIELD_SEPARATOR = ' '
    HEADER = '00'
    TRUNC_TRAILING_BLANKS = ' '
    WRITE_LF = 'X'
    COL_SELECT = ' '
    COL_SELECT_MASK = ' '
    DAT_MODE = ' '
    CONFIRM_OVERWRITE = ' '
    NO_AUTH_CHECK = ' '
    CODEPAGE = ' '
    IGNORE_CERR = ABAP_TRUE
    REPLACEMENT = '#'
    WRITE_BOM = ' '
    TRUNC_TRAILING_BLANKS_EOL = 'X'
    WK1_N_FORMAT = ' '
    WK1_N_SIZE = ' '
    WK1_T_FORMAT = ' '
    WK1_T_SIZE = ' '
    IMPORTING
    FILELENGTH =
    tables
    data_tab = T_pdf_tab
    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
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    thanks & regards,
    Venkatesh

  • Smartforms to pdf and send mail

    PROGRAM :
    *& Report  ZDB_PDFMAIL
    REPORT  zdb_pdfmail.
    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,
    *i_record LIKE SOLIX OCCURS 0 WITH HEADER LINE,
    i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    w_objhead TYPE soli_tab,
    w_ctrlop TYPE ssfctrlop,
    w_compop TYPE ssfcompop,
    w_return TYPE ssfcrescl,
    w_doc_chng TYPE sodocchgi1,
    w_data TYPE sodocchgi1,
    w_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.
    DATA  doc LIKE docs OCCURS 0 WITH HEADER LINE.
    DATA bin_fsize TYPE i.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname           = 'ZZZ_TEST2'
      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_2_PDF'
    EXPORTING
      USE_OTF_MC_CMD               = 'X'
      ARCHIVE_INDEX                =
    IMPORTING
      BIN_FILESIZE                 =
    TABLES
       otf                          =
       doctab_archive               =
       lines                        =
    EXCEPTIONS
      ERR_CONV_NOT_POSSIBLE        = 1
      ERR_OTF_MC_NOENDMARKER       = 2
      OTHERS                       = 3
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        format                = 'PDF'
        max_linewidth         = 132
      IMPORTING
        bin_filesize          = v_len_in
      TABLES
        otf                   = i_otf
        lines                 = i_tline
      EXCEPTIONS
        err_max_linewidth     = 1
        err_format            = 2
        err_conv_not_possible = 3
        OTHERS                = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Convert PDF from 132 to 255.
    LOOP AT i_tline.
    Replacing space by ~
      TRANSLATE i_tline USING ' ~'.
      CONCATENATE w_buffer i_tline INTO w_buffer.
    ENDLOOP.
    Replacing ~ by space
    TRANSLATE w_buffer USING '~ '.
    DO.
      i_record = w_buffer.
    Appending 255 characters as a record
      APPEND i_record.
      SHIFT w_buffer LEFT BY 255 PLACES.
      IF w_buffer IS INITIAL.
        EXIT.
      ENDIF.
    ENDDO.
    *CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
       format                = 'PDF'
       max_linewidth         = 132
    IMPORTING
       bin_filesize          = v_len_in
    TABLES
       otf                   = i_otf
       lines                 = i_tline
    EXCEPTIONS
       err_max_linewidth     = 1
       err_format            = 2
       err_conv_not_possible = 3
       OTHERS                = 4.
    *IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    *ENDIF.
    Convert PDF from 132 to 255.
    *LOOP AT i_tline.
    Replacing space by ~
    TRANSLATE i_tline USING ' ~'.
    CONCATENATE w_buffer i_tline INTO w_buffer.
    *ENDLOOP.
    Replacing ~ by space
    *TRANSLATE w_buffer USING '~ '.
    *DO.
    i_record = w_buffer.
    Appending 255 characters as a record
    APPEND i_record.
    SHIFT w_buffer LEFT BY 255 PLACES.
    IF w_buffer IS INITIAL.
       EXIT.
    ENDIF.
    *ENDDO.
    REFRESH: i_reclist,
    i_objtxt,
    i_objbin,
    i_objpack.
    CLEAR w_objhead.
    Object with PDF.
    i_objbin[] = i_record[].
    DESCRIBE TABLE i_objbin LINES v_lines_bin.
    Object with main text of the mail.
    i_objtxt = 'Find attached the output of the smart form.'.
    APPEND i_objtxt.
    i_objtxt = 'Regards,'.
    APPEND i_objtxt.
    i_objtxt = 'J.Jayanthi'.
    APPEND i_objtxt.
    DESCRIBE TABLE i_objtxt LINES v_lines_txt.
    Document information.
    w_doc_chng-obj_name = 'Smartform'.
    w_doc_chng-expiry_dat = sy-datum + 10.
    w_doc_chng-obj_descr = 'Smart form output'.
    w_doc_chng-sensitivty = 'F'. "Functional object
    w_doc_chng-doc_size = v_lines_txt * 255.
    Pack to main body as RAW.
    Obj. to be transported not in binary form
    CLEAR i_objpack-transf_bin.
    Start line of object header in transport packet
    i_objpack-head_start = 1.
    Number of lines of an object header in object packet
    i_objpack-head_num = 0.
    Start line of object contents in an object packet
    i_objpack-body_start = 1.
    Number of lines of the object contents in an object packet
    i_objpack-body_num = v_lines_txt.
    Code for document class
    i_objpack-doc_type = 'RAW'.
    APPEND i_objpack.
    Packing as PDF.
    i_objpack-transf_bin = 'X'.
    i_objpack-head_start = 1.
    i_objpack-head_num = 1.
    i_objpack-body_start = 1.
    i_objpack-body_num = v_lines_bin.
    i_objpack-doc_type = 'PDF'.
    i_objpack-obj_name = 'Smartform'.
    CONCATENATE 'Smartform_output' '.pdf'
    INTO i_objpack-obj_descr.
    i_objpack-doc_size = v_lines_bin * 255.
    APPEND i_objpack.
    Document information.
    CLEAR i_reclist.
    e-mail receivers.
    i_reclist-receiver = '[email protected]'.
    i_reclist-express = 'X'.
    i_reclist-rec_type = 'U'. "Internet address
    APPEND i_reclist.
    Sending mail.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data              = w_doc_chng
        put_in_outbox              = 'X'
      TABLES
        packing_list               = i_objpack
        object_header              = w_objhead
        contents_hex               = i_objbin
        contents_txt               = i_objtxt
        receivers                  = i_reclist
      EXCEPTIONS
        too_many_receivers         = 1
        document_not_sent          = 2
        document_type_not_exist    = 3
        operation_no_authorization = 4
        parameter_error            = 5
        x_error                    = 6
        enqueue_error              = 7
        OTHERS                     = 8.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ERROR:
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_DYN_CALL_ILLEGAL_TYPE', was
      not caught and
    therefore caused a runtime error.
    The reason for the exception is:
    In the function "SO_NEW_DOCUMENT_ATT_SEND_API1", the STRUCTURE parameter
      "CONTENTS_HEX" is typed in such a way
    that only actual parameters are allowed, which are compatible in Unicode
      with respect to the fragment view. However, the specified actual
    parameter "I_OBJBIN" has an incompatible fragment view.
    PLS. TELL ME HOW TO UPDATE . 3KS
    WAITING FOR YOUR HELP

    I HAVE CHECK WHAT YOU SAID.
    CONCATENATE f_repid0(9) f_uname0(3) INTO lc_rq2name.
    SELECT * FROM tsp01 WHERE rq2name = lc_rq2name
      ORDER BY rqcretime DESCENDING.
    IN THE TABLE OF TSP01,HAVE NO MY RECORD.
    MAYBE MY PRINT REQUEST DOES NOT PUT INTO THE TABLE .
    WHY ? HOW TO SETTING ?
    OTHER ABAPER USER THE SAME PROGRAM ,HE CAN RUN SUCCESS.
    BUT SOMEONE NOT .
    Regards

  • Smartforms in pdf and send via mails

    Dear friends
    I have to send the smartforms via mail.
    but only have a preview of the smartform.
    please help.
    no spool no is generated.
    please help.
    thanks and reagrds
    vivek

    Hi Vivek,
    After the FM 'SSF_FUNCTION_MODULE_NAME' and fm_name,
    Change  smartform preview formate(OTF) to PDF . call FM.
    *---Function module to convert OTF data to PDF data format
            call function 'CONVERT_OTF'
              exporting
                format        = 'PDF'
                max_linewidth = 132
              importing
                bin_filesize  = l_v_pdf_size     "l_v_pdf_size    type i,
              tables
                otf           = l_it_otf_data         "l_it_otf_data   type standard table of itcoo initial size 0,
                lines         = l_it_pdf_data.      "l_it_pdf_data   type standard table of tline,
    then
    *---Function module to chnage width of PDF file to 255
            call function 'SX_TABLE_LINE_WIDTH_CHANGE'
              exporting
                line_width_dst              = '255'
              tables
                content_in                  = l_it_pdf_data[]
                content_out                 = l_it_pdf[]
              exceptions
                err_line_width_src_too_long = 1
                err_line_width_dst_too_long = 2
                err_conv_failed             = 3
                others                      = 4.
    and finelly.
    *---Function module to send mail
            call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
              exporting
                document_data              = l_wa_doc_chng 
                put_in_outbox              = c_check
                commit_work                = c_check
              tables
                packing_list               = l_it_objpack
                object_header              = l_wa_objhead
                contents_bin               = l_it_pdf
                receivers                  = l_it_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.
    Thanks.
    Mona.
    Edited by: Mona Singh on Dec 4, 2008 3:06 PM

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

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

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

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

  • To convert Smart Form output to PDF format and send it via email.

    Hi Friends,
    Could any one please tell me, how to convert the Smart Forms output to PDF format and send it via email to customer. If any one have the code, kindly mail me to [email protected]
    Thanks & Regards,
    John

    Refer the links -
    how to convert smartform into pdf and send through mail
    Smartform as PDF attachment to a mail.
    smartform pdf and mail
    smartform to pdf to mail
    Regrads,
    Amit
    Reward all helpful replies.

  • Reg: Converting Standard Payslip (PC00_M99_CEDT) to PDF and send via email

    Dear Experts,
    Please provide me a solution to convert the standard Pay slip (PC00_M99_CEDT) Remuneration statement to PDF and send it via email to individual employee by fetching the email ids through the info types.
    I checked the forum, few answers our complete but they have not given the solution.
    Thanks in advance
    Abdur
    Moderator message: moved to requirements forum (points-free!)
    Edited by: Thomas Zloch on Feb 7, 2011 11:53 AM
    Moderator message: moved back to ABAP General.
    Edited by: Thomas Zloch on Feb 9, 2011 1:03 PM

    Dear Experts,
    As suggested, I have written the below code.
    REPORT  ztest_period.
    DATA : td_listobject LIKE abaplist OCCURS 0 WITH HEADER LINE.
    DATA: txtlines(1024) TYPE c OCCURS 0 WITH HEADER LINE.
    DATA: list_tab TYPE TABLE OF abaplist,
          lt_objbin TYPE TABLE OF solisti1 WITH HEADER LINE.
    SUBMIT rpcedtx0 VIA SELECTION-SCREEN EXPORTING LIST TO MEMORY AND RETURN.
    CLEAR td_listobject. REFRESH td_listobject.
    CALL FUNCTION 'LIST_FROM_MEMORY'
      TABLES
        listobject = td_listobject
      EXCEPTIONS
        not_found  = 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.
    CHECK sy-subrc = 0.
    CALL FUNCTION 'TABLE_COMPRESS'
    TABLES
    in = td_listobject
    out = lt_objbin
    EXCEPTIONS
    compress_error = 1
    OTHERS = 2.
    &code&
    I'm getting the raw data from FM 'LIST_FROM_MEMORY' Please tell me how should i convert it to normal data.
    Once i get the data, I need to send an email for individual personnel number for the respective month.
    Please advice me the next step.
    Thanks and Regards,
    Abdur Rafique
    Edited by: abdur rafique on Feb 21, 2011 11:39 AM

Maybe you are looking for