Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

sending email issue

hello gurus,

I've written the following code to send an email if the background job failed.after executing the program the sy-subrc status of the F.M SO_NEW_DOCUMENT_SEND_API1 is '2'. i.e, document not sent.

I checked in sost t-code to view the email status but they didn't show up please help me out.



select single status from tbtco into lv_jstatus where jobname = p_lv_jname and jobcount = p_lv_jcount.

*if lv_jstatus eq 'Y'.

*  lv_jstatus = 'A'.

*  endif.

if lv_jstatus eq 'A'.

ls_mailrecipients-rec_type  ='U'.

ls_mailrecipients-receiver = 'xxxx@gmail.com'.

ls_mailrecipients-express = 'X'.

APPEND  ls_mailrecipients to lt_mailrecipients .

*CLEAR lt_mailrecipients .

* subject.

ls_mailsubject-obj_name = 'Status'.

ls_mailsubject-obj_langu = sy-langu.

ls_mailsubject-obj_descr = ' Background Job is Cancelled.'.

ls_mailsubject-sensitivty = 'P'.

* mail contents

ls_mailtxt-line = 'Hello,'.

APPEND ls_mailtxt to lt_mailtxt.

ls_mailtxt-line = 'The Background Job is cancelled,Pleae Have a Look'.

APPEND ls_mailtxt to lt_mailtxt.

ls_mailtxt-line = 'Thank You'.

append ls_mailtxt to lt_mailtxt.

*CLEAR lt_mailtxt.

* send mail

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

destination 'NONE'

    EXPORTING

      document_data              = ls_mailsubject

      document_type              = 'RAW'

      put_in_outbox              = 'X'

      commit_work                = 'X'

    TABLES

      object_content             = lt_mailtxt[]

      receivers                  = lt_mailrecipients[]

    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.

In the debugging mode I got status of the job 'A' . everything working fine but they are not showing up in SOST. please help me out

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question