Mail Send Functionality using SO_NEW_DOCUMENT_ATT_SEND_API1

hi,
i m using Fn Module "SO_NEW_DOCUMENT_ATT_SEND_API1" to send email with attachment.
I have written  a program which will fetch data in excel format . this excel should be sent as attachment to specified receiver. however i m having difficulties adding attachment to function module.
I specified under parameter "contents_bin" but its giving some error message related wth structure.
I chkd SDN and wasnt able to find any resolution yet.
Any suggestion or idea which can be useful on this.
Thanks.

REPORT  zsendemail                    .
PARAMETERS: psubject(40) type c default  'Hello',
            p_email(40)   type c default 'write email address' .
data:   it_packing_list like sopcklsti1 occurs 0 with header line,
        it_contents like solisti1 occurs 0 with header line,
        it_receivers like somlreci1 occurs 0 with header line,
        it_attachment like solisti1 occurs 0 with header line,
        gd_cnt type i,
        gd_sent_all(1) type c,
        gd_doc_data like sodocchgi1,
        gd_error type sy-subrc.
data:   it_message type standard table of SOLISTI1 initial size 0
                with header line.
*START-OF-SELECTION.
START-OF-SELECTION.
Perform populate_message_table.
*Send email message, although is not sent from SAP until mail send
*program has been executed(rsconn01)
PERFORM send_email_message.
*Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
*&      Form  POPULATE_MESSAGE_TABLE
      Adds text to email text table
form populate_message_table.
  Append 'Email line 1' to it_message.
  Append 'Email line 2' to it_message.
  Append 'Email line 3' to it_message.
  Append 'Email line 4' to it_message.
endform.                    " POPULATE_MESSAGE_TABLE
*&      Form  SEND_EMAIL_MESSAGE
      Send email message
form send_email_message.
Fill the document data.
  gd_doc_data-doc_size = 1.
Populate the subject/generic message attributes
  gd_doc_data-obj_langu = sy-langu.
  gd_doc_data-obj_name  = 'SAPRPT'.
  gd_doc_data-obj_descr = psubject.
  gd_doc_data-sensitivty = 'F'.
Describe the body of the message
  clear it_packing_list.
  refresh it_packing_list.
  it_packing_list-transf_bin = space.
  it_packing_list-head_start = 1.
  it_packing_list-head_num = 0.
  it_packing_list-body_start = 1.
  describe table it_message lines it_packing_list-body_num.
  it_packing_list-doc_type = 'RAW'.
  append it_packing_list.
Add the recipients email address
  clear it_receivers.
  refresh it_receivers.
  it_receivers-receiver = p_email.
  it_receivers-rec_type = 'U'.
  it_receivers-com_type = 'INT'.
  it_receivers-notif_del = 'X'.
  it_receivers-notif_ndel = 'X'.
  append it_receivers.
Call the FM to post the message to SAPMAIL
  call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       exporting
            document_data              = gd_doc_data
            put_in_outbox              = 'X'
       importing
            sent_to_all                = gd_sent_all
       tables
            packing_list               = it_packing_list
            contents_txt               = it_message
            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.
Store function module return code
  gd_error = sy-subrc.
Get it_receivers return code
  loop at it_receivers.
  endloop.
endform.                    " SEND_EMAIL_MESSAGE
*&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
      Instructs mail send program for SAPCONNECT to send email.
form initiate_mail_execute_program.
  wait up to 2 seconds.
  if gd_error eq 0.
      submit rsconn01 with mode = 'INT'
                    with output = 'X'
                    and return.
  endif.
endform.                    " INITIATE_MAIL_EXECUTE_PROGRAM

Similar Messages

  • Status of the mail sending option using SO_NEW_DOCUMENT_ATT_SEND_API1

    Hi experts,
    I m using SO_NEW_DOCUMENT_ATT_SEND_API1 function moduel for sending mails to dealers. That is, whenver i execute a Z transaction, the customer invoice details are getting displayed in report output. At the same time, the same output data is sent as mail to the respective dealers.
    Now teh user is asking whether there is any possiblity for the end users to have a proof of the mail which is being sent from the Z transaction. If the mail is sent, the end user who executes the Z transaction (mail sending transaction) should have that mail in his/her SENT ITEMS. If the mail not reaches the dealer, then the user must identify the mail bounce identification.
    Pls tell me how to achve the same..
    Regards,
    Shanthi

    Hi,
    Yes it is possible..
    Just pass 'X' to the exporting parameter 'put_in_outbox'. The user can check the send mail in 'sost'. All the details of the mail will be there. This will be the proof that the mail was sent.
    Reg the 2nd part of your query, if the mail is not delivered to any reciepent or to particular recipient, the details will be there in the SAP outbox, that also you can see through transaction 'sost'.
    Thanks & Regards
    Rocky

  • Sending mails to UWL using SO_NEW_DOCUMENT_ATT_SEND_API1 function module

    Hi all,
    is it possible to view mails send using SO_NEW_DOCUMENT_ATT_SEND_API1 function module to UWL?
    I am receving emails in my SAP Inbox.
    Please guide.
    thanks.

    Hi,
    You can only get the SAP mails into UWL notification tab with the Sonic connector (well of course with some custom development everything is possible).
    One trick to get the workflow for sending "mails" to UWL is to NOT use email sending step, but instead use a decision step in the workflow and send this work item to the user. The decision step can include the same message as the email, and have onl one option "Confirm" (or whatever). These you can easily display in UWL since they are normal work items.
    Regards,
    Karri

  • E-mail functionality using so_new_document_att_send_api1

    Hi
    We Implemented E-mail functionality in our tool useing "so_new_document_att_send_api1" standard FM but here im unable to attach excel document .How to attach a excel document in this standard FM plz help.
    Asif

    hi try this code
    *& Report  ZTEST_2                                                     *
    *& Report  ZTEST_2                                                     *
    REPORT  ztest_2                                 .
    TYPES : BEGIN OF t_email_update_iw32,
             aufnr LIKE viaufks-aufnr,
             vornr LIKE afvc-vornr,
             text(220),
            END OF t_email_update_iw32.
    DATA : gt_email_update_iw32 TYPE STANDARD TABLE OF t_email_update_iw32,
           gw_email_update_iw32 TYPE t_email_update_iw32.
    TYPES : BEGIN OF t_email_date_error,
             aufnr LIKE viaufks-aufnr,
             prueflos LIKE qamr-prueflos,
             merknr  LIKE qamr-merknr,
             text(220),
            END OF t_email_date_error.
    DATA : gt_email_date_error TYPE STANDARD TABLE OF t_email_date_error,
           gw_email_date_error TYPE t_email_date_error.
    TYPES : BEGIN OF t_email_conf_doc_error,
             aufnr LIKE viaufks-aufnr,
             vornr LIKE afvc-vornr,
             text(220),
            END OF t_email_conf_doc_error.
    DATA : gt_email_conf_doc_error TYPE STANDARD TABLE OF
    t_email_conf_doc_error,
           gw_email_conf_doc_error TYPE t_email_conf_doc_error.
    SELECTION-SCREEN : BEGIN OF BLOCK b4 WITH FRAME TITLE text-004.
    PARAMETERS : cb_email AS CHECKBOX DEFAULT 'X'.
    *SELECTION-SCREEN BEGIN OF LINE.
    *SELECTION-SCREEN COMMENT (16) text-007 FOR FIELD p_email1.
    PARAMETERS : p_email LIKE somlreci1-receiver,
                 p_email1 LIKE adr6-smtp_addr.
    PARAMETERS : p_table1 AS CHECKBOX,
                 p_table2 AS CHECKBOX,
                 p_table3 AS CHECKBOX.
    SELECTION-SCREEN : END OF BLOCK b4.
    CLEAR gw_email_update_iw32.
    REFRESH gt_email_update_iw32.
    gw_email_update_iw32-aufnr = '1234567'.
    gw_email_update_iw32-vornr = '0010'.
    gw_email_update_iw32-text = 'This is table1'.
    APPEND  gw_email_update_iw32 TO gt_email_update_iw32.
    CLEAR gw_email_update_iw32.
    gw_email_update_iw32-aufnr = '4564578'.
    gw_email_update_iw32-vornr = '0020'.
    gw_email_update_iw32-text = 'This is table1'.
    APPEND  gw_email_update_iw32 TO gt_email_update_iw32.
    gw_email_date_error-aufnr = '222615'.
    gw_email_date_error-prueflos = '1111'.
    gw_email_date_error-merknr = '2222'.
    gw_email_date_error-text = 'This is table2'.
    APPEND gw_email_date_error TO gt_email_date_error.
    gw_email_date_error-aufnr = '222615'.
    gw_email_date_error-prueflos = '3333'.
    gw_email_date_error-merknr = '4444'.
    gw_email_date_error-text = 'This is table2'.
    APPEND gw_email_date_error TO gt_email_date_error.
    gw_email_conf_doc_error-aufnr = '9900107987'.
    gw_email_conf_doc_error-vornr = '999999'.
    gw_email_conf_doc_error-text  = 'This is table3'.
    APPEND gw_email_conf_doc_error TO gt_email_conf_doc_error.
    gw_email_conf_doc_error-aufnr = '9900107987'.
    gw_email_conf_doc_error-vornr = '999999'.
    gw_email_conf_doc_error-text  = 'This is table3'.
    APPEND gw_email_conf_doc_error TO gt_email_conf_doc_error.
    DATA : lw_space VALUE ''.
    SET PARAMETER ID 'ZPDF' FIELD lw_space.
    DATA : pripar LIKE pri_params.
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
      EXPORTING
        in_parameters          = pripar
        line_size              = 255
        layout                 = 'X_65_132'
        no_dialog              = 'X'
      IMPORTING
        out_parameters         = pripar
      EXCEPTIONS
        archive_info_not_found = 1
        invalid_print_params   = 2
        invalid_archive_params = 3
        OTHERS                 = 4.
    NEW-PAGE PRINT ON PARAMETERS pripar NO DIALOG .
    RESERVE 5 LINES.
    DATA : text1(10) TYPE c  VALUE 'AUFNR',
           text2(10) TYPE c VALUE 'VORNR',
           text3(50) TYPE c VALUE 'TEXT'.
    IF p_table1 = 'X'.
      WRITE  AT 10   text1. WRITE AT 30  text2 . WRITE AT 30 text3.
      LOOP AT  gt_email_update_iw32 INTO  gw_email_update_iw32.
        WRITE : /  gw_email_update_iw32-aufnr , gw_email_update_iw32-vornr ,
    gw_email_update_iw32-text.
      ENDLOOP.
    ENDIF.
    WRITE : / sy-uline .
    IF p_table2 = 'X'.
      WRITE : / 'AUFNR' , 'PRUEFLOS' ,  'MERKNR', 'TEXT' .
      LOOP AT gt_email_date_error INTO gw_email_date_error.
        WRITE : / gw_email_date_error-aufnr, gw_email_date_error-prueflos,
    gw_email_date_error-merknr,gw_email_date_error-text.
      ENDLOOP.
    ENDIF.
    WRITE : / sy-uline .
    IF p_table3 = 'X'.
      WRITE : / 'AUFNR' , 'VORNR' , 'TEXT' .
      LOOP AT gt_email_conf_doc_error INTO gw_email_conf_doc_error.
        WRITE : / gw_email_conf_doc_error-aufnr,
    gw_email_conf_doc_error-vornr, gw_email_conf_doc_error-text.
      ENDLOOP.
    ENDIF.
    NEW-PAGE PRINT OFF.
    DATA : mtab_pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : rqident LIKE tsp01-rqident ,
           rqcretime LIKE tsp01-rqcretime .
    SELECT  rqident  rqcretime FROM tsp01
           INTO (rqident,rqcretime)
           WHERE rqowner = sy-uname
           ORDER BY rqcretime DESCENDING.
      EXIT.
    ENDSELECT.
    DATA: spool_id LIKE tsp01-rqident.
    MOVE  rqident TO spool_id.
    DATA : p_file LIKE rlgrap-filename VALUE 'C:\file.pdf' ,
           numbytes TYPE i,
           cancel.
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
      EXPORTING
        src_spoolid = spool_id
          NO_DIALOG =
          DST_DEVICE =
          PDF_DESTINATION =
    IMPORTING
        pdf_bytecount = numbytes
          PDF_SPOOLID =
          LIST_PAGECOUNT =
          BTC_JOBNAME =
          BTC_JOBCOUNT =
      TABLES
        pdf = mtab_pdf
    EXCEPTIONS
       err_no_abap_spooljob = 1
       err_no_spooljob = 2
       err_no_permission = 3
       err_conv_not_possible = 4
       err_bad_destdevice = 5
       user_cancelled = 6
       err_spoolerror = 7
       err_temseerror = 8
       err_btcjob_open_failed = 9
       err_btcjob_submit_failed = 10
       err_btcjob_close_failed = 11
       OTHERS = 12
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    end
    DATA :  w_buffer TYPE string. "To convert from 132 to 255
    DATA : i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    LOOP AT mtab_pdf.
    Replacing space by ~
      TRANSLATE mtab_pdf USING ' ~'.
      CONCATENATE w_buffer mtab_pdf 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.
    *start try
    DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
    DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
    DATA: doc_chng LIKE sodocchgi1.
    DATA : tab_lines TYPE c.
    doc_chng-obj_name = 'TEST'.
    doc_chng-obj_descr = 'Mail came successfully'.
    objtxt = 'Regards'.
    APPEND objtxt.
    objtxt = 'Nitin'.
    APPEND objtxt.
    objtxt = 'hahaha'.
    APPEND objtxt.
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    * ERSTELLEN DES EINTRAGS ZUM KOMPRIMIERTEN DOKUMENT
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'RAW'.
    APPEND objpack.
    * ERSTELLEN DER ANLAGE FUR DAS DOKUMENT
    **OBJBIN = '\O/ '. APPEND OBJBIN.
    **OBJBIN = ' '. APPEND OBJBIN.
    **OBJBIN = ' / \ '. APPEND OBJBIN.
    LOOP AT i_record.
      objbin[] =  i_record[].
    ENDLOOP.
    DESCRIBE TABLE objbin LINES tab_lines.
    *objhead = 'picasso.txt'. APPEND objhead.
    * Erstellen des Eintrags zur komprimierten Anlage
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 1.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'PDF'.
    objpack-obj_name = 'PDF File received '.
    objpack-obj_descr = 'PDF File received '.
    *objpack-doc_size = ( tab_lines ) * 255 .
    APPEND objpack.
    * Fullen der Empfangerliste
    refresh reclist.
    reclist-rec_type = 'U'.
    reclist-receiver = p_email1.
    APPEND reclist.
    reclist-rec_type = 'B'.
    reclist-receiver = sy-uname.
    APPEND reclist.
    reclist-rec_type = 'U'.
    reclist-receiver = p_email.
    APPEND reclist.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data              = doc_chng
        put_in_outbox              = 'X'
      TABLES
        packing_list               = objpack
       object_header              = objhead
        contents_bin               = objbin
        contents_txt               = objtxt
        receivers                  = reclist
      EXCEPTIONS
        too_many_receivers         = 1
        document_not_sent          = 2
        operation_no_authorization = 4
        OTHERS                     = 99.

  • Problem in sending attachment using "SO_NEW_DOCUMENT_ATT_SEND_API1"

    Hi All,
    I have a requirement of sending the data available in an internal table via email. I need to populate this content into excel sheet and send it as an attachment to recipients. I am using the following code for that.
    REPORT  z51515t_doc_att.
    DATA: objpack   LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    DATA: objhead   LIKE solisti1 OCCURS 1 WITH HEADER LINE.
    DATA: objbin    LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: objtxt    LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: reclist   LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
    DATA: doc_chng  LIKE sodocchgi1.
    DATA: tab_lines LIKE sy-tabix.
    DATA : BEGIN OF itab OCCURS 0,
              pernr LIKE p0001-pernr,
              name LIKE p0002-vorna,
           END OF itab.
    Creation of the document to be sent
    File Name
    doc_chng-obj_name = 'SENDFILE'.
    Mail Subject
    doc_chng-obj_descr = 'Delivered Mail'.
    Mail Contents
    objtxt = 'My Content 1 '.
    APPEND objtxt.
    objtxt = 'My Content2'.
    APPEND objtxt.
    DESCRIBE TABLE objtxt LINES tab_lines.
    Creation of the entry for the document
    CLEAR objpack-transf_bin. "Will get content from content_text
    objpack-head_start = 1. "Reads given row number in object header
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'RAW'.
    APPEND objpack.
    Prepare content for attachment
    DO 3 TIMES.
      itab-pernr = 182.
      itab-name = 'Prasath'.
      APPEND itab.
      itab-pernr = 1000.
      itab-name = 'Praveen'.
      APPEND itab.
    ENDDO.
    Populate attachment content
    LOOP AT itab.
      CONCATENATE itab-pernr itab-name INTO objbin-line.
      APPEND objbin.
    ENDLOOP.
    DESCRIBE TABLE objbin LINES tab_lines.
    Creation of the entry for the compressed attachment
    objpack-transf_bin = 'X'. "Will get content from content_bin
    objpack-head_start = 1.
    objpack-head_num   = 1.
    objpack-body_start = 1.
    objpack-body_num   = tab_lines.
    objpack-doc_type   = 'EXT'.
    objpack-obj_name   = 'WEBSITE'.
    objpack-obj_descr  = 'MyFile.XLS'.
    objpack-doc_size   = tab_lines * 255.
    APPEND objpack.
    target recipent
    CLEAR reclist.
    reclist-receiver = '[email protected]'.
    reclist-express  = 'X'.
    reclist-rec_type = 'U'.
    APPEND reclist.
    copy recipents
    CLEAR reclist.
    reclist-receiver = '[email protected]'.
    reclist-express  = 'X'.
    reclist-rec_type = 'U'.
    reclist-copy     = 'X'.
    APPEND reclist.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data              = doc_chng
        put_in_outbox              = 'X'
        commit_work                = 'X'
      TABLES
        packing_list               = objpack
        object_header              = objhead
        contents_bin               = objbin
        contents_txt               = objtxt
        receivers                  = reclist
      EXCEPTIONS
        too_many_receivers         = 1
        document_not_sent          = 2
        operation_no_authorization = 4
        OTHERS                     = 99.
    Now using this code i am able to send out the file but the data in the XL file is not aligned properly. When i open the attachment that i receive the contents of itab appear inside the same cell - A1 of the XL sheet. I want the data to be available in different rows and columns. How do i achieve this?
    Thanks,
    Prasath N

    See the below program it was sending the file   as  attach in XLS  format   by  column and rows  are  properly placed ...  see the
    <b>Code  in my program  :
    CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
                 con_tab TYPE x VALUE '09'.   "OK for non Unicode</b>
    REPORT  ZEMAIL_ATTACH                   .
    TABLES: ekko.
    PARAMETERS: p_email   TYPE somlreci1-receiver
                                      DEFAULT '[email protected]'.
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
          wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
      ebeln(10) TYPE c,
      ebelp(5)  TYPE c,
      aedat(8)  TYPE c,
      matnr(18) TYPE c,
    END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    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,
            gd_error    TYPE sy-subrc,
            gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
    *   Retrieve sample data from table ekpo
      PERFORM data_retrieval.
    *   Populate table with detaisl to be entered into .xls file
      PERFORM build_xls_data_table.
    *END-OF-SELECTION
    END-OF-SELECTION.
    * Populate message body text
      perform populate_email_message_body.
    * Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_message
                                          it_attach
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'XLS'
                                          'filename'
                                 changing gd_error
                                          gd_reciever.
    *   Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM initiate_mail_execute_program.
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp aedat matnr
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekpo.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_XLS_DATA_TABLE
    *       Build data table for .xls document
    FORM build_xls_data_table.
      CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
                 con_tab TYPE x VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    *constants:
    *    con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
    *    con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
             INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      LOOP AT it_ekpo INTO wa_charekpo.
        CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
                    wa_charekpo-aedat wa_charekpo-matnr
               INTO it_attach SEPARATED BY con_tab.
        CONCATENATE con_cret it_attach  INTO it_attach.
        APPEND  it_attach.
      ENDLOOP.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
    *       Send email
    FORM send_file_as_email_attachment tables pit_message
                                              pit_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.
      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[] = pit_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.
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
    *       Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
    *        Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test ekpo records'.
      APPEND it_message.
    endform.                    " POPULATE_EMAIL_MESSAGE_BODY
    reward  points  if it is usefull ....
    Girish

  • Mails in UWL using SO_NEW_DOCUMENT_ATT_SEND_API1

    Hi all,
    is it possible to view mails send using SO_NEW_DOCUMENT_ATT_SEND_API1 function module to UWL?
    I am receving emails in my SAP Inbox.
    Please guide.
    thanks.

    I believe you can use SONiC. You might want to do some research on that.

  • Mail Sending from a method

    Hi All,
    I kept  mail sending functionality in a bady.
    I kept the code in a method and i am using the Function module "SO_NEW_DOCUMENT_SEND_API1" to send the Email.But Suprig this function module returnd SY_SUBRC = 0 but when i checked in the SCOT its not showing the LOG and the mail is not going.I copied the  same code and i kept in a Report and tried but here  the Mail is sending.
    Please help how to resolve this .
    Regards
    Krishna

    Hi.
    Try using COMMIT WORK statement after the call to the FM.
    Also Check the below code.
    PARAMETERS: p_mail TYPE ad_smtpadr OBLIGATORY.
    DATA: i_mara TYPE STANDARD TABLE OF mara,  " MARA Entries
          i_marc TYPE STANDARD TABLE OF marc.  " MARC Entries
    DATA: l_text TYPE char255.  " 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
          i_attach1         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
    *Constants------------------------------------------------------------*
    CONSTANTS: c_tab(1) TYPE c VALUE
                   cl_abap_char_utilities=>horizontal_tab,
                                         " Tab Character
               c_cr(1)  TYPE c VALUE cl_abap_char_utilities=>cr_lf,
                                         " Line Feed for End-Of_line
               c_ext    TYPE soodk-objtp VALUE 'XLS'. " XLS Extension
    START-OF-SELECTION.
      SELECT * FROM mara INTO TABLE i_mara UP TO 20 ROWS.
      SELECT * FROM marc INTO TABLE i_marc UP TO 20 ROWS.
    * Preparing body of the Mail
      MOVE 'Mail Body' TO l_text.
      APPEND l_text TO i_content.
    * 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 = 'Material Details' ).
    * Preparing contents of attachment with Change Log
      PERFORM prepare_attachment.
      DESCRIBE TABLE i_mara 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 = 'Material Details'
              i_att_content_text   = i_attach[].
      DESCRIBE TABLE i_marc 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 = 'Material Plant Details'
              i_att_content_text   = i_attach1[].
    * 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_mail TO LOWER CASE.
        l_recipient = cl_cam_address_bcs=>create_internet_address( p_mail )
           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.
    *&      Form  PREPARE_ATTACHMENT
    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_con(50) TYPE c.        " Field Content in character format
    * Columns to be tab delimeted
      LOOP AT i_mara 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.
      LOOP AT i_marc 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_attach1.
            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
    Please treat above code just as reference...
    Hope this helps.
    Thanks,
    Balaji

  • Can you send encrypted e-mails using SO_NEW_DOCUMENT_ATT_SEND_API1

    We use SO_NEW_DOCUMENT_ATT_SEND_API1 to send e-mails to employees for various notifications.  The e-mails go out through SCOT and are sent to our lotus notes.
    We have a project being implemented, where the data we are sending in the note is kind of sensitive, so we'd like to see if we could send the e-mail as encrypted.   Does anyone know if there is some parameter we can set upon sending that would encrypt the text in the e-mail for sending?

    FORM pssword_prot_encryptpdf .
      DATA: BEGIN OF command_list OCCURS 0.
              INCLUDE STRUCTURE sxpgcolist.
      DATA: END OF command_list .
      DATA: BEGIN OF exec_protocol OCCURS 0.
              INCLUDE STRUCTURE btcxpm.
      DATA: END OF exec_protocol.
      DATA: status LIKE btcxp3-exitstat,
      commandname LIKE sxpgcolist-name VALUE 'ZTEST',
      sel_no LIKE sy-tabix.
    * GET LIST OF EXTERNAL COMMANDS
      CALL FUNCTION 'SXPG_COMMAND_LIST_GET'
        EXPORTING
          commandname     = commandname
          operatingsystem = sy-opsys
        TABLES
          command_list    = command_list
        EXCEPTIONS
          OTHERS          = 1.
      CALL FUNCTION 'SXPG_COMMAND_CHECK'
        EXPORTING
          commandname                = command_list-name
          operatingsystem            = sy-opsys
        EXCEPTIONS
          no_permission              = 1
          command_not_found          = 2
          parameters_too_long        = 3
          security_risk              = 4
          wrong_check_call_interface = 5
          x_error                    = 6
          too_many_parameters        = 7
          parameter_expected         = 8
          illegal_command            = 9
          communication_failure      = 10
          system_failure             = 11
          OTHERS                     = 12.
      CLEAR command_list.
      REFRESH command_list.
      DATA: v_dir_input      TYPE sxpgcolist-parameters.
      DATA: v_dir_input1      TYPE sxpgcolist-parameters.
      break developer.
      command_list-name = 'ZTEST'.
      command_list-opsystem = 'Windows NT'.
      CONCATENATE   'd:\pdf\' main_dtl-vbeln '.PDF' INTO name.
      CONCATENATE 'cmd /c d:\pdf\encryptpdf.exe' '-i' name  '-o ' name  '-u'  hdr-password INTO v_dir_input SEPARATED BY space .
      READ TABLE command_list INDEX sel_no.
      break developer.
      CONCATENATE command_list-opcommand v_dir_input INTO command_list-opcommand SEPARATED BY space.
    * CHECK AUTHORIZATION
      command_list-addpar = 'X'.
      APPEND command_list.
      CONSTANTS: c_extcom    TYPE sxpgcolist-name VALUE 'ZTEST',
                 c_oper      TYPE syopsys VALUE 'Windows NT'.
      DATA: t_result         TYPE STANDARD TABLE OF btcxpm.
      v_dir_input  =  command_list-opcommand.
      CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
        EXPORTING
          commandname                   = c_extcom
          additional_parameters         = v_dir_input
          operatingsystem               = c_oper
        TABLES
          exec_protocol                 = t_result
        EXCEPTIONS
          no_permission                 = 1
          command_not_found             = 2
          parameters_too_long           = 3
          security_risk                 = 4
          wrong_check_call_interface    = 5
          program_start_error           = 6
          program_termination_error     = 7
          x_error                       = 8
          parameter_expected            = 9
          too_many_parameters           = 10
          illegal_command               = 11
          wrong_asynchronous_parameters = 12
          cant_enq_tbtco_entry          = 13
          jobcount_generation_error     = 14
          OTHERS                        = 15.
    ENDFORM.                    " PSSWORD_PROT

  • Error getting while sending the Mails using 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    Hi ALL,
       I HAVE THE REQUIREMENT AS SEND A REPORT AS A MAIL. IAM USING FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' WHILE EXECUTING ITS NOT SHOWING ANY ERROR. BUT IAM NOT GETTING ANY MAIL. I CHECKED IN 'SOST' TCODE. THERE I SEE A MESSAGE LIKE 'CANNOT PROCESS THE MSG TYPE IN SAP SYSTEM'. PLS TELL ME THE WHAT IS THE PROBLE.

    Hi
    Please dont write in Capital letters, it considered as shouting. Hope you are aware of the forum rules.
    You can check if you have made anything wrong in coding by referring wiki link.
    [Sending Mails |http://wiki.sdn.sap.com/wiki/display/ABAP/SendingMails-HomePage]
    Regards
    Abhii

  • How to update the sent mail using SO_NEW_DOCUMENT_ATT_SEND_API1

    I have a requirement to update/ append the sent mail like a trail.Since i am sending mails using SO_NEW_DOCUMENT_ATT_SEND_API1, how can i update new contents to sent mails using this RFC???Please help me.

    you may have to store content of each time mail send then only, you can send with history.

  • Sending Carbon Copy using SO_NEW_DOCUMENT_ATT_SEND_API1

    Hello,
    I am using SO_NEW_DOCUMENT_ATT_SEND_API1' to send out email letting people know a direct deposit has been posted to their bank.  My problem is that the Acct department wants a carbon copy sent to their email address for each email that is sent.  Looking at this function, there is a line called
    RECEIVERS = IT_RECLIST.  When I take this thru debug, I see IT_RECLIST  defined as TYPE TABLE OF SOMLRECI1.  When I see the fields in IT_RECLIST, there is a field called copy, I assume I set this flag = 'X' to let the function know I want a carbon copy, correct?  Also, I am confused as to where the carbon copy email address would go, because all I see is a field called RECEIVER that is holding the recipients email.  Can you guys set me straight here?

    u can't send a carbon copy...instead while sending the email, the same can be sent to 2 or more people at a time. Add the email address to the existing list and it will trigger same email to the department.

  • Is there a way of using a mail merge function while on the iphone or ipad, i wish to email a "Word style, ot TXT" document to 250 of my contacts

    Is there a way of using a mail merge function while on the iphone or ipad, i wish to email a "Word style, ot TXT" document to 250 of my contacts, I have tried downloading my contacts to my PC's outlook but only 1 contact comes across at a time despite the fact that Icloud says downloading namedperson + 249 other contacts to a CSV file

    Hi everyone!
    Looking also for an app that allows me to merge email and send them out to each recipient individually. Apparently that's not possible yet. Here's what the guys at RedbitsApps told me about Group Email capabilities: 
    "The current version of the app relies on the device operating system to send the emails. For this reason, sending individual email instead of a single email to multiple recipients is not possible. Apple doesn't allow apps to send single emails to many recipients easily. We may use a custom sending software in a future version."
    Let's keep looking guys... 

  • "Send mail as" function in Apple Mail?

    Hi all,
    Does anyone know if Apple Mail has a "send mail as" function? Gmail has this so that you can sent up your gmail account to "send mail as" a different address than your gmail account. (This is great for cases like if you have a university alumni email address that is actually an alias that just forwards mail to another address -- if you set it up to forward to a gmail account, you can then set the gmail account to "send mail as" that address -- so when people receive mail from you, it looks like it was sent from [email protected] instead of [email protected] or whatever.)
    Anyway, I use gmail but I use my Apple Mail client to check it (using the POP feature), and the "send mail as" function on gmail only works if you sent mail through the web-based gmail. Does anyone know if there's a way to set this up in Apple Mail so that it will say the message is from my alias address intead of my gmail address?
    Thanks!!

    Hello,
    Back in December, in another Topic, it was explained to you how to search Mail Help to answer this very question. I just tested that method of managing alias addresses, other than those for a .mac, with my Gmail account, and it works.
    Search Mail Help with the search argument of "Using email aliases in Mail". You can also search in Support with the same search argument, and find the same article. In both cases, there exhibits to make it clearer that describing only with text, here.
    Did you try this, previously?
    Ernie

  • Missing message in mail sended with SO_NEW_DOCUMENT_ATT_SEND_API1

    Hi all,
    I've created a new function module which calls the SAP standard function module SO_NEW_DOCUMENT_ATT_SEND_API1. The mail is sent to the correct receiver. <b>The problem:</b> The message field in all my mails is empty. Only subject field is filled.
    Thanks in advance,
    Fabian
    Here is the coding:
    FUNCTION z_isa_send_mail_for_new_shipto.
    *"*"Lokale Schnittstelle:
    *"  IMPORTING
    *"     VALUE(I_RECEIVER) LIKE  SOMLRECI1 STRUCTURE  SOMLRECI1
    *"     VALUE(I_SUBJECT) LIKE  SODOCCHGI1-OBJ_DESCR
    *"  TABLES
    *"      T_TEXT STRUCTURE  SOLISTI1
    * Data Declaration
      DATA:
        lt_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
        reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE,
        gd_doc_data LIKE sodocchgi1.
      gd_doc_data-doc_size = 1.
    * Populate the subject/generic message attributes
      gd_doc_data-obj_langu = sy-langu.
      gd_doc_data-obj_name = 'SAPRPT'.
      gd_doc_data-obj_descr = i_subject.
      gd_doc_data-sensitivty = 'F'.
    * Describe the body of the message
      CLEAR lt_packing_list.
      REFRESH lt_packing_list.
      lt_packing_list-transf_bin = space.
      lt_packing_list-head_start = 1.
      lt_packing_list-head_num = 0.
      lt_packing_list-body_start = 1.
      DESCRIBE TABLE t_text LINES lt_packing_list-body_num.
      lt_packing_list-doc_type = 'RAW'.
      APPEND lt_packing_list.
    * Create receiver list
      reclist-receiver = i_receiver-receiver.
      reclist-rec_type = i_receiver-rec_type.
      APPEND reclist.
    * Send Message
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
           TABLES
                packing_list               = lt_packing_list
                contents_txt               = t_text
                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.
    ENDFUNCTION.

    Hi Fabian,
    Your code seemes to be good, maybe you schould ensure that your internal table is filled. I am not sure if it is really necessary to tell the function the exact size of your message...Have a look at my code..
    I send you my code for the same function,maybe this helps.
        DATA: lt_objpack  TYPE STANDARD TABLE OF sopcklsti1,
              lt_objhead  TYPE STANDARD TABLE OF solisti1,
              lt_objtxt   TYPE STANDARD TABLE OF solisti1,
              lt_reclist  TYPE STANDARD TABLE OF somlreci1.
        DATA: ls_objpack  TYPE sopcklsti1,
              ls_objhead  TYPE solisti1,
              ls_objtxt   TYPE solisti1,
              ls_reclist  TYPE somlreci1,
              ls_doc_chng TYPE sodocchgi1,
              ls_order    TYPE bapiret2.
        DATA: ld_tablines LIKE sy-tabix,
              ld_to       TYPE yylog_mail,
              ld_cc       TYPE yylog_mail,
              ld_bcc      TYPE yylog_mail,
              ld_uzeit(8) TYPE c,
              ld_datum(10) TYPE c.
    * Creation of the document to be sent
        CLEAR ls_doc_chng.
    * File Name
        ls_doc_chng-obj_name = 'SENDFILE'.
        CONCATENATE gd_datum+6(2) '.'
                    gd_datum+4(2) '.'
                    gd_datum(4)
               INTO ld_datum.
        CONCATENATE gd_uzeit(2) ':'
                    gd_uzeit+2(2) ':'
                    gd_uzeit+4(2)
               INTO ld_uzeit.
    * Mail Subject
        CONCATENATE 'MGV - Criação ordens de venda' ld_datum ld_uzeit
                          INTO ls_doc_chng-obj_descr SEPARATED BY space.
    * Mail Contents
        CLEAR ls_objtxt.
        ls_objtxt = 'MGV - Resultado da criação de ordens de venda.'.
        APPEND ls_objtxt TO lt_objtxt.
        CLEAR ls_objtxt.
        APPEND ls_objtxt TO lt_objtxt.
    * Pass messages from result table to the mail body
        LOOP AT i_order_result INTO ls_order.
          CLEAR ls_objtxt.
          ls_objtxt = ls_order-message.
          APPEND ls_objtxt TO lt_objtxt.
        ENDLOOP.
        DESCRIBE TABLE lt_objtxt LINES ld_tablines.
        CLEAR ls_objtxt.
    <b>    READ TABLE lt_objtxt INTO ls_objtxt INDEX ld_tablines.
        ls_doc_chng-doc_size = ( ld_tablines - 1 ) * 255
                                                   + STRLEN( ls_objtxt ).</b>
    * Creation of the entry for the compressed document
        CLEAR ls_objpack-transf_bin.
        ls_objpack-head_start = 1.
        ls_objpack-head_num = 0.
        ls_objpack-body_start = 1.
        ls_objpack-body_num = ld_tablines.
        ls_objpack-doc_type = 'RAW'.
        APPEND ls_objpack TO lt_objpack.
        ls_objhead = 'ENCOMENDAS'.
        APPEND ls_objhead TO lt_objhead.
    * GET RECIPENTS FROM CONFIGURATION TABLE
        CLEAR: ld_to,
               ld_cc.
        get_mail_config( EXPORTING id = 'TO'
                         IMPORTING val = ld_to ).
        get_mail_config( EXPORTING id = 'CC'
                         IMPORTING val = ld_cc ).
        get_mail_config( EXPORTING id = 'BCC'
                         IMPORTING val = ld_bcc ).
    * Completing the recipient list
    * target recipent
        CLEAR ls_reclist.
        ls_reclist-receiver = ld_to. "Destination variavel
        ls_reclist-express  = 'X'.
        ls_reclist-rec_type = 'U'.
        APPEND ls_reclist TO lt_reclist.
    * copy recipents
        IF NOT ld_cc IS INITIAL.
          CLEAR ls_reclist.
          ls_reclist-receiver = ld_cc.
          ls_reclist-express  = 'X'.
          ls_reclist-rec_type = 'U'.
          ls_reclist-copy     = 'X'.
          APPEND ls_reclist TO lt_reclist.
        ENDIF.
    * blind copy recipents
        IF NOT ld_bcc IS INITIAL.
          CLEAR ls_reclist.
          ls_reclist-receiver   = ld_bcc.
          ls_reclist-express    = 'X'.
          ls_reclist-rec_type   = 'U'.
          ls_reclist-blind_copy = 'X'.
          APPEND ls_reclist TO lt_reclist.
        ENDIF.
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
            document_data              = ls_doc_chng
            commit_work                = 'X'
          TABLES
            packing_list               = lt_objpack
            object_header              = lt_objhead
            contents_txt               = lt_objtxt
            receivers                  = lt_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 s112.
        ENDIF.

  • Function module 'SO_NEW_DOCUMENT_ATT_SEND_API1' not sending detail in email

    Hello experts,
    I am using function module 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send emails from a workflow method. The emails are being sent out and received but there is no detail in the email.
    The following are my parameters.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA                    = gd_doc_d
        PUT_IN_OUTBOX                    = 'X'
        COMMIT_WORK                      = 'X'
    TABLES
       PACKING_LIST                     = it_packin
       OBJECT_HEADER                    =
       CONTENTS_BIN                     =
       CONTENTS_TXT                     = it_message
       CONTENTS_HEX                     =
       OBJECT_PARA                      =
       OBJECT_PARB                      =
       RECEIVERS                        = it_receiv
    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
    I am inserting the detail in internal table 'it_message' but this is not transmitted....can anybody point out what I need to do to get detail in the email.
    Thanks to all who might reply..

    Hi,
    Have you made sure that your code works without workflow? Just put it to a report and execute it with dummy values and see if it sends the email properly. If that works, then the problem might be in the workflow. I would first make sure that the bindings are correct - that your internal table containing the details is passed to the task. This you can see from the workflow log in the container.
    Regards,
    Karri

Maybe you are looking for

  • HP Touchsmart 310 PC

    Can you tell me what and were the jack with long wire and red sensor tip plugs in to ,I have to ports on back of computer not sure witch one to use. This question was solved. View Solution.

  • Compare physical db with CASE model

    I'm using Designer Release 6.0 for PC. I'd like to compare (diff) my Designer db server model with my physical implementation residing on our server. We sometimes have developers change the physical db without changing the CASE tool (ERD, tables, etc

  • Login that does not use https

    I don't have access to https sites from my current work facility. Do you have a login method that does not use HTTPS? Is there any way that I can link my metalink account and my OTN account, and get to OTN through my metalink account? David

  • HAVING A HARD TIME WITH SPRY MENU BAR - #2

    To V1: Thanks for the answer - it took care of the problem. After I changed the links in the site to absolute,  another problem occurred: the links only function  on the uploaded site, not in DW (when I click on "preview in browser" in DW, the link i

  • Help needed with denied claim

    Hello, I am in the US and used PayPal to purchase some shipping materials (box, packing tape, bubble wrap) from an online UK retailer to be shipped to a UK address. After two weeks of emails asking for a delivery confirmation and then a refund becaus