Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

sending email issue

Former Member
0 Kudos

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

7 REPLIES 7

krishna_k19
Contributor
0 Kudos

Hi Narendra ,

    If you are running the same in foreground mails are going or not.

I think its not going foreground also , kindly check with basis team are you having authorization to send a mails.

Ans system itself giving the subrc value 2 ,means document not sent.

Regards,

Krishna

0 Kudos

they didnt even show up in the t-code SOST for processing the email. I tried before they were successfully sent. But now they are not showing in SOST

Former Member
0 Kudos

Any More Helpful answers please help me

0 Kudos

Did you check whether, there are issues in setting up the SMP Service.

Esp, pl. check the email address is configured against the user.

1) Cross check the steps in : http://scn.sap.com/docs/DOC-46513

2) Try running RSCONN01, and check whether the mail is not in waiting state

Cheers,

Remi

0 Kudos

thanks, I'l check it out.

0 Kudos

Guess by now, you must have been able to resolve the issue.

Pl. close this thread, (also post how you have resolved this issue)

Regards,

Remi

former_member197132
Participant
0 Kudos

This message was moderated.