Smartforms as OTF attachment in SAP inbox

Hi,
I need to create a smartform which is directly sent to the SAP inbox of the user as an OTF file.
Can anyone provide me with the code for this.
thanks and regards
Aviroop

Hi Aviroop
Check this thread,
smartform (otf) as pdf and sending as email-attachment
cheers
sameer

Similar Messages

  • Simple code to send ALV display as XLS attachment  to SAP inbox

    Hi All,
    Simple code to send ALV display as XLS attachment  to SAP inbox.
    Also i need to send only 200 records per attachement. So in this case i need send multiple attachment per mail
    Thanks,
    Lokesh

    The following code is used to send the internal table which u pass fo  the ALV display to be send as excel sheet attachment
    Internal table is it_attach[]
    ld_email               = po_email.
      ld_mtitle              = 'Email From Z377_EMAIL_XLS'.
      ld_format              = 'XLS'.
      ld_attdescription      = 'filename'.
      ld_attfilename         = 'Allot'.
      ld_sender_address      = ' '.
      ld_sender_address_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 li_content 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               = li_content
      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.

  • Read Attachment from SAP inbox and Transfer to Application Server Folder

    Hi
      I have one requirement . I have to developed one background program to read the all the attachment in SAP inbox and transfer all this attachment to sap application server folder.
    Thanks and Regards
    Shyam

    Hi Rajendra ,
    please try this code snippet , here we call a selection screen that allows us to browse the file name .
    PARAMETER : p_file TYPE localfile OBLIGATORY .
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file .
      data: user_action type i, filename type filetable, result type i,
            fn type file_table.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
      EXPORTING
        WINDOW_TITLE            = 'SELECT FILE'
       DEFAULT_EXTENSION       =
       DEFAULT_FILENAME        =
       FILE_FILTER             =
       INITIAL_DIRECTORY       =
       MULTISELECTION          =
      CHANGING
        FILE_TABLE              = filename
        RC                      = result
        USER_ACTION             = user_action
      EXCEPTIONS
        FILE_OPEN_DIALOG_FAILED = 1
        CNTL_ERROR              = 2
        ERROR_NO_GUI            = 3
        NOT_SUPPORTED_BY_GUI    = 4
        others                  = 5
      if user_action = cl_gui_frontend_services=>action_ok.
        clear p_file.
        loop at filename into fn.
          p_file = fn-filename.
        endloop.
      endif.
    Hopefully it helps

  • READ PDF ATTACHMENT FROM SAP INBOX

    Hi all,
    can any one tell me the FM's used to read the pdf attachment from the sap inbox.
    Thanks& Regards,
    Arun.

    Hi Arun
    See this [PDF|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/2c678dc3-0401-0010-3c80-8ef48f450491] of SCN
    Regards
    S@chin

  • OTF attachment in IW21

    Hi Experts,
    I am getting an OTF attachment to SAP inbox while executing IW21 Tcode.Is this a smartform or SAP Script?
    Can I make any changes in its display?I want to send a mail along with this modified OTF format.I have written code for triggering mail using BAdi.But was unable to find this OTF form.
    Can any one help me in finding this form and making necessary display changes to send it to as an attachment to the users?
    Regards,
    Sam

    Hi K.K,
    Thanx for ur inputs.
    I tried above method.Eventhough I was unable to open the pdf attachment in mail.
    Following is my code
    Data:it_otfdata            TYPE STANDARD TABLE OF itcoo,
    wa_otfdata            LIKE LINE OF  it_otfdata,
    V_PDF_XSTRING    TYPE        XSTRING.
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    format                = 'PDF'
    max_linewidth         = 132
    IMPORTING
    bin_filesize          = bin_filesize
    TABLES
    otf                   = it_otfdata
    lines                 = it_lines132
    EXCEPTIONS
    err_max_linewidth     = 1
    err_format            = 2
    err_conv_not_possible = 3
    err_bad_otf           = 4
    OTHERS                = 5.
    Later I used following functions also
    CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
          TABLES
            content_in                  = it_lines132
            content_out                 = it_lines255
          EXCEPTIONS
            err_line_width_src_too_long = 1
            err_line_width_dst_too_long = 2
            err_conv_failed             = 3
            OTHERS                      = 4.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
          EXPORTING
            BUFFER     = V_PDF_XSTRING
            TABLES
            BINARY_TAB = it_otfdata.
    But I am getting error message:Acrobat could not open pdf because it is either not a supported file type or because the file has been corrupted.
    I am using following steps to send attachment through mail
    document = cl_document_bcs=>create_document(
                          i_type    = 'PDF'
                          i_hex     = pdf_content
                          i_text    = text
                          i_length  = '12'
                         i_subject = 'Subject').
    CALL METHOD send_request->edit(
              i_hide_note     = 'X'
              i_starting_at_x = 12
              i_starting_at_y = 5
              i_ending_at_x   = 97
              i_ending_at_y   = 22 ).
    call method send_request->send.
    Regards,
    Sam
    Edited by: sam24 on Sep 5, 2010 2:49 PM

  • Sending the adobe form to SAP inbox with data (on submit action)

    Hi,
    I am fectching the data from the database table in WDDOINIT method and displaying it on the form. Now my requirement is that, on the action SUBMIT, I have to send this Form to SAP user inbox.
    I wrote a code to send the form as pdf attachment by giving the form name.. but the data are not passed. only the form goes to the sap inbox.
    My question is,  how to send the form as pdf attachment with the data that are fetched...?

    Hi,
    create the parameter FP_FORMOUTPUT as IMPORT parameter structure FPFORMOUTPUT and t_att_content_hex parameter is as XSTRING.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
        EXPORTING
          BUFFER                = FP_FORMOUTPUT-pdf
    *   APPEND_TO_TABLE       = ' '
    * IMPORTING
    *   OUTPUT_LENGTH         =
        TABLES
          BINARY_TAB            = t_att_content_hex
    For sending code as PDF attachment to SAP Inbox
    CLASS cl_bcs DEFINITION LOAD.
      DATA:
      lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
      lo_send_request = cl_bcs=>create_persistent( ).
    * Message body and subject
      DATA:
      lt_message_body TYPE bcsy_text VALUE IS INITIAL,
      lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
      APPEND 'Dear,' TO lt_message_body.
      append ' ' to lt_message_body.
      APPEND 'Please fill the attached form and send it back to us.'
      TO lt_message_body.
      append ' ' to lt_message_body.
      APPEND 'Thank You,' TO lt_message_body.
      lo_document = cl_document_bcs=>create_document(
      i_type = 'RAW'
      i_text = lt_message_body
      i_subject = 'Personnel Information Form' ).
      DATA: lx_document_bcs TYPE REF TO cx_document_bcs VALUE IS INITIAL.
      TRY.
          lo_document->add_attachment(
          EXPORTING
          i_attachment_type = 'PDF'
          i_attachment_subject = 'Personnel Information Form'
    * I_ATTACHMENT_SIZE =
    * I_ATTACHMENT_LANGUAGE = SPACE
    * I_ATT_CONTENT_TEXT =
    * I_ATTACHMENT_HEADER =
          i_att_content_hex = t_att_content_hex ).
        CATCH cx_document_bcs INTO lx_document_bcs.
      ENDTRY.
    * Add attachment
    * Pass the document to send request
      lo_send_request->set_document( lo_document ).
    * Create sender
      DATA:
      lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,
      l_send type ADR6-SMTP_ADDR value 'provide Email id here'.
      lo_sender = cl_cam_address_bcs=>create_internet_address( l_send ).
    * Set sender
      lo_send_request->set_sender(
      EXPORTING
      i_sender = lo_sender ).
    * Create recipient
      DATA:
      lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.
      lo_recipient = cl_sapuser_bcs=>create( sy-uname ).
    * Set recipient
      lo_send_request->add_recipient(
      EXPORTING
      i_recipient = lo_recipient
      i_express = 'X' ).
    *  lo_send_request->add_recipient(
    *  EXPORTING
    *  i_recipient = lo_recipient
    *  i_express = 'X' ).
    * Send email
      DATA: lv_sent_to_all(1) TYPE c VALUE IS INITIAL.
      lo_send_request->send(
      EXPORTING
      i_with_error_screen = 'X'
      RECEIVING
      result = lv_sent_to_all ).
    Thanks.

  • Connect SAP Inbox with XI

    hi,
        i have to get the mail attachment from SAP Inbox into                                        
        XI. Is it possible ?
    Please revert back asap
    gaurav

    Hi,
    to have a mail attachment just go thro this link
    Work with attachments
    Mail Sender Adapter with multiple sMIME attachments

  • Attachment in portal not getting displayed in SAP Inbox

    Hi All.
    While creating travel expense requests from Enterprise Portal, travelers create few attachments and then save the travel expense reports.
    A workflow then gets triggered and these travel expense reports reach SAP Inboxes of the checkers [in the finance department].
    The issue here is that these checkers do not have access to enterprise portal and they expect to see the attachments [that the traveler has created via the portal] via corresponding work items in their SAP Inboxes u2013 which currently is not happening!
    I checked the trip transaction that got created [in the backend / in SAP] and found the u2018attachment listu2019 menu option in GOS being disabled [may be because there is not even one attachment that has come to the backend!]
    What needs to be done so that the attachments can even be viewed from the backend / from SAP Inbox? Please suggest!
    Br,
    Hari

    Hi,
      You may have to check with the stylesheet, Check if the iVIews are using portal stylesheets from portal theme. If you want to use WD style sheets, The parameter for the web dynpro to use special theme "sap.useWebDynproStyleSheet" should be "true" (configuration adapter->webdynpro->sap.com->tcwddispwda) in visual admin. If you want to set this option for particular iViews only, then from the WD iView properties, set 'Supply Portal stylesheet' property to 'No'.
    Regards,
    Harini S

  • Error when reading a pdf attachment file in sap inbox

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

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

  • Read SAP Inbox Excel Attachment

    Hi,
    In my SAP inbox there is a mail with Excel attachment. Can you please let me know how to read this excel attachment. I am able to read contents but not the Excel Attachment.
    Thanks,
    Usman Malik

    Hi,
    I think using FM SO_DOCUMENT_READ_API1 you can read attachment content.
    Kindly check the following link:
    http://wiki.sdn.sap.com/wiki/display/ABAP/ReadingPDFattachmentfromsapinboxthrough+ABAP
    Thanks & Regards,
    S.Senthilkumar.

  • Sending ALV output to the SAP Inbox.

    Hi
    I'm using  SAP report <b>sendlist_bcs</b> for sending report output to the SAP inbox but attachment is not getting delivered.
    Can anybody help to resolve the issue...
    My report is:
    *& Report  ZTTEST_SAGAR
    REPORT  ZTTEST_SAGAR.
    *& Report  SENDLIST_BCS
    *& Sample report from note 190669 for sending lists via SAPconnect
    *& using the BCS interface
    *&  Note:
    *&  1. Set a commit work statement after the sending
    *&  2. Give binary data of type x not type c to send module, i.e.
    *&     use structure solix instead of soli and give it to tables
    *&     parameter contents_hex instead of contents_bin
    *&     Do this by filling contents_hex directly from the module
    *&     table_compress. In case of reading the data from spool, convert
    *&     to solix using so_solitab_to_solixtab
    *&  3. Don't calculate document size. It is done internally
    *report sendlist_bcs no standard page heading message-id so.
    selection-screen begin of block mode with frame title text-001.
    parameters: submit radiobutton group mode default 'X'.
    parameters: write  radiobutton group mode .
    parameters: spool  radiobutton group mode.
    selection-screen end of block mode.
    global data
    data g_list_content type solix_tab.
    data g_text_content type soli_tab.
    data sysid(10) TYPE C.
    *---- start-of-selection -
    start-of-selection.
      perform create_text_content changing g_text_content.
      perform create_list_content changing g_list_content.
      perform send using g_text_content
                         g_list_content.
    a commit work has to be set somewhere after the sending!
      commit work.
    Form routines                                                        *
    *&      Form  create_list_content
    form create_list_content changing list_content type solix_tab.
    1st possibility - use "submit <report> exporting list to memory"
      if submit = 'X'.
        perform use_submit changing list_content.
      endif.
    2nd possibility - create a new list within this report.
      if write = 'X'.
        perform write_a_list changing list_content.
      endif.
    3rd possibility - get list from spool
      if spool = 'X'.
        perform get_list_from_spool changing list_content.
      endif.
    endform.                                         "create_list_content
    *&      Form  create_text_content
    form create_text_content changing text_content type soli_tab.
      append 'This is the first line'  to text_content.         "#EC NOTEXT
      append 'This is the second line' to text_content.         "#EC NOTEXT
    convert the content from RAW to TXT
      call function 'SO_RAW_TO_RTF'
        tables
          objcont_old = text_content
          objcont_new = text_content
        exceptions
          others      = 0.
    endform.                                         "create_text_content
    *&      Form  SEND
    form send using text_content type soli_tab
                    list_content type solix_tab.
      data  send_request       type ref to cl_bcs.
      data  text               type bcsy_text.
      data  document           type ref to cl_document_bcs.
      data  recipient          type ref to if_recipient_bcs.
      data  bcs_exception      type ref to cx_bcs.
      data  sent_to_all        type os_boolean.
      try.
        create the send request
          send_request = cl_bcs=>create_persistent( ).
        create the document with attachments
        main document
          append 'Hi,' to text.
          append 'attached you will find the list.' to text.
          document = cl_document_bcs=>create_document(
                                    i_type    = 'RAW'
                                    i_text    = text
                                    i_subject = 'ABAPlist' ).
        add text attachment to document
          document->add_attachment( i_attachment_type    = 'TXT'
                                    i_attachment_subject = text-002
                                    i_att_content_text   = text_content ).
        add list attachment to document
          document->add_attachment( i_attachment_type    = 'ALI'
                                    i_attachment_subject = text-003
                                    i_att_content_hex    = list_content ).
        add document to send request
          send_request->set_document( document ).
          sysid = sy-sysid.
          data : uname type ad_uname.
          uname = 'USTZZSKAZI'.
        create recipient and add to send request
          recipient = cl_cam_address_bcs=>CREATE_RML_ADDRESS( i_syst     = sysid
                                                              i_client   = sy-mandt
                                                              i_username = uname ).
          send_request->add_recipient( i_recipient = recipient ).
        send
          sent_to_all = send_request->send( i_with_error_screen = 'X' ).
          if sent_to_all = 'X'.
           message s022.
          endif.
        catch cx_bcs into bcs_exception.
         message e865 with bcs_exception->error_type.
      endtry.
    endform.                    "send
    *&      Form  USE_SUBMIT
    form use_submit changing contents_hex type solix_tab.
      data listobject type table of abaplist.
    get the list object by calling the list in another report
    F1 on submit gives more information
      submit balvsd03 exporting list to memory and return.
    import the list from memory and store it in table listobject
      call function 'LIST_FROM_MEMORY'
        tables
          listobject = listobject
        exceptions
          not_found  = 1
          others     = 2.
      if sy-subrc <> 0.
       message e105 with 'LIST_FROM_MEMORY'.
      endif.
    free memory
      call function 'LIST_FREE_MEMORY'
        tables
          listobject = listobject
        exceptions
          others     = 1.
      if sy-subrc <> 0.
       message e105 with 'LIST_FREE_MEMORY'.
      endif.
    it's always necessary to compress the table.
    SAPconnect will decompress it
      call function 'TABLE_COMPRESS'                            "#EC *
        tables
          in             = listobject
          out            = contents_hex
        exceptions
          compress_error = 1
          others         = 2.
      if sy-subrc <> 0.
       message e105 with 'TABLE_COMPRESS'.
      endif.
    endform.                               " USE_SUBMIT
    *&      Form  WRITE_A_LIST
    form write_a_list changing contents_hex type solix_tab.
      data listobject type table of abaplist.
      perform write_list.
    Save the list and store table listobject
      call function 'SAVE_LIST'
        exporting
          list_index         = sy-lsind
        tables
          listobject         = listobject
        exceptions
          list_index_invalid = 1.
      if sy-subrc = 1.
       message e105 with 'SAVE_LIST'.
      endif.
    It's always necessary to compress the table
    SAPconnect will decompress it
      call function 'TABLE_COMPRESS'                            "#EC *
        tables
          in             = listobject
          out            = contents_hex
        exceptions
          compress_error = 1
          others         = 2.
      if sy-subrc <> 0.
       message e105 with 'TABLE_COMPRESS'.
      endif.
    endform.                               " WRITE_A_LIST
    *&      Form  GET_LIST_FROM_SPOOL
    form get_list_from_spool changing contents_hex type solix_tab.
      data spool_number     type rspoid.
      data contents_bin     type soli_tab.
      data print_parameters type pri_params.
      data valid            type c.
    write a list into spool
      call function 'GET_PRINT_PARAMETERS'
        importing
          out_parameters         = print_parameters
          valid                  = valid
        exceptions
          archive_info_not_found = 1
          invalid_print_params   = 2
          invalid_archive_params = 3
          others                 = 4.
      if sy-subrc <> 0.
       message e105 with 'GET_PRINT_PARAMETERS'.
      elseif valid is initial.
        return.
      endif.
      new-page print on parameters print_parameters no dialog.
      perform write_list.
      new-page print off.
      spool_number = sy-spono.
    you can also send OTF documents from spool with this function
    module. The importing parameter real_type gives you the doc type
    that you have to give to the send interface. The parameter is not
    used here
      call function 'RSPO_RETURN_SPOOLJOB'
        exporting
          rqident              = spool_number
        tables
          buffer               = contents_bin
        exceptions
          no_such_job          = 1
          job_contains_no_data = 2
          selection_empty      = 3
          no_permission        = 4
          can_not_access       = 5
          read_error           = 6
          type_no_match        = 7
          others               = 8.
      if sy-subrc <> 0.
       message e105 with 'RSPO_RETURN_SPOOLJOB'.
      endif.
    convert to hex table
      call function 'SO_SOLITAB_TO_SOLIXTAB'
        exporting
          ip_solitab  = contents_bin
        importing
          ep_solixtab = contents_hex.
    endform.                               " GET_LIST_FROM_SPOOL
    *&      Form  WRITE_LIST
    form write_list.
      data lt_scarr type table of scarr.
      data carr type scarr.
      select * from scarr into table lt_scarr.
      format color = 1.
      uline at /1(46).
      write: / sy-vline,
             'CARRID',   10 sy-vline,
             'CARRNAME', 35 sy-vline,
             'CURRCODE', 46 sy-vline.
      format color = 2.
      uline at /1(46).
      loop at lt_scarr into carr.
        write: / sy-vline,
               carr-carrid,   10 sy-vline,
               carr-carrname, 35 sy-vline,
               carr-currcode, 46 sy-vline.
      endloop.
      uline at /1(46).
      new-line.
    endform.                               " WRITE_LIST
    Thanks,
    sagar

    hi Sagar
    'SO_NEW_DOCUMENT_ATT_SEND_API1' function module for that.
    Example::::
    Data Declaration
    data pdf like tline occurs 0.
    data : objbin  like solisti1   occurs 0 with header line.
    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    type table of SOMLRECI1   with header line.
    Data: listobject like abaplist   occurs  1 with header line.
    data : objhex2 like objhex occurs 0 with header line.
    Data: tab_lines  type i,
          doc_size   type i,
          att_type   like SOODK-OBJTP.
    data: ls_drao like drao occurs 0,
         i_data like drao-orblk occurs 0,
          ls_doc_file like dms_doc_file,
          ls_draw like draw.
    data: begin of i_data occurs 0,
          orbkl like drao-orbkl,
           orblk like drao-orblk,
          end of i_data.
    data: w_data like i_data,
         w_data2 type drao-orbkl,
          wa_drao type drao.
    DATA: t_error(1) type c.
    DATA: t_return like BAPIRET2.
    *ls_draw-mandt = '200'.
    ls_draw-dokar = 'GPO'.
    ls_draw-doknr = 'Z10'.
    ls_draw-dokvr = '00'.
    ls_draw-doktl = '000'.
    ls_draw-dttrg = 'SAP-SYSTEM'.
    ls_draw-dAPPL = 'DOC'.
    ls_doc_file-fileno = '1'.
    ls_doc_file-dttrg = 'SAP-SYSTEM'.
    *Debug the cv03n transaction to see how the FMs are used
    CALL FUNCTION 'CV120_DOC_CHECKOUT_TO_TABLE'
      EXPORTING
      PS_COUT_DEF       =
        ps_doc_file       =   ls_doc_file
        ps_draw           =   LS_DRAW
      tables
      PT_DRAZ           =
        ptx_content       =    ls_drao
      PTX_DRAOZ         =
    EXCEPTIONS
       ERROR             = 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.
    loop at ls_drao into wa_drao.
      move:  wa_drao-orblk to w_data-orblk.
      append w_data to i_data.
    endloop.
    OBJPACK-HEAD_START = 1.
    DESCRIBE TABLE i_data LINES TAB_LINES.
    CALL FUNCTION 'ZOUTPUT_X_TABLESIZE_CHG'
    EXPORTING
      IV_APPEND          = ' '
       IV_BYTE_MODE       = 'X'
      IV_STRING          =
      IV_XSTRING         =
    IMPORTING
      EV_SIZE            =
      EV_LINES           =
      EV_STRING          =
      EV_XSTRING         =
    TABLES
       IT_DATA            = i_data
       ET_DATA            = objhex
    EXCEPTIONS
       NOENTRIES          = 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.
    loop at objhex.
      move-corresponding objhex to objhex2.
      append objhex2.
    endloop.
    docdata-obj_name  = 'TEST_ALI'.
    docdata-obj_descr = 'Test including ALI/HTML Attachment'.
      Main Text
    objtxt = 'Test Document.'.
    append objtxt.
    objtxt = 'You will find an ALI/HTML attachment '.
    append objtxt.
    objtxt = 'Have a nice day.'.
    append objtxt.
      Write Packing List (Main)
    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.
    Create Message Attachment
      Write Packing List (Attachment)
    att_type = 'PDF'.
    describe table objhex lines tab_lines.
    read     table objhex index tab_lines.
    objpack-doc_size = ( tab_lines ) * 255 ."+ strlen( i_data ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num   = 0.
    objpack-body_start = 1.
    objpack-body_num   = tab_lines.
    objpack-doc_type   = att_type.
    objpack-obj_name   = 'ATTACHMENT1'.
    objpack-obj_descr  = 'Attached Document1'.
    append objpack.
    Second attachment
    loop at objhex.
      move-corresponding objhex to objhex2.
      append objhex2.
    endloop.
    *att_type = 'DOC'.
    *describe table objhex lines tab_lines.
    *read     table objhex index tab_lines.
    *objpack-doc_size = ( tab_lines ) * 255 ."+ strlen( i_data ).
    *objpack-transf_bin = 'X'.
    *objpack-head_start = 1.
    *objpack-head_num   = 0.
    *objpack-body_start = 1.
    *objpack-body_num   = tab_lines.
    *objpack-doc_type   = att_type.
    *objpack-obj_name   = 'ATTACHMENT2'.
    *objpack-obj_descr  = 'Attached Document2'.
    *append objpack.
    Third attachment
    *loop at objhex.
    move-corresponding objhex to objhex2.
    append objhex2.
    *endloop.
    *att_type = 'PDF'.
    *describe table objhex lines tab_lines.
    *read     table objhex index tab_lines.
    *objpack-doc_size = ( tab_lines ) * 255 ."+ strlen( i_data ).
    *objpack-transf_bin = 'X'.
    *objpack-head_start = 1.
    *objpack-head_num   = 0.
    *objpack-body_start = 1.
    *objpack-body_num   = tab_lines.
    *objpack-doc_type   = att_type.
    *objpack-obj_name   = 'ATTACHMENT3'.
    *objpack-obj_descr  = 'Attached Document3'.
    *append objpack.
    Create receiver list
    data: reclist1 type sadrfd .
    reclist1-rec_fax = '650-467-2890'.
    reclist1-REC_STATE = 'US'.
    append reclist1.
    *read table reclist1 index 1.
    move reclist1(30) to reclist-receiver(30).
    move reclist1346(3) to reclist-receiver346(3).
    *reclist-receiver = reclist1."'US16503457900'.
    *move reclist1-rec_fax to reclist-receiver.
    *reclist-receiver = 'US16502796630'.  "'+1 (16502796999)'.
    reclist-REC_type = 'F'.
    *reclist-country = 'US'.
    *reclist-COM_TYPE = 'TELFAX'.
    *reclist-fax = 'US1650-279-6630'.
    append reclist.
    *reclist-receiver = sy-uname.                "<-- change internal user
    *reclist-rec_type = 'B'.
    *append reclist.
    Send Message
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data                     = docdata
         PUT_IN_OUTBOX                     = 'X'
         COMMIT_WORK                       = 'X'     "used from rel.6.10
      IMPORTING
        SENT_TO_ALL                        =
        NEW_OBJECT_ID                     =
      tables
        packing_list                      = objpack
        OBJECT_HEADER                     = objhead
        CONTENTS_BIN                      = objbin
        CONTENTS_TXT                      = objtxt
         CONTENTS_HEX                      = objhex
        OBJECT_PARA                        =
        OBJECT_PARB                        =
        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.
    **Please reward suitable points***
    With Regards
    Navin Khedikar

  • Sending mail to  SAP Inbox thru actions

    Hi Friends,
    I am having a requirement as below:
    Need to send one mail to SAP Inbox to the BP in one specific partner functions in an activity based upon the below conditions:
    1) Status of the transaction is open
    2) The Todays' Date -Created date =45
    I believe this can be done using actions. Please let me know if this is possible. If yes let me know the simplest way and if know let me know the alternative way.
    Thanks,
    Jai

    hi
    yes you can do this using actions
    just create your action profiel and there you give processing type as smartforms
    and then select your parameters\
    there are some standard actions available in the system for that you can refer to them
    then you inside the conditions give your conditions
    attach your action profile to your transaction and then you have what u wanted
    alternate way to achieve this is using FMs or workflows
    best regards
    ashish

  • Error While Opening PDF File in SAP Inbox

    Hello Experts,
    I am facing a weird error in SAP Inbox while opening a PDF files (both created by custom ABAP programs as well as the one attached to a new SAP Inbox message from my desktop & sent to my Inbox as a test).
    The error states that "This file does not have a program associated with it for performing this action. Please install program or, if one is already installed, create an association in the Default Programs control panel.".
    I checked TCode DC30 also & found an appropriate program is already maintained for PDF.
    I couldn't make out more out of this error message. Any inputs in this regard will be highly appreciable.
    Regards,
    Shaurya

    Hi,
      Find out the FM that's generating the actual error through de-bug and analyze the same by looking in OSS and or SDN.
    Regards
    Narasimhan

  • RE: Mail sent to SAP inbox-Urgent.

    Hi,
    I sent mail with attachment( internal table contents) to SAP inbox using the below codw.
       DATA: l_text TYPE char255.  " Text
    *DATA: l_text(280) TYPE c.  " Text
    DATA: l_lines TYPE i,
          l_size    TYPE  sood-objlen.      " Size of Attachment
    Mail related
    DATA: i_content         TYPE   soli_tab, " Mail content
          i_attach          TYPE   soli_tab. " Attachment
    DATA: l_send_request    TYPE REF TO    cl_bcs,   " E-Mail Send Request
          l_document        TYPE REF TO    cl_document_bcs,   " E-Mail Attachment
          l_recipient       TYPE REF TO    if_recipient_bcs,  " Distribution List
          l_sender          TYPE REF TO    if_sender_bcs,     " Address of Sender
          l_uname           TYPE           salrtdrcpt,        " Sender Name(SY-UNAME)
          l_bcs_exception   TYPE REF TO    cx_document_bcs,   " BCS Exception
          l_addr_exception  TYPE REF TO    cx_address_bcs,    " Address Exception
          l_send_exception  TYPE REF TO    cx_send_req_bcs.   " E-Mail sending Exception
    DATA: l_recipient_soos  TYPE           soos1.
    *data : p_uname TYPE ad_smtpadr .
    FORM send_to_sap_mail .
    Preparing body of the Mail
      MOVE 'Pending Delivery Documents List' TO l_text.
      APPEND l_text TO i_content.
    Preparing contents of attachment with Change Log
      PERFORM prepare_attachment.
    Creates persistent send request
      TRY.
          l_send_request = cl_bcs=>create_persistent( ).
    Creating Document
          l_document = cl_document_bcs=>create_document(
                                        i_type  = 'RAW'
                                        i_text  = i_content[]
                                        i_subject = 'Pending Delivery Documents' ).
         DESCRIBE TABLE i_mara LINES l_lines.
    DESCRIBE TABLE it_output LINES l_lines.
    Size to multiplied by 2 for UNICODE enabled systems
          l_size = l_lines * 2 * 255.
    Adding Attachment
          CALL METHOD l_document->add_attachment
            EXPORTING
              i_attachment_type    = c_ext
              i_attachment_size    = l_size
              i_attachment_subject = 'Pending Delivery Documents'
              i_att_content_text   = i_attach[].
    Add document to send request
          CALL METHOD l_send_request->set_document( l_document ).
    Get Sender Object
          l_uname = sy-uname.
          l_sender = cl_sapuser_bcs=>create( l_uname ).
          CALL METHOD l_send_request->set_sender
            EXPORTING
              i_sender = l_sender.
    E-Mail
          TRANSLATE p_uname TO UPPER CASE.
         l_recipient_soos-recesc = 'B'.
         l_recipient_soos-recnam = p_uname.
    Preparing recepient from SAP Logon Name
              CALL METHOD cl_send_request_bcs=>create_recipient_from_soos1
                    EXPORTING
                      i_soos1 = l_recipient_soos
                    RECEIVING
                      result = l_recipient.
    Add Recipient
          CALL METHOD l_send_request->add_recipient
            EXPORTING
              i_recipient  = l_recipient
              i_express    = 'U'
              i_copy       = ' '
              i_blind_copy = ' '
              i_no_forward = ' '.
    *Trigger E-Mail immediately
          l_send_request->set_send_immediately( 'X' ).
          CALL METHOD l_send_request->send( ).
          COMMIT WORK.
        CATCH cx_document_bcs INTO l_bcs_exception.
        CATCH cx_send_req_bcs INTO l_send_exception.
        CATCH cx_address_bcs  INTO l_addr_exception.
      ENDTRY.
    Refresh it_output.
    clear l_text.
    clear I_content.
    refresh I_attach.
    ENDFORM.                    " Send_to_sap_mail
    *&      Form  prepare_attachment
          text
    -->  p1        text
    <--  p2        text
    FORM prepare_attachment .
    FIELD-SYMBOLS: <lfs_table>,    " Internal table structure
                     <lfs_con>.      " Field Content
    DATA: l_text TYPE char1024.     " Text content for mail attachment
    DATA: l_text(1280) TYPE c.     " Text content for mail attachment
      DATA: l_con(50) TYPE c.        " Field Content in character format
    Columns to be tab delimeted
      LOOP AT it_output ASSIGNING <lfs_table>.
        DO.
          ASSIGN COMPONENT sy-index OF STRUCTURE <lfs_table>
                 TO <lfs_con>.
          IF sy-subrc NE 0.
            CONCATENATE c_cr l_text INTO l_text.
            APPEND l_text TO i_attach.
            EXIT.
          ELSE.
            CLEAR: l_con.
            MOVE <lfs_con> TO l_con.
            CONDENSE l_con.
            IF sy-index = 1.
              CLEAR: l_text.
              MOVE l_con TO l_text.
            ELSE.
              CONCATENATE l_text l_con INTO l_text
                 SEPARATED BY c_tab.
            ENDIF.
          ENDIF.
        ENDDO.
      ENDLOOP.
    ENDFORM.                    " prepare_attachment
    Here my problem is in my internal table i have 30 columns and the row output length is more than 255 char,
    and the SOLI structure fields defined as CHAR255, thats why when i am opening the sap mail attachment in Excel sheet, last three fields data is not displaying can any one please let me know the answer.

    loop at output_table.
      concatenate g_string
                         filed1
                         filed2
                     CL_ABAP_CHAR_UTILITIES=>CR_LF
      into g_string separted by
               CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    endloop.
    now pass the filled string to
    CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
        EXPORTING
          text            = g_string
      IMPORTING
        LENGTH          = LENGTH
        TABLES
          ftext_tab       = obj_bin.
    pass this objbin to SO_NEW_DOCUMENT_ATT_SEND_API1
    now you will get the desired excel sheet.
    NOte: dont put urgent in your subject.it is arule that people should not ans question which have urgent.
    Edited by: S.r.v.r.Kumar on Jun 18, 2008 10:25 PM

  • Smartform as PDF attachment to a mail.

    Hi,
    Can anyonce briefly explain me how the output of a smartform can be attached as a PDF file to a mail.
    Ques 1: Do we need to pass any explicit value to the smart form generated function module.  If so, what is the value and to which parameter do we need to pass.
    Ques 2: As far as i know OTF is converted to PDF. If this is so please explain how this is  done.
    Ques 3: How can a PDF document be made as an attachment, to a mail.
    If anyone can provide me an example it would be very great.
    Thanks & Regards,
    Goutham.

    Hi,
    Go through the following code:
    REPORT  z_smtf_pdf_and_email_aks01.
    DATA: x_ctrl_p       TYPE ssfctrlop,
          x_output_data  TYPE ssfcrescl.
    DATA: it_docs    LIKE docs       OCCURS 0 WITH HEADER LINE,
          it_lines   LIKE tline      OCCURS 0 WITH HEADER LINE,
          it_packing LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
    *-----Initialisation
    x_ctrl_p-no_dialog = 'X'.
    x_ctrl_p-getotf    = 'X'.
    x_ctrl_p-langu     = sy-langu.
              Internal Tables  Declaration                              *
    DATA: it_record    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          it_pcklist   LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
          it_mess      LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          it_objbin    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          it_receivers LIKE somlreci1  OCCURS 0 WITH HEADER LINE,
          it_table     LIKE solix      OCCURS 0 WITH HEADER LINE.
    DATA: it_soli      LIKE soli OCCURS 0 WITH HEADER LINE.
    *-----Work area declaration
    DATA: wa_doc_data  TYPE  sodocchgi1.
              Variable  Declaration                                     *
    DATA: v_lines_txt  TYPE  i,
          v_lines_bin  TYPE  i,
          v_lines      TYPE  i,
          v_fname TYPE rs38l_fnam,
          v_size TYPE i,
          v_filename TYPE rlgrap-filename.
              Start of selection event                                  *
    START-OF-SELECTION.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname = 'Z_SMTF_TEST_AKS01'
        IMPORTING
          fm_name  = v_fname.
      CALL FUNCTION v_fname
        EXPORTING
          control_parameters = x_ctrl_p
        IMPORTING
          job_output_info    = x_output_data.
    *-----Calling fumction module to convert output to pdf.
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
       IMPORTING
         bin_filesize   = v_size
       TABLES
         otf            = x_output_data-otfdata
         doctab_archive = it_docs
         lines          = it_lines.
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          max_linewidth         = 134
        IMPORTING
          bin_filesize          = v_size
        TABLES
          otf                   = x_output_data-otfdata
          lines                 = it_lines
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          OTHERS                = 4.
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
        EXPORTING
          line_width_dst              = 255
        TABLES
          content_in                  = it_lines
          content_out                 = it_soli
        EXCEPTIONS
          err_line_width_src_too_long = 1
          err_line_width_dst_too_long = 2
          err_conv_failed             = 3
          OTHERS                      = 4.
      CALL FUNCTION 'ZFUNC_CONVERT_DATA_ODC01'
       EXPORTING
         iv_byte_mode       = 'X'
       TABLES
         it_data            = it_lines
         et_data            = it_table.
    *-----To caluculate total number of lines of internal table
      DESCRIBE TABLE it_table LINES v_lines.
    *-----Function module to download the output file.
      CALL FUNCTION 'DOWNLOAD'
        EXPORTING
          bin_filesize = v_size
          filename     = ' '
          filetype     = 'BIN'
        IMPORTING
          act_filename = v_filename
        TABLES
          data_tab     = it_lines.
    *-----Create Message Body and Title and Description
      it_mess =
    'i have successfully converted smartform from otf format to pdf' .
      " and i have attached that in mail'.
      APPEND it_mess.
      wa_doc_data-obj_name   = 'smartform'.
      wa_doc_data-expiry_dat = sy-datum + 10.
      wa_doc_data-obj_descr  = 'smartform'.
      wa_doc_data-sensitivty = 'F'.
      wa_doc_data-doc_size   = v_lines * 255.
      APPEND it_pcklist.
    *-----PDF Attachment
      it_pcklist-transf_bin = 'X'.
      it_pcklist-head_start = 1.
      it_pcklist-head_num = 0.
      it_pcklist-body_start = 1.
      it_pcklist-doc_size =  v_lines_bin * 255 .
      it_pcklist-body_num = v_lines.
      it_pcklist-doc_type = 'PDF'.
      it_pcklist-obj_name = 'smartform'.
      it_pcklist-obj_descr = 'smart_desc'.
      it_pcklist-obj_langu  = 'E'.
      it_pcklist-doc_size   = v_lines * 255.
      APPEND it_pcklist.
    *-----Giving the receiver email-id
      CLEAR it_receivers.
      it_receivers-receiver = '[email protected]'
      it_receivers-rec_type = 'U'.
      APPEND it_receivers.
      CLEAR it_receivers.
      it_receivers-receiver = '[email protected]'.
      it_receivers-rec_type = 'U'.
      APPEND it_receivers.
      CLEAR it_receivers.
      it_receivers-receiver = '[email protected]'.
      it_receivers-rec_type = 'U'.
      APPEND it_receivers.
    *-----Calling the function module to sending email
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = wa_doc_data
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = it_pcklist
          contents_txt               = it_mess
          contents_hex               = it_table
          receivers                  = 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.
      IF sy-subrc = 0.
        SUBMIT rsconn01   WITH mode       = 'INT'
                          WITH output     = 'X'
                          WITH rfcgroup   = 'iwdf7ytc_YD3_94'
                          AND RETURN.
        REFRESH: it_receivers,
                 it_mess,
                 it_pcklist.
      ENDIF.
    Reward points if helpful answer.
    Ashvender

Maybe you are looking for