<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SO_NEW_DOCUMENT_ATT_SEND_API1 cannot send out mail in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/so-new-document-att-send-api1-cannot-send-out-mail/m-p/8317946#M1637028</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Questions about this ancient API have been asked many, many times.  Search the forum for posts, including references to an SAP Note that contains both correct documentation for the API and working code.  Compare your code to the working version....better still, convert email processing to utilize current toolset, BCS, for which there are SAP demo programs, named like BCS_TEST* and BCS_EXAMPLE*.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Nov 2011 12:35:30 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-11-10T12:35:30Z</dc:date>
    <item>
      <title>SO_NEW_DOCUMENT_ATT_SEND_API1 cannot send out mail</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/so-new-document-att-send-api1-cannot-send-out-mail/m-p/8317944#M1637026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, &lt;/P&gt;&lt;P&gt;I am getting the error code '2' (Document not send).  Anyone knows whichever part that I did wrongly below??&lt;/P&gt;&lt;P&gt;Whichever part is the most suspicious for document not send?  Is it the gd_doc_data? Or the it_packing_list? Or objhead/objbin?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;*&amp;amp;Get the Email id and User id Whom you want to Send  ******&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;sort the lt_p0105 according to uname&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SORT lt_p0105 by uname ASCENDING.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; &amp;amp;-- Assign the Email id and User id to  Whom you want to Send  -------------&amp;amp;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  LOOP AT lt_p0105 INTO ls_p0105.&lt;/P&gt;&lt;P&gt;    wa_it_receivers-receiver   = ls_p0105-usrid_long. "&amp;amp;---- Assign Email id&lt;/P&gt;&lt;P&gt;    wa_it_receivers-rec_type   = 'U'.                    "&amp;amp;---- Send to External Email id&lt;/P&gt;&lt;P&gt;    wa_it_receivers-com_type   = 'INT'.&lt;/P&gt;&lt;P&gt;    wa_it_receivers-notif_del  = 'X'.&lt;/P&gt;&lt;P&gt;    wa_it_receivers-notif_ndel = 'X'.&lt;/P&gt;&lt;P&gt;    lv_uname                   = ls_p0105-uname.&lt;/P&gt;&lt;P&gt;    APPEND wa_it_receivers TO it_receivers .&lt;/P&gt;&lt;P&gt;    CLEAR wa_it_receivers.&lt;/P&gt;&lt;P&gt;    CLEAR ls_p0105.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp; - END of  Assign the Email id and User id to  Whom you want to Send  --&amp;amp;&lt;/P&gt;&lt;P&gt;  "&amp;amp;--- Read the Number of lines in the Internal Table&lt;/P&gt;&lt;P&gt;  DESCRIBE TABLE it_receivers LINES num_lines.&lt;/P&gt;&lt;P&gt;  "&amp;amp;--- Check the Sender Email id or SAP User id is got or not.&lt;/P&gt;&lt;P&gt;  IF num_lines IS NOT INITIAL.&lt;/P&gt;&lt;P&gt;*&amp;amp;----&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Add thetext to mail text table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&amp;amp;----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;*********&lt;STRONG&gt;&amp;amp; Send EMAIL MESSAGE  &amp;amp;&lt;/STRONG&gt;********************************&lt;/P&gt;&lt;P&gt;    DESCRIBE TABLE it_message LINES tab_lines.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   READ TABLE it_message INDEX tab_lines.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    gd_doc_data-doc_size = 1.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   gd_doc_data-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( it_message ).&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*Populate the subject/generic message attributes&lt;/P&gt;&lt;P&gt;    gd_doc_data-obj_langu = sy-langu.&lt;/P&gt;&lt;P&gt;    gd_doc_data-obj_name = 'SAPRPT'.&lt;/P&gt;&lt;P&gt;    gd_doc_data-obj_descr = psubject.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   gd_doc_data-sensitivty = 'F'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*Describe the body of the message&lt;/P&gt;&lt;P&gt;    CLEAR wa_it_packing_list.&lt;/P&gt;&lt;P&gt;    REFRESH it_packing_list.&lt;/P&gt;&lt;P&gt;    wa_it_packing_list-transf_bin = space.&lt;/P&gt;&lt;P&gt;    wa_it_packing_list-head_start = 1.&lt;/P&gt;&lt;P&gt;    wa_it_packing_list-head_num = 0.&lt;/P&gt;&lt;P&gt;    wa_it_packing_list-body_start = 1.&lt;/P&gt;&lt;P&gt;    DESCRIBE TABLE it_message LINES wa_it_packing_list-body_num.&lt;/P&gt;&lt;P&gt;    wa_it_packing_list-doc_type = 'RAW'.&lt;/P&gt;&lt;P&gt;    APPEND wa_it_packing_list TO it_packing_list.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Creation of the document attachment&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  LOOP AT int_storage.&lt;/P&gt;&lt;P&gt;    CONCATENATE int_storage-P0000-PERNR&lt;/P&gt;&lt;P&gt;                int_storage-P0002-VORNA&lt;/P&gt;&lt;P&gt;                int_storage-P0002-NACHN&lt;/P&gt;&lt;P&gt;                int_storage-P0019-MNDAT&lt;/P&gt;&lt;P&gt;                int_storage-P0019-BVMRK&lt;/P&gt;&lt;P&gt;                int_storage-TEXT_P0019_BVMRK&lt;/P&gt;&lt;P&gt;                int_storage-P0019-TERMN&lt;/P&gt;&lt;P&gt;                int_storage-P0019-TMART&lt;/P&gt;&lt;P&gt;                int_storage-TEXT_P0019_TMART&lt;/P&gt;&lt;P&gt;                int_storage-SYHR_A_P0019_AF_TEXT1&lt;/P&gt;&lt;P&gt;                int_storage-SYHR_A_P0019_AF_TEXT2&lt;/P&gt;&lt;P&gt;                int_storage-SYHR_A_P0019_AF_TEXT3&lt;/P&gt;&lt;P&gt;                INTO OBJBIN.&lt;/P&gt;&lt;P&gt;    APPEND OBJBIN.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;  DESCRIBE TABLE OBJBIN LINES TAB_LINES.&lt;/P&gt;&lt;P&gt;  OBJHEAD = 'Monitoring Task Email'.&lt;/P&gt;&lt;P&gt;  APPEND OBJHEAD.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Creation of the entry for the compressed attachment&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  wa_it_packing_list-TRANSF_BIN = 'X'.&lt;/P&gt;&lt;P&gt;  wa_it_packing_list-HEAD_START = 1.&lt;/P&gt;&lt;P&gt;  wa_it_packing_list-HEAD_NUM   = 1.&lt;/P&gt;&lt;P&gt;  wa_it_packing_list-BODY_START = 1.&lt;/P&gt;&lt;P&gt;  wa_it_packing_list-BODY_NUM   = TAB_LINES.&lt;/P&gt;&lt;P&gt;  wa_it_packing_list-DOC_TYPE   = 'TXT'.&lt;/P&gt;&lt;P&gt;  wa_it_packing_list-OBJ_NAME   = 'Monitoring Task Email List'.&lt;/P&gt;&lt;P&gt;  wa_it_packing_list-OBJ_DESCR  = 'EMAIL_LIST.TXT'.&lt;/P&gt;&lt;P&gt;  wa_it_packing_list-DOC_SIZE   = TAB_LINES * 255.&lt;/P&gt;&lt;P&gt;  APPEND wa_it_packing_list to it_packing_list.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;*&amp;amp;------ Call the Function Module to send the message to External and SAP Inbox&lt;/P&gt;&lt;P&gt;    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'&lt;/P&gt;&lt;P&gt;      EXPORTING&lt;/P&gt;&lt;P&gt;        document_data              = gd_doc_data&lt;/P&gt;&lt;P&gt;        put_in_outbox              = 'X'&lt;/P&gt;&lt;P&gt;        commit_work                = 'X'&lt;/P&gt;&lt;P&gt;      TABLES&lt;/P&gt;&lt;P&gt;        packing_list               = it_packing_list&lt;/P&gt;&lt;P&gt;        object_header              = objhead&lt;/P&gt;&lt;P&gt;        contents_bin               = objbin&lt;/P&gt;&lt;P&gt;        contents_txt               = it_message&lt;/P&gt;&lt;P&gt;        receivers                  = it_receivers&lt;/P&gt;&lt;P&gt;      EXCEPTIONS&lt;/P&gt;&lt;P&gt;        too_many_receivers         = 1&lt;/P&gt;&lt;P&gt;        document_not_sent          = 2&lt;/P&gt;&lt;P&gt;        document_type_not_exist    = 3&lt;/P&gt;&lt;P&gt;        operation_no_authorization = 4&lt;/P&gt;&lt;P&gt;        parameter_error            = 5&lt;/P&gt;&lt;P&gt;        x_error                    = 6&lt;/P&gt;&lt;P&gt;        enqueue_error              = 7&lt;/P&gt;&lt;P&gt;        OTHERS                     = 8.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   ENDIF.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ENDIF. "&amp;amp;---- END of Check the Sender Email id or SAP User id is got or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Siong Chao on Nov 10, 2011 12:39 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Siong Chao on Nov 10, 2011 12:41 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2011 11:39:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/so-new-document-att-send-api1-cannot-send-out-mail/m-p/8317944#M1637026</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2011-11-10T11:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: SO_NEW_DOCUMENT_ATT_SEND_API1 cannot send out mail</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/so-new-document-att-send-api1-cannot-send-out-mail/m-p/8317945#M1637027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Compare your code with this. This code works fine in our production system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other things you may want to look is whether the system settings in SCOT transaction are complete and there are other programs that are able to send emails.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*Populating the body
  lv_message = l_c_mess_1 .
  APPEND lv_message TO gt_message.
 
  lv_message = space.
  APPEND lv_message TO gt_message.
 
  CONCATENATE l_c_mess_5 p_fname '.' INTO lv_message SEPARATED BY space.
  APPEND lv_message TO gt_message.
 
  lv_message = space.
  APPEND lv_message TO gt_message.
 
  lv_message = l_c_mess_6.
  APPEND lv_message TO gt_message.
 
  lv_message = space.
  APPEND lv_message TO gt_message.
 
  lv_message = l_c_mess_7.
  APPEND lv_message TO gt_message.
 
  lv_message = space.
  APPEND lv_message TO gt_message.
 
  lv_message = l_c_mess_8.
  APPEND lv_message TO gt_message.
 
* Populate attachment
    LOOP AT gt_error INTO gs_error.
      CONCATENATE gs_error-client_id gs_error-client_run_id
                  gs_error-vendor_id
                  gs_error-row_id gs_error-carrier_vendor_code
                  gs_error-carrier_id
                  gs_error-invoice_number
                  gs_error-msg
               INTO gs_attachment SEPARATED BY gc_tab.
      gs_attachment+253(2) = '##'.
      REPLACE '##' WITH l_c_newline INTO gs_attachment.
      APPEND gs_attachment TO gt_attachment.
    ENDLOOP.
 
**File Type
  ld_format = 'XLS'.
**File Name
  IF NOT gt_error[] IS INITIAL.
    CONCATENATE 'Error Report' sy-datum sy-sysid sy-uname
      INTO ld_attfilename SEPARATED BY space.
  ELSE.
    CONCATENATE 'Success Report' sy-datum sy-sysid sy-uname
      INTO ld_attfilename SEPARATED BY space.
  ENDIF.
 
* Fill the document data and get size of attachment
  CLEAR gd_doc_data.
 
* Populate the subject/generic message attributes
  gd_doc_data-obj_langu = sy-langu.
  gd_doc_data-doc_size = 1.
  gd_doc_data-obj_name = 'SAPRPT'.
  IF NOT gt_error[] IS INITIAL.
    gd_doc_data-obj_descr = gv_err_subject.
  ELSE.
    gd_doc_data-obj_descr = gv_suc_subject.
  ENDIF.
  gd_doc_data-sensitivty = 'F'.
 
* Describe the body of the message
  CLEAR gt_packing_list.
  REFRESH gt_packing_list.
  gs_packing_list-transf_bin = space.
  gs_packing_list-head_start = 1.
  gs_packing_list-head_num = 0.
  gs_packing_list-body_start = 1.
  DESCRIBE TABLE gt_message LINES gs_packing_list-body_num.
  gs_packing_list-doc_type = 'RAW'.
  APPEND gs_packing_list TO gt_packing_list.
  CLEAR gs_packing_list.
 
*Describe the attachment info
  gs_packing_list-transf_bin = 'X'.
  gs_packing_list-head_start = 1.
  gs_packing_list-head_num = 1.
  gs_packing_list-body_start = 1.
  DESCRIBE TABLE gt_attachment LINES gs_packing_list-body_num.
  gs_packing_list-doc_type = ld_format.
  gs_packing_list-obj_name = ld_attfilename.
  gs_packing_list-obj_descr = ld_attfilename.
  gs_packing_list-doc_size = gs_packing_list-body_num * 255.
  APPEND gs_packing_list TO gt_packing_list.
 
**Populating Mail Recepients
  gs_receivers-receiver = p_email.
  gs_receivers-rec_type = 'C'.
  gs_receivers-com_type = 'INT'.
  gs_receivers-notif_del = 'X'.
  gs_receivers-notif_ndel = 'X'.
  gs_receivers-express = 'X'.
  APPEND gs_receivers TO gt_receivers.
 
*Function Module to send mail
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       EXPORTING
            document_data              = gd_doc_data
            put_in_outbox              = 'X'
            commit_work                = 'X'
       TABLES
            packing_list               = gt_packing_list
            contents_bin               = gt_attachment
            contents_txt               = gt_message
            receivers                  = gt_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.
    MESSAGE e024.
  ENDIF.
 
*Executing the standard mail sending program for immediate dispatch of
*mail
  SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2011 12:27:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/so-new-document-att-send-api1-cannot-send-out-mail/m-p/8317945#M1637027</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-10T12:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: SO_NEW_DOCUMENT_ATT_SEND_API1 cannot send out mail</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/so-new-document-att-send-api1-cannot-send-out-mail/m-p/8317946#M1637028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Questions about this ancient API have been asked many, many times.  Search the forum for posts, including references to an SAP Note that contains both correct documentation for the API and working code.  Compare your code to the working version....better still, convert email processing to utilize current toolset, BCS, for which there are SAP demo programs, named like BCS_TEST* and BCS_EXAMPLE*.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2011 12:35:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/so-new-document-att-send-api1-cannot-send-out-mail/m-p/8317946#M1637028</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-10T12:35:30Z</dc:date>
    </item>
  </channel>
</rss>

