<?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 Send email using class cl_bcs without a &amp;quot;commit work&amp;quot; in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/send-email-using-class-cl-bcs-without-a-quot-commit-work-quot/m-p/3406745#M818125</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since upgrading from version 4.5 to version 4.7, about a year ago, a function module that we were using to send e-mail was no longer delivering an error message to the sender's e-mail address if the address to which the e-mail was sent was invalid.  We found that this error was occurring with the several function modules we were using,  SO_NEW_DOCUMENT_ATT_SEND_MAPI, SO_NEW_DOCUMENT_ATT_SEND_API1, and SO_OBJECT_SEND.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found a couple different examples on this forum that were using classes and methods from package SBCOMS to send e-mails.  So far so good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I have come across a situation where the point in the code where the e-mail is being sent, a commit work cannot be executed without causing an abend.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, my question is, how can you send an e-mail using classes and methods from package SBCOMS that does not require a commit work to be executed?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example of the code I am using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  try.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create persistent send request&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      send_request = cl_bcs=&amp;gt;create_persistent( ).&lt;/P&gt;&lt;P&gt;&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; Now we are ready to create the e-mail content itself. The first&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; record in our documents importing parameter will become the main&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; e-mail document. All other content will be inserted as attachments&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; to this document.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;      data: first(1) type c.&lt;/P&gt;&lt;P&gt;      clear first.&lt;/P&gt;&lt;P&gt;      data: documents_line like line of documents.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      loop at documents into documents_line.&lt;/P&gt;&lt;P&gt;        if first is initial.&lt;/P&gt;&lt;P&gt;          move 'X' to first.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Build the Main Document&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          if documents_line-content_hex[] is initial.&lt;/P&gt;&lt;P&gt;            document = cl_document_bcs=&amp;gt;create_document(&lt;/P&gt;&lt;P&gt;                                i_type    = documents_line-type&lt;/P&gt;&lt;P&gt;                                i_text    = documents_line-content_text&lt;/P&gt;&lt;P&gt;                                i_subject = documents_line-subject ).&lt;/P&gt;&lt;P&gt;          else.&lt;/P&gt;&lt;P&gt;            document = cl_document_bcs=&amp;gt;create_document(&lt;/P&gt;&lt;P&gt;                                i_type    = documents_line-type&lt;/P&gt;&lt;P&gt;                                i_hex     = documents_line-content_hex&lt;/P&gt;&lt;P&gt;                                i_subject = documents_line-subject ).&lt;/P&gt;&lt;P&gt;          endif.&lt;/P&gt;&lt;P&gt;        else.&lt;/P&gt;&lt;P&gt;          if documents_line-content_hex[] is initial.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Add Attachment&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;            call method document-&amp;gt;add_attachment&lt;/P&gt;&lt;P&gt;              exporting&lt;/P&gt;&lt;P&gt;                i_attachment_type    = documents_line-type&lt;/P&gt;&lt;P&gt;                i_attachment_subject = documents_line-subject&lt;/P&gt;&lt;P&gt;                i_att_content_text   = documents_line-content_text&lt;/P&gt;&lt;P&gt;                i_attachment_header  = documents_line-attachment_header.&lt;/P&gt;&lt;P&gt;          else.&lt;/P&gt;&lt;P&gt;            call method document-&amp;gt;add_attachment&lt;/P&gt;&lt;P&gt;              exporting&lt;/P&gt;&lt;P&gt;                i_attachment_type    = documents_line-type&lt;/P&gt;&lt;P&gt;                i_attachment_subject = documents_line-subject&lt;/P&gt;&lt;P&gt;                i_att_content_hex    = documents_line-content_hex&lt;/P&gt;&lt;P&gt;                i_attachment_header  = documents_line-attachment_header.&lt;/P&gt;&lt;P&gt;          endif.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;      endloop.&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; Now we can add our document (and its attachments) to our send request&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Add document to send request&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      call method send_request-&amp;gt;set_document( document ).&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; Next we will create a sender object (this function module&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; automatically uses the current user) and places it into our send&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; request.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get sender object&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      sender = cl_sapuser_bcs=&amp;gt;create( sy-uname ).&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Add sender&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      call method send_request-&amp;gt;set_sender&lt;/P&gt;&lt;P&gt;        exporting&lt;/P&gt;&lt;P&gt;          i_sender = sender.&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;Following the sender, we can add our recipients to the e-mail. If&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;requested by the calling program we will lookup the recipients e-mail&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;address from their SAP User Master using the BAPI,&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;BAPI_USER_GET_DETAIL.  If an e-mail address isn't maintained there,&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;we will try and create one by concatenating their user id together&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;with our default company domain name.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;      data: recipients_line like line of recipients.&lt;/P&gt;&lt;P&gt;      loop at recipients into recipients_line.&lt;/P&gt;&lt;P&gt;        if recipients_line-c_address is initial.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create recipient&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          clear iaddsmtp.&lt;/P&gt;&lt;P&gt;          refresh iaddsmtp.&lt;/P&gt;&lt;P&gt;          clear bapiadsmtp.&lt;/P&gt;&lt;P&gt;          clear recipient.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Read the E-Mail address for the user&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          call function 'BAPI_USER_GET_DETAIL'&lt;/P&gt;&lt;P&gt;            exporting&lt;/P&gt;&lt;P&gt;              username = recipients_line-uname&lt;/P&gt;&lt;P&gt;            tables&lt;/P&gt;&lt;P&gt;              return   = ireturn&lt;/P&gt;&lt;P&gt;              addsmtp  = iaddsmtp.&lt;/P&gt;&lt;P&gt;          loop at iaddsmtp where std_no = 'X'.&lt;/P&gt;&lt;P&gt;            clear bapiadsmtp.&lt;/P&gt;&lt;P&gt;            move iaddsmtp to bapiadsmtp.&lt;/P&gt;&lt;P&gt;          endloop.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;If no E-mail address was found, create one.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          if bapiadsmtp-e_mail = ''.&lt;/P&gt;&lt;P&gt;            concatenate recipients_line-uname local_domain&lt;/P&gt;&lt;P&gt;                      into recipients_line-c_address.&lt;/P&gt;&lt;P&gt;          else.&lt;/P&gt;&lt;P&gt;            move bapiadsmtp-e_mail to recipients_line-c_address.&lt;/P&gt;&lt;P&gt;          endif.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        recipient = cl_cam_address_bcs=&amp;gt;create_internet_address(&lt;/P&gt;&lt;P&gt;                                           recipients_line-c_address ).&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Add recipient with its respective attributes to send request&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        call method send_request-&amp;gt;add_recipient&lt;/P&gt;&lt;P&gt;          exporting&lt;/P&gt;&lt;P&gt;            i_recipient  = recipient&lt;/P&gt;&lt;P&gt;            i_express    = recipients_line-i_express&lt;/P&gt;&lt;P&gt;            i_copy       = recipients_line-i_copy&lt;/P&gt;&lt;P&gt;            i_blind_copy = recipients_line-i_blind_copy&lt;/P&gt;&lt;P&gt;            i_no_forward = recipients_line-i_no_forward.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      endloop.&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; Set the return status attributes of the message.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Set that you don't need a Return Status E-mail&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      data: status_mail type bcs_stml.&lt;/P&gt;&lt;P&gt;      status_mail = requested_status.&lt;/P&gt;&lt;P&gt;      call method send_request-&amp;gt;set_status_attributes&lt;/P&gt;&lt;P&gt;        exporting&lt;/P&gt;&lt;P&gt;          i_requested_status = requested_status&lt;/P&gt;&lt;P&gt;          i_status_mail      = status_mail.&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; Here is opportunity to send e-mail immediately. The E-mails still&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; get logged in the system and can be monitored from SCOT (or SOST).&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; The following code will trigger the send immediately.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;set send immediately flag&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      send_request-&amp;gt;set_send_immediately( 'X' ).&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; Finally we tell the system to send our email. We follow this up with&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; a commit work statement. Because the BCS is written as a Persistent&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; Object Class, no activity will take place until we trigger the commit&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; work.  We close by catching the BCS errors into the BCS exception&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; class.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Send document&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      call method send_request-&amp;gt;send( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      commit work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    catch cx_bcs into bcs_exception.&lt;/P&gt;&lt;P&gt;      raise exception bcs_exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;  endtry.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Feb 2008 21:11:10 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-22T21:11:10Z</dc:date>
    <item>
      <title>Send email using class cl_bcs without a "commit work"</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/send-email-using-class-cl-bcs-without-a-quot-commit-work-quot/m-p/3406745#M818125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since upgrading from version 4.5 to version 4.7, about a year ago, a function module that we were using to send e-mail was no longer delivering an error message to the sender's e-mail address if the address to which the e-mail was sent was invalid.  We found that this error was occurring with the several function modules we were using,  SO_NEW_DOCUMENT_ATT_SEND_MAPI, SO_NEW_DOCUMENT_ATT_SEND_API1, and SO_OBJECT_SEND.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found a couple different examples on this forum that were using classes and methods from package SBCOMS to send e-mails.  So far so good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I have come across a situation where the point in the code where the e-mail is being sent, a commit work cannot be executed without causing an abend.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, my question is, how can you send an e-mail using classes and methods from package SBCOMS that does not require a commit work to be executed?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example of the code I am using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  try.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create persistent send request&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      send_request = cl_bcs=&amp;gt;create_persistent( ).&lt;/P&gt;&lt;P&gt;&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; Now we are ready to create the e-mail content itself. The first&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; record in our documents importing parameter will become the main&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; e-mail document. All other content will be inserted as attachments&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; to this document.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;      data: first(1) type c.&lt;/P&gt;&lt;P&gt;      clear first.&lt;/P&gt;&lt;P&gt;      data: documents_line like line of documents.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      loop at documents into documents_line.&lt;/P&gt;&lt;P&gt;        if first is initial.&lt;/P&gt;&lt;P&gt;          move 'X' to first.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Build the Main Document&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          if documents_line-content_hex[] is initial.&lt;/P&gt;&lt;P&gt;            document = cl_document_bcs=&amp;gt;create_document(&lt;/P&gt;&lt;P&gt;                                i_type    = documents_line-type&lt;/P&gt;&lt;P&gt;                                i_text    = documents_line-content_text&lt;/P&gt;&lt;P&gt;                                i_subject = documents_line-subject ).&lt;/P&gt;&lt;P&gt;          else.&lt;/P&gt;&lt;P&gt;            document = cl_document_bcs=&amp;gt;create_document(&lt;/P&gt;&lt;P&gt;                                i_type    = documents_line-type&lt;/P&gt;&lt;P&gt;                                i_hex     = documents_line-content_hex&lt;/P&gt;&lt;P&gt;                                i_subject = documents_line-subject ).&lt;/P&gt;&lt;P&gt;          endif.&lt;/P&gt;&lt;P&gt;        else.&lt;/P&gt;&lt;P&gt;          if documents_line-content_hex[] is initial.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Add Attachment&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;            call method document-&amp;gt;add_attachment&lt;/P&gt;&lt;P&gt;              exporting&lt;/P&gt;&lt;P&gt;                i_attachment_type    = documents_line-type&lt;/P&gt;&lt;P&gt;                i_attachment_subject = documents_line-subject&lt;/P&gt;&lt;P&gt;                i_att_content_text   = documents_line-content_text&lt;/P&gt;&lt;P&gt;                i_attachment_header  = documents_line-attachment_header.&lt;/P&gt;&lt;P&gt;          else.&lt;/P&gt;&lt;P&gt;            call method document-&amp;gt;add_attachment&lt;/P&gt;&lt;P&gt;              exporting&lt;/P&gt;&lt;P&gt;                i_attachment_type    = documents_line-type&lt;/P&gt;&lt;P&gt;                i_attachment_subject = documents_line-subject&lt;/P&gt;&lt;P&gt;                i_att_content_hex    = documents_line-content_hex&lt;/P&gt;&lt;P&gt;                i_attachment_header  = documents_line-attachment_header.&lt;/P&gt;&lt;P&gt;          endif.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;      endloop.&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; Now we can add our document (and its attachments) to our send request&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Add document to send request&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      call method send_request-&amp;gt;set_document( document ).&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; Next we will create a sender object (this function module&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; automatically uses the current user) and places it into our send&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; request.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get sender object&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      sender = cl_sapuser_bcs=&amp;gt;create( sy-uname ).&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Add sender&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      call method send_request-&amp;gt;set_sender&lt;/P&gt;&lt;P&gt;        exporting&lt;/P&gt;&lt;P&gt;          i_sender = sender.&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;Following the sender, we can add our recipients to the e-mail. If&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;requested by the calling program we will lookup the recipients e-mail&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;address from their SAP User Master using the BAPI,&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;BAPI_USER_GET_DETAIL.  If an e-mail address isn't maintained there,&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;we will try and create one by concatenating their user id together&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;with our default company domain name.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;      data: recipients_line like line of recipients.&lt;/P&gt;&lt;P&gt;      loop at recipients into recipients_line.&lt;/P&gt;&lt;P&gt;        if recipients_line-c_address is initial.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create recipient&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          clear iaddsmtp.&lt;/P&gt;&lt;P&gt;          refresh iaddsmtp.&lt;/P&gt;&lt;P&gt;          clear bapiadsmtp.&lt;/P&gt;&lt;P&gt;          clear recipient.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Read the E-Mail address for the user&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          call function 'BAPI_USER_GET_DETAIL'&lt;/P&gt;&lt;P&gt;            exporting&lt;/P&gt;&lt;P&gt;              username = recipients_line-uname&lt;/P&gt;&lt;P&gt;            tables&lt;/P&gt;&lt;P&gt;              return   = ireturn&lt;/P&gt;&lt;P&gt;              addsmtp  = iaddsmtp.&lt;/P&gt;&lt;P&gt;          loop at iaddsmtp where std_no = 'X'.&lt;/P&gt;&lt;P&gt;            clear bapiadsmtp.&lt;/P&gt;&lt;P&gt;            move iaddsmtp to bapiadsmtp.&lt;/P&gt;&lt;P&gt;          endloop.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;If no E-mail address was found, create one.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;          if bapiadsmtp-e_mail = ''.&lt;/P&gt;&lt;P&gt;            concatenate recipients_line-uname local_domain&lt;/P&gt;&lt;P&gt;                      into recipients_line-c_address.&lt;/P&gt;&lt;P&gt;          else.&lt;/P&gt;&lt;P&gt;            move bapiadsmtp-e_mail to recipients_line-c_address.&lt;/P&gt;&lt;P&gt;          endif.&lt;/P&gt;&lt;P&gt;        endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        recipient = cl_cam_address_bcs=&amp;gt;create_internet_address(&lt;/P&gt;&lt;P&gt;                                           recipients_line-c_address ).&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Add recipient with its respective attributes to send request&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        call method send_request-&amp;gt;add_recipient&lt;/P&gt;&lt;P&gt;          exporting&lt;/P&gt;&lt;P&gt;            i_recipient  = recipient&lt;/P&gt;&lt;P&gt;            i_express    = recipients_line-i_express&lt;/P&gt;&lt;P&gt;            i_copy       = recipients_line-i_copy&lt;/P&gt;&lt;P&gt;            i_blind_copy = recipients_line-i_blind_copy&lt;/P&gt;&lt;P&gt;            i_no_forward = recipients_line-i_no_forward.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      endloop.&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; Set the return status attributes of the message.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Set that you don't need a Return Status E-mail&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      data: status_mail type bcs_stml.&lt;/P&gt;&lt;P&gt;      status_mail = requested_status.&lt;/P&gt;&lt;P&gt;      call method send_request-&amp;gt;set_status_attributes&lt;/P&gt;&lt;P&gt;        exporting&lt;/P&gt;&lt;P&gt;          i_requested_status = requested_status&lt;/P&gt;&lt;P&gt;          i_status_mail      = status_mail.&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; Here is opportunity to send e-mail immediately. The E-mails still&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; get logged in the system and can be monitored from SCOT (or SOST).&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; The following code will trigger the send immediately.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;set send immediately flag&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      send_request-&amp;gt;set_send_immediately( 'X' ).&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; Finally we tell the system to send our email. We follow this up with&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; a commit work statement. Because the BCS is written as a Persistent&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; Object Class, no activity will take place until we trigger the commit&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; work.  We close by catching the BCS errors into the BCS exception&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; class.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Send document&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      call method send_request-&amp;gt;send( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      commit work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    catch cx_bcs into bcs_exception.&lt;/P&gt;&lt;P&gt;      raise exception bcs_exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;  endtry.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2008 21:11:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/send-email-using-class-cl-bcs-without-a-quot-commit-work-quot/m-p/3406745#M818125</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-22T21:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: Send email using class cl_bcs without a "commit work"</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/send-email-using-class-cl-bcs-without-a-quot-commit-work-quot/m-p/3406746#M818126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;a commit work cannot be executed without causing an abend.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;commit work is required here. &lt;/P&gt;&lt;P&gt;have you analyzed whats causing the abend? i have been using a similar code without problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Feb 2008 07:21:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/send-email-using-class-cl-bcs-without-a-quot-commit-work-quot/m-p/3406746#M818126</guid>
      <dc:creator>athavanraja</dc:creator>
      <dc:date>2008-02-23T07:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Send email using class cl_bcs without a "commit work"</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/send-email-using-class-cl-bcs-without-a-quot-commit-work-quot/m-p/3406747#M818127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Durairaj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have exchanged several emails with the author of the FM I copied from this forum, Thomas Jung.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;He said:&lt;/P&gt;&lt;P&gt;If you can't issue a commit work that should be OK. Regardless of what you are within, you will eventually get an  implicit  commit  work at the end of the LUW and the should be enough  to trigger the  mail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I sent him the program calling the email FM and the FM source code.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;He said:&lt;/P&gt;&lt;P&gt;Well I was unable to recreate your situation in my 7.10 system. This could mean that there is a bug in your system that is not responding well to the implicit commit work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=============================================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what is currently happening in our 620 system, patch level 061.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I remove the commit work from the FM, the request gets created but the request staus in Tcode scot is 'No entry in queue yet'.  The request then has to be manually resent, changing the status to &amp;#145;waiting&amp;#146;.  The request can then be transmitted either manually from scot or programmatically using &amp;#145;RSCONN01&amp;#146;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the commit work is in the FM, the request is automatically transmitted and the email is sent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a link to the blog that Thomas created showing how he created a FM.  I am using the FM described in this blog.&lt;/P&gt;&lt;P&gt;/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Feb 2008 18:54:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/send-email-using-class-cl-bcs-without-a-quot-commit-work-quot/m-p/3406747#M818127</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-25T18:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: Send email using class cl_bcs without a "commit work"</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/send-email-using-class-cl-bcs-without-a-quot-commit-work-quot/m-p/3406748#M818128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An explicit commit work was required in our 620 system.  As Thomas Jung surmised, an implicit work was not enough.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2008 00:15:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/send-email-using-class-cl-bcs-without-a-quot-commit-work-quot/m-p/3406748#M818128</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-28T00:15:17Z</dc:date>
    </item>
  </channel>
</rss>

