<?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 Error Email in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-email/m-p/4693337#M1103111</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the report need to be executed in SM36 .&lt;/P&gt;&lt;P&gt;if the data doesnot exist for the selction criteria given or if the job failed in SM36 an email need to be triggered  to particular mail id given in the selection screen. i have written code for if the data does not exists an email to be sent&lt;/P&gt;&lt;P&gt;but how to write code if the job cancelled then an email to be sent. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the status of the job exists in TBTCO table , &lt;/P&gt;&lt;P&gt;code: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  PERFORM get_data.&lt;/P&gt;&lt;P&gt;   PERFORM check_job_done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF gt_final[] IS INITIAL.&lt;/P&gt;&lt;P&gt;    PERFORM send_mail.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------" /&gt;&lt;P&gt;PERFORM check_job_done.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------" /&gt;&lt;P&gt;    SELECT jobname jobcount status enddate endtime&lt;/P&gt;&lt;P&gt;      FROM tbtco&lt;/P&gt;&lt;P&gt;      INTO CORRESPONDING FIELDS OF TABLE gt_tbtco&lt;/P&gt;&lt;P&gt;     WHERE jobname = 'ZEMAIL'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;           READ TABLE gt_tbtco INDEX 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      IF gt_tbtco-status = c_r_status&lt;/P&gt;&lt;P&gt;      OR gt_tbtco-status = c_p_status&lt;/P&gt;&lt;P&gt;      OR gt_tbtco-status = c_y_status&lt;/P&gt;&lt;P&gt;      OR gt_tbtco-status = c_s_status&lt;/P&gt;&lt;P&gt;      OR gt_tbtco-status = c_x_status&lt;/P&gt;&lt;P&gt;      OR gt_tbtco-status = c_z_status.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Error when there is something wrong with the job&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      PERFORM send_mail.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;      IF gt_tbtco-status = c_f_status.&lt;/P&gt;&lt;P&gt;      exit.&lt;/P&gt;&lt;P&gt;     ENDIF.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------------------------------------------------------" /&gt;&lt;P&gt; PERFORM send_mail.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------------------------------------------------------" /&gt;&lt;P&gt;l_email_recvr = p_recvr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Send email to the receiving person/group&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL FUNCTION 'EFG_GEN_SEND_EMAIL'&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      i_title     = l_email_hdr&lt;/P&gt;&lt;P&gt;      i_sender    = l_email_sndr&lt;/P&gt;&lt;P&gt;      i_recipient = l_email_recvr&lt;/P&gt;&lt;P&gt;    TABLES&lt;/P&gt;&lt;P&gt;      i_tab_lines = gt_msg.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Nov 2008 08:18:58 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-11-07T08:18:58Z</dc:date>
    <item>
      <title>Error Email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-email/m-p/4693337#M1103111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the report need to be executed in SM36 .&lt;/P&gt;&lt;P&gt;if the data doesnot exist for the selction criteria given or if the job failed in SM36 an email need to be triggered  to particular mail id given in the selection screen. i have written code for if the data does not exists an email to be sent&lt;/P&gt;&lt;P&gt;but how to write code if the job cancelled then an email to be sent. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the status of the job exists in TBTCO table , &lt;/P&gt;&lt;P&gt;code: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  PERFORM get_data.&lt;/P&gt;&lt;P&gt;   PERFORM check_job_done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF gt_final[] IS INITIAL.&lt;/P&gt;&lt;P&gt;    PERFORM send_mail.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------------------------------------" /&gt;&lt;P&gt;PERFORM check_job_done.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-------------------------------------------------------" /&gt;&lt;P&gt;    SELECT jobname jobcount status enddate endtime&lt;/P&gt;&lt;P&gt;      FROM tbtco&lt;/P&gt;&lt;P&gt;      INTO CORRESPONDING FIELDS OF TABLE gt_tbtco&lt;/P&gt;&lt;P&gt;     WHERE jobname = 'ZEMAIL'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;           READ TABLE gt_tbtco INDEX 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      IF gt_tbtco-status = c_r_status&lt;/P&gt;&lt;P&gt;      OR gt_tbtco-status = c_p_status&lt;/P&gt;&lt;P&gt;      OR gt_tbtco-status = c_y_status&lt;/P&gt;&lt;P&gt;      OR gt_tbtco-status = c_s_status&lt;/P&gt;&lt;P&gt;      OR gt_tbtco-status = c_x_status&lt;/P&gt;&lt;P&gt;      OR gt_tbtco-status = c_z_status.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Error when there is something wrong with the job&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      PERFORM send_mail.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;      IF gt_tbtco-status = c_f_status.&lt;/P&gt;&lt;P&gt;      exit.&lt;/P&gt;&lt;P&gt;     ENDIF.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------------------------------------------------------" /&gt;&lt;P&gt; PERFORM send_mail.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="------------------------------------------------------" /&gt;&lt;P&gt;l_email_recvr = p_recvr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Send email to the receiving person/group&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL FUNCTION 'EFG_GEN_SEND_EMAIL'&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      i_title     = l_email_hdr&lt;/P&gt;&lt;P&gt;      i_sender    = l_email_sndr&lt;/P&gt;&lt;P&gt;      i_recipient = l_email_recvr&lt;/P&gt;&lt;P&gt;    TABLES&lt;/P&gt;&lt;P&gt;      i_tab_lines = gt_msg.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2008 08:18:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-email/m-p/4693337#M1103111</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-07T08:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Error Email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-email/m-p/4693338#M1103112</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;Try to use the class CL_SOTR_SEND_MAIL and method SEND_MAIL for sending mail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jayant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2008 08:20:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-email/m-p/4693338#M1103112</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-07T08:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Error Email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-email/m-p/4693339#M1103113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example for you...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;report  zemail.

tables: adr6.

data: send_request  type ref to cl_bcs,
      document      type ref to cl_document_bcs,
      recipient     type ref to if_recipient_bcs,
      bcs_exception type ref to cx_bcs.

data: sent_to_all type os_boolean,
      adresse     type adr6-smtp_addr,
      subject     type so_obj_des,
      text        type bcsy_text,
      line        type soli-line.

data: reciever type table of adr6-smtp_addr.

* Email address
select-options: s_smtp for adr6-smtp_addr no intervals
                 default 'your.email.

start-of-selection.

*--Build the email body
  line = 'Email body'.
  append line to text.

*--Build the send request
  try.

*--create the send request
      send_request = cl_bcs=&amp;gt;create_persistent( ).
      document = cl_document_bcs=&amp;gt;create_document( i_type    = 'RAW'
                                                   i_text    = text
                                                   i_subject = subject ).

*--add document to send request
      send_request-&amp;gt;set_document( document ).

*--create recipient and add to send request
      loop at s_smtp.
        check ( s_smtp-low is not initial ).
        adresse   = s_smtp-low.
        recipient = cl_cam_address_bcs=&amp;gt;create_internet_address( adresse ).
        send_request-&amp;gt;add_recipient( i_recipient = recipient ).
      endloop.

*--send mail now
      sent_to_all = send_request-&amp;gt;send( i_with_error_screen = 'X' ).
      if sent_to_all = 'X'.
        message s022(so).
      endif.

    catch cx_bcs into bcs_exception.
      message e865(so) with bcs_exception-&amp;gt;error_type.
  endtry.

  commit work.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Darren&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2008 08:25:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-email/m-p/4693339#M1103113</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-07T08:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Error Email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-email/m-p/4693340#M1103114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hemal,&lt;/P&gt;&lt;P&gt;Please refer the below links:&lt;/P&gt;&lt;P&gt;&lt;A href="http://searchsap.techtarget.com/tip/1,289483,sid21_gci868240,00.html" target="test_blank"&gt;http://searchsap.techtarget.com/tip/1,289483,sid21_gci868240,00.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/2c/abb2e7ff6311d194c000a0c93033f7/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/2c/abb2e7ff6311d194c000a0c93033f7/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope these help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dawood.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2008 08:26:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-email/m-p/4693340#M1103114</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-07T08:26:15Z</dc:date>
    </item>
  </channel>
</rss>

