Skip to Content
author's profile photo Former Member
Former Member

Passing hard code value as the sender name in fm SO_NEW_DOCUMENT_SEND_API1

Hi Experts,

I am using one FM "SO_NEW_DOCUMENT_SEND_API1" to send mail form my program.

In the receipient inbox under from address the mail is showing

the USER ID in which that program has been executed .

*Is it possible to send a hard coded value as a sender instead of the sap user id in the sender address * .



Edited by: sarmistha das on May 6, 2008 11:18 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 06, 2008 at 09:24 AM


    Using FM SO_NEW_DOCUMENT_SEND_API1 you cannot have hard coded sender address.

    You can create your Z fm that is copy of the above fm and implement an option to have sender address.

    Or you can implement below logic to send an email in your program.

    *TABLES : ypgtest.

    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 .



    protocol = 1

    virt_idx = 0

    • LOCAL = 1


    hostname = server

    port = port


    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[].


    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


    i_sender = sender.

    CLEAR sender .

    reply = cl_cam_address_bcs=>create_internet_address( reply_id ).

    CALL METHOD send_request->set_reply_to


    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


    i_recipient = recipient

    i_express = 'X'.


    CALL METHOD send_request->set_status_attributes


    i_requested_status = 'E'

    i_status_mail = 'E'.

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

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

    CALL METHOD send_request->send(


    i_with_error_screen = 'X'


    result = sent_to_all ).

    IF sent_to_all = 'X'.

    APPEND 'Mail sent successfully ' TO return .



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

    • * 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 .



    ELSE .

    APPEND 'Specify email address for sending' TO return .

    ENDIF .


    Shravan G.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 06, 2008 at 09:23 AM


    If the email address is configured in SU01 txn for that particular user id, then automaticallyt it will come as sender ID.

    Ask for basis help to configure email ID for that user.Other wise there is no other solution for this.



    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 12, 2009 at 12:33 PM


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.