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: 

Unable to send Mail in CC using SO_NEW_DOCUMENT_SEND_API1

deepak_dhamat
Active Contributor
0 Kudos
1,196

cc-problem.png

Hi ,

I am sending email from sap using function module 'SO_NEW_DOCUMENT_SEND_API1' . when i am passing mail to receiver as To (Vendor) mail is send properly , but when i am setting as mailrec-Copy= 'X' it sets Blind_copy='X' and mail does not goes to CC but it goes to BCC .

i have attached problem "file

Before Asking question i went through all SDN blog . but did'nt got satisfactory answer /solution .

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}

  mailrec-receiver = t_vendor-lif_adr  ."so_mail-low.

  mailrec-rec_type  = 'U'.

  mailrec-com_type = 'INT'.

*  MAILREC-express  = 'X'.

*  mailrec-blind_copy = ''.

*  mailrec-COPY = '' .

  mailrec-notif_del = ''.

  mailrec-notif_ndel = ''.

  APPEND mailrec.

*    ENDLOOP .



  CLEAR mailrec  .



  LOOP AT it_vendor1 .

    mailrec-receiver = it_vendor1-grp_adr ."'deepdhamat@gmail.com'."so_mail-low.

    mailrec-rec_type  = 'U'.

    mailrec-com_type = 'INT'.

    MAILREC-express  = 'X'.

*    mailrec-blind_copy = ''.

*    mailrec-copy = 'X' .

    mailrec-notif_del = ''.

    mailrec-notif_ndel = ''.

    APPEND mailrec.

  ENDLOOP.


SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}

  CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

    EXPORTING

      document_data              = maildata

      document_type              = 'HTM' "HTM'

      put_in_outbox              = 'X'

      commit_work                = 'X'

    TABLES

*     object_header              = mailtxt

      object_content             = lt_mailtxt "lt_html

      receivers                  = mailrec

    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.

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

When i debugged in function module 'SO_NEW_DOCUMENT_SEND_API1' it goes to another function module internally i.e SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; }

call function 'SO_DOCUMENT_SEND_API1' and it performs below code in that function module line no 91

* transfer receiver data
perform transfer_rec_to_tab tables receivers
rec_table.

in above perform it sets Copy=' ' and Blind_copy='X'

Regards

Deepak dhamat

1 ACCEPTED SOLUTION

deepak_dhamat
Active Contributor
0 Kudos
904

Thank you Tomas & Matthew for your reply .

There was problem of Structure used for passing "mailrec" internal table was wrong .

correct structure to be used was somlreci1

DATA: mailrec LIKE somlreci1 OCCURS 0 WITH HEADER LINE.

regards

Deepak Dhamat

5 REPLIES 5

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
904

SO_NEW_DOCUMENT_SEND_API1 is function from 1998. It is quite obsolete and not user friendly.
These days it is recommended to use class CL_BCS which is available for a long time.
Here you can find some introduction: CL_BCS wiki page. And there are MANY examples of how to use it in system (demo programs) or over the internet.

-- Tomas --

matt
Active Contributor
0 Kudos
904

If you right click and choose "paste as plain text", you won't see the

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}

type rubbish in your code, and it will make your question easier to read.

deepak_dhamat
Active Contributor
0 Kudos
905

Thank you Tomas & Matthew for your reply .

There was problem of Structure used for passing "mailrec" internal table was wrong .

correct structure to be used was somlreci1

DATA: mailrec LIKE somlreci1 OCCURS 0 WITH HEADER LINE.

regards

Deepak Dhamat

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
904

Just FIY, this is also obsolete:

OCCURS 0 WITH HEADER LINE
-- Tomas --

matt
Active Contributor
0 Kudos
904

Don't use HEADER LINES with tables. It's BAD programming. While you're at it, check out SORTED and HASHED tables... though not necessarily appropriate here.