Application Development and Automation 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: 
Read only

Mail Problem

kanthimathikris
Advisor
Advisor
0 Likes
736

Hi,

I am working with the function module

SO_NEW_DOCUMENT_SEND_API1 and facing the following pblm.

With this function module the mail is send to receivers of

type 'B' (SAP Users) and not of type 'U'. What might be the problem.

Note : When I checked the SCOT transaction I could find some work processes in Wait state for a long period of time.

Please help me to resolve this issue.

-Mathi

9 REPLIES 9
Read only

Former Member
0 Likes
708

Hi Kanthimathi,

Chk out this sample code and let me know if its working:


*&---------------------------------------------------------------------*
*& Report  ZSENDEMAIL                                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*& Example of sending external email via SAPCONNECT                    *
*&                                                                     *
*&---------------------------------------------------------------------*
REPORT  zsendemail                    .

PARAMETERS: psubject(40) type c default  'Testing',
            p_email(40)   type c default 'anjali.devi@wipro.com'.

data:   it_packing_list like sopcklsti1 occurs 0 with header line,
        it_contents like solisti1 occurs 0 with header line,
        it_receivers like somlreci1 occurs 0 with header line,
        it_attachment like solisti1 occurs 0 with header line,
        gd_cnt type i,
        gd_sent_all(1) type c,
        gd_doc_data like sodocchgi1,
        gd_error type sy-subrc.

data:   it_message type standard table of SOLISTI1 initial size 0
                with header line.

***********************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.

Perform populate_message_table.

*Send email message, although is not sent from SAP until mail send
*program has been executed(rsconn01)
PERFORM send_email_message.

*Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.


*&---------------------------------------------------------------------*
*&      Form  POPULATE_MESSAGE_TABLE
*&---------------------------------------------------------------------*
*       Adds text to email text table
*----------------------------------------------------------------------*
form populate_message_table.
  Append 'Line1' to it_message.
  Append 'Line2' to it_message.
  Append 'Line3' to it_message.
  Append 'Test- 1' to it_message.
endform.                    " POPULATE_MESSAGE_TABLE


*&---------------------------------------------------------------------*
*&      Form  SEND_EMAIL_MESSAGE
*&---------------------------------------------------------------------*
*       Send email message
*----------------------------------------------------------------------*
form send_email_message.
* Fill the document data.
  gd_doc_data-doc_size = 1.

* Populate the subject/generic message attributes
  gd_doc_data-obj_langu = sy-langu.
  gd_doc_data-obj_name  = 'SAPRPT'.
  gd_doc_data-obj_descr = psubject.
  gd_doc_data-sensitivty = 'F'.

* Describe the body of the message
* Information about structure of data tables
  clear it_packing_list.
  refresh it_packing_list.
  it_packing_list-transf_bin = space.
  it_packing_list-head_start = 1.
  it_packing_list-head_num = 0.
  it_packing_list-body_start = 1.
  describe table it_message lines it_packing_list-body_num.
  it_packing_list-doc_type = 'RAW'.
  append it_packing_list.

* Add the recipients email address
  clear it_receivers.
  refresh it_receivers.
  it_receivers-receiver = p_email.
  it_receivers-rec_type = 'U'.
  append it_receivers.

* Call the FM to post the message to SAPMAIL
  call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       exporting
            document_data              = gd_doc_data
            put_in_outbox              = 'X'
       importing
            sent_to_all                = gd_sent_all
       tables
            packing_list               = it_packing_list
            contents_txt               = it_message
            receivers                  = it_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.

* Store function module return code
  gd_error = sy-subrc.

* Get it_receivers return code
  loop at it_receivers.
  endloop.
endform.                    " SEND_EMAIL_MESSAGE


*&---------------------------------------------------------------------
*&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
*&---------------------------------------------------------------------
*       Instructs mail send program for SAPCONNECT to send email.
*----------------------------------------------------------------------

form initiate_mail_execute_program.
  wait up to 2 seconds.
  if gd_error eq 0.
      submit rsconn01 with mode = 'INT'
                    with output = 'X'
                    and return.
  endif.
endform.                    " INITIATE_MAIL_EXECUTE_PROGRAM
*

http://www.sap-img.com/fu016.htm

The above codes will work fine if your mail sending configurations are set properly. Please contact the basis team for help on this.

Also, please let us know the error thats being displayed currently.

Best Regards,
Anjali

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
708

Hi,

What is the problem you are facing?

Did u checked the sy-subrc after the FM?

Is it showing zero?

Read only

0 Likes
708

Are you trying to send external mail?.

Karun M

Read only

Former Member
0 Likes
708

hi krishnan,

the problem might me 1 of these as under:-

1. In the exporting parameters of..FM use

commit_work = 'X'.

2. Check for Sy-subrc of FM..

if sy-subrc = 0.

SUBMIT rsconn01

WITH mode EQ 'INT'

AND RETURN.

      • this report program is used to automatically send the e-mails that are pending in the job queue.

ELSE

3. U may have some SMTP Config. problem.

If so u can ask me for details.

Else send ur code what u r using.

Regards

-


Sachin Dhingra

Read only

kanthimathikris
Advisor
Advisor
0 Likes
708

Hi Sachin,

Thanks for the input.

I have added the code what you have given.

Still facing the same problem.

Here goes my code

RECLIST-RECEIVER = 'ssushak@yahoo.com'.

RECLIST-REC_TYPE = 'U'.

RECLIST-EXPRESS = 'X'.

APPEND RECLIST.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_TYPE = 'RAW'

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

OBJECT_CONTENT = OBJCONT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

if sy-subrc = 0.

SUBMIT rsconn01

WITH mode EQ 'INT'

AND RETURN.

endif.

Read only

kanthimathikris
Advisor
Advisor
0 Likes
708

Hi Sachin,

Thanks for the input.

I have added the code what you have given.

Still facing the same problem.

Here goes my code

RECLIST-RECEIVER = 'ssushak@yahoo.com'.

RECLIST-REC_TYPE = 'U'.

RECLIST-EXPRESS = 'X'.

APPEND RECLIST.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_TYPE = 'RAW'

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

TABLES

OBJECT_CONTENT = OBJCONT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

if sy-subrc = 0.

SUBMIT rsconn01

WITH mode EQ 'INT'

AND RETURN.

endif.

Read only

kanthimathikris
Advisor
Advisor
0 Likes
708

I wanted to add few things..

When I opened my mail server today, I got all the mails sent yesterday..it nearly took more than 7 hrs for sending the mails.

Note :

I explicitly forced the mail sending thro' the transaction

SOST.

How can I make the process faster?

Read only

0 Likes
708

Hi,

wait up to 2 seconds.

if sy-subrc eq 0.

submit rsconn01 with mode = 'INT'

with output = 'X'

and return.

endif.

Check whether it is placed in outbox after this.

Message was edited by: Jayanthi Jayaraman

Read only

kanthimathikris
Advisor
Advisor
0 Likes
708

Hi,

There might be some SMTP problem yesterday, now the problem is solved.

Regards,

Mathi