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

SO_NEW_DOCUMENT_ATT_SEND_API1 multiple receivers

Former Member
0 Likes
2,226

I have searched the forum and found several examples and threads about function module SO_NEW_DOCUMENT_ATT_SEND_API1.

I have used it before but am now having a specific problem and cannot find a solution.

The RECEIVERS table is being populated with multiple addresses. The intent is to send one single email to all the recipients listed. Instead, the email is being sent once per recipient.

The code below shows two addresses. It should send one email with a TO: and CC: address. Instead it sends it twice (with TO: and CC: populated in each email). "test1" and "test2" are incomplete email addresses for this example.

I assumed it was a simple coding error on my part. Anyone see it? This is on an ECC 6.0 system.

  CLEAR it_mailtxt-line.
  it_mailtxt-line = 'testing email with multiple recipients.'.
  APPEND it_mailtxt.

  DESCRIBE TABLE it_mailtxt LINES mailtxt_size.

  it_doc_att-obj_descr =  'Test email'.
  it_doc_att-sensitivty = 'F'.
  it_doc_att-doc_size = mailtxt_size * 255.

  CLEAR it_mailpack-transf_bin.
  it_mailpack-head_start = 1.
  it_mailpack-head_num = 0.
  it_mailpack-body_start = 1.
  it_mailpack-body_num = mailtxt_size.
  it_mailpack-doc_type = 'RAW'.
  APPEND it_mailpack.

  REFRESH it_reclist.
  CLEAR it_reclist.

  it_reclist-receiver = 'test1'.
  it_reclist-express = 'X'.
  it_reclist-rec_type = 'U'.
  it_reclist-com_type   = 'INT'.
  APPEND it_reclist.

  CLEAR it_reclist.
  it_reclist-copy   = 'X'.
  it_reclist-receiver = 'test2'.
  it_reclist-express = 'X'.
  it_reclist-rec_type = 'U'.
  it_reclist-com_type   = 'INT'.
  APPEND it_reclist.

  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data                      = it_doc_att
      COMMIT_WORK                        = 'X'
    TABLES
      packing_list                       = it_mailpack
      object_header                   = it_mailhead
      contents_txt                      = it_mailtxt
      receivers                          = it_reclist
    EXCEPTIONS
      too_many_receivers                 = 1
      document_not_sent                  = 2
      document_type_not_exist            = 3
      operation_no_authorizationfiltered = 4
      parameter_error                    = 5
      x_error                            = 6
      enqueue_error                      = 7
      OTHERS                             = 8.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,045

Did you check maybe your code is being called in a loop.

6 REPLIES 6
Read only

Former Member
0 Likes
1,046

Did you check maybe your code is being called in a loop.

Read only

0 Likes
1,045

Yes, so I pulled out the section of code above (and the DATA declarations) and pasted it in a separate program. Same result.

Thought I might be missing a parameter in one of the structures.

Read only

Former Member
0 Likes
1,045

No answer for your issue with the function module, but suggest you have a look at the class based email solution CL_BCS - it is well documented and provides a lot of additional functionality.

Andrew

Read only

Former Member
0 Likes
1,045

Hi,

Can you please check any OSS NOTE on SAP service market place ?

There are 32 notes with this FM .. may be any one can give you any idea..

Read only

andrea_olivieri
Contributor
0 Likes
1,045

Hi,

you should create a distribution list via SBWP > Distribution List.

Then check the function module documentation in order to find how to fill the RECEIVERS[ ] table parameter with the created distribution list.

Regards,

Andrea

Read only

Former Member
0 Likes
1,045

Sorry folks. My error. Some of the target recipients were test accounts with mail forwarding. There was some looping going on that looked like duplicate emails. My apologies.