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

Not able to send mail using SO_OBJECT_SEND.

Former Member
0 Likes
1,996

Hi,

I'm trying to send a Mail using FM SO_OBJECT_SEND, the coding for which is attached below, here the problem is even if SY-SUBRC is 0 mail is not sent, I've checked the same in SCOT and SOST, but there are no mails in the outbox.

I've tried it using COMMIT WORK as well.

IF lv_email IS NOT INITIAL.
*RECEIVERS table
    CLEAR wa_reclist.
    REFRESH lt_reclist.
    wa_reclist-recextnam = lv_email.   " Email Address
    wa_reclist-recesc     = 'A'.       " Receiver type
    wa_reclist-sndart     = 'MAIL'.
    wa_reclist-sndpri     = '1'.
    wa_reclist-mailstatus = 'X'.
    wa_reclist-rcdat      = sy-datum.
    wa_reclist-rctim      = sy-uzeit.
    wa_reclist-deliver    = 'X'.
    wa_reclist-not_deli   = 'X'.
    wa_reclist-sndex      = 'X'.       " EXPRESS DOCUMENT
    APPEND wa_reclist TO lt_reclist.
  ENDIF.

**BUILD MESSAGE HEADER
* General data
  wa_objhd-objla = sy-langu.
  wa_objhd-objnam = 'Sales Order Created.'.

* Message Body
  CLEAR wa_objcont.
  CONCATENATE 'Sales Order:- ' vbeln 'created.' INTO wa_objcont-line.
  APPEND wa_objcont TO lt_objcont.

  CALL FUNCTION 'SO_OBJECT_SEND'
    EXPORTING
      object_hd_change           = wa_objhd
      object_type                = 'RAW'
      outbox_flag                = 'X'
    TABLES
      objcont                    = lt_objcont
      receivers                  = lt_reclist
    EXCEPTIONS
      active_user_not_exist      = 1
      communication_failure      = 2
      component_not_available    = 3
      folder_not_exist           = 4
      folder_no_authorization    = 5
      forwarder_not_exist        = 6
      note_not_exist             = 7
      object_not_exist           = 8
      object_not_sent            = 9
      object_no_authorization    = 10
      object_type_not_exist      = 11
      operation_no_authorization = 12
      owner_not_exist            = 13
      parameter_error            = 14
      substitute_not_active      = 15
      substitute_not_defined     = 16
      system_failure             = 17
      too_much_receivers         = 18
      user_not_exist             = 19
      x_error                    = 20
      OTHERS                     = 21.

  COMMIT WORK.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,485

HI

Try with the below FM's

1. CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = wa_docdata

document_type = 'HTM'

put_in_outbox = 'X'

commit_work = 'X'

TABLES

object_content = i_content

receivers = i_receiver.

  • IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  • ENDIF.

2.

  • Creates persistent send request

l_send_request = cl_bcs=>create_persistent( ).

  • Craete document for mail body

l_document = cl_document_bcs=>create_document(

i_type = 'HTM'

i_text = i_content"l_body " Mail body

i_subject = l_subject ).

CALL METHOD l_send_request->set_document( l_document ).

  • Sender addess

l_sender = cl_sapuser_bcs=>create( 'ABC' ).

CALL METHOD l_send_request->set_sender

EXPORTING

i_sender = l_sender.

  • Recipient address

IF wa_result-email IS NOT INITIAL.

l_email = wa_result-email.

l_recipient = cl_cam_address_bcs=>create_internet_address( l_email ).

  • Add recipient address to send request

CALL METHOD l_send_request->add_recipient

EXPORTING

i_recipient = l_recipient

i_express = 'X'

i_copy = ' '

i_blind_copy = ' '

i_no_forward = ' '.

status_mail = requested_status.

CALL METHOD l_send_request->set_status_attributes

EXPORTING

i_requested_status = requested_status

i_status_mail = status_mail.

  • Trigger E-Mail immediately

l_send_request->set_send_immediately( 'X' ).

  • Send mail

CALL METHOD l_send_request->send( ).

COMMIT WORK.

ENDIF.

Hi,

I'm trying to send a Mail using FM SO_OBJECT_SEND, the coding for which is attached below, here the problem is even if SY-SUBRC is 0 mail is not sent, I've checked the same in SCOT and SOST, but there are no mails in the outbox.

I've tried it using COMMIT WORK as well.

IF lv_email IS NOT INITIAL.
*RECEIVERS table
    CLEAR wa_reclist.
    REFRESH lt_reclist.
    wa_reclist-recextnam = lv_email.   " Email Address
    wa_reclist-recesc     = 'A'.       " Receiver type
    wa_reclist-sndart     = 'MAIL'.
    wa_reclist-sndpri     = '1'.
    wa_reclist-mailstatus = 'X'.
    wa_reclist-rcdat      = sy-datum.
    wa_reclist-rctim      = sy-uzeit.
    wa_reclist-deliver    = 'X'.
    wa_reclist-not_deli   = 'X'.
    wa_reclist-sndex      = 'X'.       " EXPRESS DOCUMENT
    APPEND wa_reclist TO lt_reclist.
  ENDIF.

**BUILD MESSAGE HEADER
* General data
  wa_objhd-objla = sy-langu.
  wa_objhd-objnam = 'Sales Order Created.'.

* Message Body
  CLEAR wa_objcont.
  CONCATENATE 'Sales Order:- ' vbeln 'created.' INTO wa_objcont-line.
  APPEND wa_objcont TO lt_objcont.

  CALL FUNCTION 'SO_OBJECT_SEND'
    EXPORTING
      object_hd_change           = wa_objhd
      object_type                = 'RAW'
      outbox_flag                = 'X'
    TABLES
      objcont                    = lt_objcont
      receivers                  = lt_reclist
    EXCEPTIONS
      active_user_not_exist      = 1
      communication_failure      = 2
      component_not_available    = 3
      folder_not_exist           = 4
      folder_no_authorization    = 5
      forwarder_not_exist        = 6
      note_not_exist             = 7
      object_not_exist           = 8
      object_not_sent            = 9
      object_no_authorization    = 10
      object_type_not_exist      = 11
      operation_no_authorization = 12
      owner_not_exist            = 13
      parameter_error            = 14
      substitute_not_active      = 15
      substitute_not_defined     = 16
      system_failure             = 17
      too_much_receivers         = 18
      user_not_exist             = 19
      x_error                    = 20
      OTHERS                     = 21.

  COMMIT WORK.

7 REPLIES 7
Read only

Former Member
0 Likes
1,485

<<Do NOT copy-paste code from elsewhere>>

<<Do NOT Demand points>>

Edited by: kishan P on Jan 4, 2011 4:52 PM

Read only

Former Member
0 Likes
1,486

HI

Try with the below FM's

1. CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = wa_docdata

document_type = 'HTM'

put_in_outbox = 'X'

commit_work = 'X'

TABLES

object_content = i_content

receivers = i_receiver.

  • IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  • ENDIF.

2.

  • Creates persistent send request

l_send_request = cl_bcs=>create_persistent( ).

  • Craete document for mail body

l_document = cl_document_bcs=>create_document(

i_type = 'HTM'

i_text = i_content"l_body " Mail body

i_subject = l_subject ).

CALL METHOD l_send_request->set_document( l_document ).

  • Sender addess

l_sender = cl_sapuser_bcs=>create( 'ABC' ).

CALL METHOD l_send_request->set_sender

EXPORTING

i_sender = l_sender.

  • Recipient address

IF wa_result-email IS NOT INITIAL.

l_email = wa_result-email.

l_recipient = cl_cam_address_bcs=>create_internet_address( l_email ).

  • Add recipient address to send request

CALL METHOD l_send_request->add_recipient

EXPORTING

i_recipient = l_recipient

i_express = 'X'

i_copy = ' '

i_blind_copy = ' '

i_no_forward = ' '.

status_mail = requested_status.

CALL METHOD l_send_request->set_status_attributes

EXPORTING

i_requested_status = requested_status

i_status_mail = status_mail.

  • Trigger E-Mail immediately

l_send_request->set_send_immediately( 'X' ).

  • Send mail

CALL METHOD l_send_request->send( ).

COMMIT WORK.

ENDIF.

Read only

0 Likes
1,485

Hello Kishore,

I know using the FM SO_NEW_DOCUMENT_SEND_API1 mightl work, but for that i need to do lot of changes plus i dont want to send an attachment, I just want to send a plain mail with one line in the Body.

I would appreciate if you can help me with SO_OBJECT_SEND FM.

Thanks for your Reply.

Read only

0 Likes
1,485

There are many posts for this function module.

Also have you checked on your own SAP system to see if this FM is used by another other programs.

Read only

0 Likes
1,485

hI

I've tried this code and it seems to work fine (I can see my message in SOST):

DATA: LT_OBJCONT TYPE TABLE OF SOLI.
DATA: WA_OBJCONT TYPE SOLI.
DATA: LT_RECLIST TYPE TABLE OF SOOS1.
DATA: WA_RECLIST TYPE SOOS1.
DATA: WA_OBJHD   TYPE SOOD1.
DATA: LT_OBJHEAD TYPE TABLE OF SOLI WITH HEADER LINE.

*RECEIVERS table
CLEAR WA_RECLIST.
REFRESH LT_RECLIST.
WA_RECLIST-RECEXTNAM = <mail address>'.   " Email Address
WA_RECLIST-RECESC     = 'U'.       " Receiver type
*WA_RECLIST-SNDART     = 'MAIL'.
*WA_RECLIST-SNDPRI     = '1'.
*WA_RECLIST-MAILSTATUS = 'X'.
WA_RECLIST-RCDAT      = SY-DATUM.
WA_RECLIST-RCTIM      = SY-UZEIT.
WA_RECLIST-DELIVER    = 'X'.
WA_RECLIST-NOT_DELI   = 'X'.
WA_RECLIST-SNDEX      = 'X'.       " EXPRESS DOCUMENT
APPEND WA_RECLIST TO LT_RECLIST.

**BUILD MESSAGE HEADER
* General data
WA_OBJHD-OBJLA = SY-LANGU.
WA_OBJHD-OBJDES = 'Sales Order Created.'.

* Message Body
CLEAR WA_OBJCONT.
CONCATENATE 'Sales Order:- ' '100' 'created.' INTO WA_OBJCONT-LINE.
APPEND WA_OBJCONT TO LT_OBJCONT.



CALL FUNCTION 'SO_OBJECT_SEND'
  EXPORTING
    OBJECT_HD_CHANGE           = WA_OBJHD
    OBJECT_TYPE                = 'RAW'
    OUTBOX_FLAG                = 'X'
  TABLES
    OBJCONT                    = LT_OBJCONT
    RECEIVERS                  = LT_RECLIST
  EXCEPTIONS
    ACTIVE_USER_NOT_EXIST      = 1
    COMMUNICATION_FAILURE      = 2
    COMPONENT_NOT_AVAILABLE    = 3
    FOLDER_NOT_EXIST           = 4
    FOLDER_NO_AUTHORIZATION    = 5
    FORWARDER_NOT_EXIST        = 6
    NOTE_NOT_EXIST             = 7
    OBJECT_NOT_EXIST           = 8
    OBJECT_NOT_SENT            = 9
    OBJECT_NO_AUTHORIZATION    = 10
    OBJECT_TYPE_NOT_EXIST      = 11
    OPERATION_NO_AUTHORIZATION = 12
    OWNER_NOT_EXIST            = 13
    PARAMETER_ERROR            = 14
    SUBSTITUTE_NOT_ACTIVE      = 15
    SUBSTITUTE_NOT_DEFINED     = 16
    SYSTEM_FAILURE             = 17
    TOO_MUCH_RECEIVERS         = 18
    USER_NOT_EXIST             = 19
    X_ERROR                    = 20
    OTHERS                     = 21.

WRITE: SY-SUBRC.

COMMIT WORK.

I've changed, the receiver type:

WA_RECLIST-RECESC = 'U'. " Receiver type

It's U instead of A

The descripition (for the mail subject):

WA_OBJHD-OBJDES = 'Sales Order Created.'.

I can't send the mail because in my dev sustem is not active

Max

Read only

0 Likes
1,485

Hi Max,

I've tried it with all the rec type combinations, but the same problem persists in my system i.e i cannot test it on Dev and moved it to Qua by keeping the rec type as 'A' and without COMMIT WORK.

After which I've done two changes:-

1. Added COMMIT WORK.

2. Changed the rec type to 'U'.

but still not worked, coz i tested the same in Dev, your reply encouraged me and i moved it to Qua and tested, and now it works fine.

Also i added 1 more statement:-

SUBMIT rsconn01 WITH mode = 'INT'
       AND RETURN.

which sends the mail immediately, i.e. no need to wait for the background job to send the mail.

Thanks a lot

Best Regards,

Sunil.

Read only

0 Likes
1,485

Actually running the below code will send all emails that are waiting to be processed.

SUBMIT rsconn01 WITH mode = 'INT'

AND RETURN.