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: 

Fill "sender id" in SO_NEW_DOCUMENT_SEND_API1

Former Member
0 Kudos
4,907

Hello,

is there a possibility to fill a "sender" in the FM "SO_NEW_DOCUMENT_SEND_API1"?

For default the SAP System takes the SY-UNAME as sender.

Thanks in advance

9 REPLIES 9

ferry_lianto
Active Contributor
0 Kudos
1,313

Hi Michael,

Welcome to SDN.

You can not change/fill the sender. SAP has a logic to populate the sender with sy-uname in FM SO_OBJECT_SEND. This FM is called inside FM SO_NEW_DOCUMENT_SEND_API1.


...
* fill attributes "sender" and "reply recipient"
  if my_sr->get_sender( ) is initial.
    try.
        uname = sy-uname.
        l_sender ?= cl_sapuser_bcs=>create( uname ).
        CALL METHOD my_sr->setu_sender( l_sender ).
      catch cx_bcs.
        "so what?
    endtry.
  endif.

  if my_sr->get_reply_to( ) is initial.
    try.
        uname = sy-uname.
        l_recip ?= cl_sapuser_bcs=>create( uname ).
        CALL METHOD my_sr->setu_reply_to( l_recip ).
      catch cx_bcs.
        "so what?
    endtry.
  endif.

...

* save oid for export
  e_send_request_oid = send_request_oid.

Hope this will help.

Regards,

Ferry Lianto

Please reward points if helpful.

0 Kudos
1,313

Hi,

can I define my_sr and l_sender?

Regards

Angela

0 Kudos
1,313

Hi all,

I am using SO_NEW_DOCUMENT_SEND_API1 to send an email. But I need to update the program so that the reply recepient has to be 'DO NOT REPLY'.

Can you help me finding out how to provide the Reply-recipient ?

Edited by: Umesh Vaidya on Nov 18, 2009 8:38 AM

athavanraja
Active Contributor
0 Kudos
1,313

Welcome to SDN.

If you are on WAS6.10 or above you can use the following code sample, where you can set the sender.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5931ff64-0a01-0010-2bb7-ff2...

Regards

Raja

Former Member
0 Kudos
1,313

Hi

Hope it will help you.

Reward if help.

&----


*& Report ZEMAIL_SIVA

*&

&----


*&

*&

&----


REPORT zemail_siva.

DATA : gd_doc_data LIKE sodocchgi1,

l_i_mail TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE,

it_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE.

DATA: w_pack TYPE sopcklsti1,

i_pack TYPE TABLE OF sopcklsti1.

PARAMETERS : p_email(100) TYPE c.

gd_doc_data-obj_descr = 'TEST EMAIL FROM ABAP SE TEAM'.

l_i_mail-line = 'Testing the Mail from ABAP on 31st March 2008'.

APPEND l_i_mail.

it_receivers-receiver = p_email.

it_receivers-rec_type = 'A'.

it_receivers-com_type = 'INT'.

*it_receivers-notif_del = 'X'.

*it_receivers-notif_ndel = 'X'.

APPEND it_receivers.

CLEAR w_pack.

w_pack-head_start = 1.

w_pack-head_num = 0.

w_pack-body_start = 1.

DESCRIBE TABLE l_i_mail LINES w_pack-body_num.

w_pack-doc_type = 'RAW'.

w_pack-doc_size = w_pack-body_num * 255.

APPEND w_pack TO i_pack.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = gd_doc_data

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

packing_list = i_pack

  • OBJECT_HEADER =

  • CONTENTS_BIN =

contents_txt = l_i_mail

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

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

..

IF sy-subrc <> 0.

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

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

ELSE.

WRITE : 'Mail Sent to specified address'.

ENDIF.

0 Kudos
1,313

Hi Mahajan,

It's impossible to set the sender with function 'SO_NEW_DOCUMENT_ATT_SEND_API1'.

Regards

Angela

Former Member
0 Kudos
1,313

Hi,

If you are not sending an attachment then use the below code to have sender address

DATA: send_request TYPE REF TO cl_bcs.

DATA: text TYPE bcsy_text.

DATA: xtext TYPE STANDARD TABLE OF solix .

DATA: document TYPE REF TO cl_document_bcs.

DATA: sender TYPE REF TO if_sender_bcs.

DATA: recipient TYPE REF TO if_recipient_bcs.

DATA: bcs_exception TYPE REF TO cx_bcs.

DATA: sent_to_all TYPE os_boolean.

DATA: conlength TYPE i ,

conlengths TYPE so_obj_len ,

result_content TYPE string .

  • subject TYPE so_obj_des .

DATA: e_r_page TYPE REF TO cl_rsr_www_page.

DATA: content_length TYPE w3param-cont_len ,

content_type TYPE w3param-cont_type,

return_code TYPE w3param-ret_code .

DATA: html TYPE STANDARD TABLE OF w3html .

DATA: server TYPE string ,

port TYPE string .

DATA: wa_rec TYPE ad_smtpadr .

DATA: bcs_message TYPE string ..

DATA : reply TYPE REF TO if_recipient_bcs.

DATA: tmp_str TYPE string .

  • data: v_sender like SENDER_ID.

  • v_sender = SENDER_ID.

IF NOT recepients[] IS INITIAL .

CLEAR result_content.

CLEAR : server, port .

CALL FUNCTION 'TH_GET_VIRT_HOST_DATA'

EXPORTING

protocol = 1

virt_idx = 0

  • LOCAL = 1

IMPORTING

hostname = server

port = port

EXCEPTIONS

not_found = 1

internal_error = 2

OTHERS = 3 .

CLEAR tmp_str .

CONCATENATE 'http://' server ':' port '/sap/public/' INTO tmp_str .

REPLACE ALL OCCURRENCES OF '/sap/public/' IN result_content WITH

tmp_str .

CLEAR tmp_str .

CLEAR: conlength,conlengths .

REFRESH text .

text[] = email_body[].

TRY.

CLEAR send_request .

send_request = cl_bcs=>create_persistent( ).

CLEAR document .

document = cl_document_bcs=>create_document(

i_type = 'HTM'

i_text = text

  • i_length = conlengths

i_subject = subject ).

  • add document to send request

CALL METHOD send_request->set_document( document ).

CLEAR sender .

sender = cl_cam_address_bcs=>create_internet_address( SENDER_ID ).

CALL METHOD send_request->set_sender

EXPORTING

i_sender = sender.

CLEAR sender .

reply = cl_cam_address_bcs=>create_internet_address( reply_id ).

CALL METHOD send_request->set_reply_to

EXPORTING

i_reply_to = reply.

CLEAR wa_rec .

LOOP AT recepients INTO wa_rec .

CLEAR recipient .

recipient = cl_cam_address_bcs=>create_internet_address(

wa_rec ).

  • add recipient with its respective attributes to send request

CALL METHOD send_request->add_recipient

EXPORTING

i_recipient = recipient

i_express = 'X'.

ENDLOOP .

CALL METHOD send_request->set_status_attributes

EXPORTING

i_requested_status = 'E'

i_status_mail = 'E'.

CALL METHOD send_request->set_send_immediately( 'X' ).

  • ---------- send document ---------------------------------------

CALL METHOD send_request->send(

EXPORTING

i_with_error_screen = 'X'

RECEIVING

result = sent_to_all ).

IF sent_to_all = 'X'.

APPEND 'Mail sent successfully ' TO return .

ENDIF.

COMMIT WORK.

  • -----------------------------------------------------------

  • * exception handling

  • -----------------------------------------------------------

  • * replace this very rudimentary exception handling

  • * with your own one !!!

  • -----------------------------------------------------------

CATCH cx_bcs INTO bcs_exception.

bcs_message = bcs_exception->get_text( ).

APPEND bcs_message TO return .

EXIT.

ENDTRY.

ELSE .

APPEND 'Specify email address for sending' TO return .

ENDIF .

Former Member
0 Kudos
1,313

Before call the FM so_new_document_att_send_api1, set sy-uname = 'xxx' where xxx = SENDER's R3 ID

0 Kudos
1,313

Hello,

we can use FM  SO_DOCUMENT_SEND_API1 instead of Using FM SO_NEW_DOCUMENT_SEND_API1.

Function Module SO_DOCUMENT_SEND_API1 contains import parameters

SENDER_ADDRESS

SENDER_ADDRESS_TYPE

Try this, its worked for me.