Send e-mail with subject line greater than 50 characters

SAP email
Share on Facebook6Share on LinkedIn6Tweet about this on TwitterShare on Google+0
Please Share!!

Sometimes when we send email, as per the business requirement, the subject line of the email can be greater than 50 characters. The function module SO_NEW_DOCUMENT_ATT_SEND_API1, which is normally used in sending emails from SAP, has a limitation of email subject of maximum 50 characters.


So in such cases we need to look for some alternative to send emails. We can call the class CL_BCS (Business Communication Service) to get this done.

CL_BCS is a class that serves as the interface from BCS to the applications. The methods of the class cater for the send functions.

Code Snippet:

TYPES: BEGIN OF t_mail_body.
INCLUDE TYPE solisti1.
TYPES: END OF t_mail_body.

c_check TYPE char1 VALUE ‘X’,
c_mode TYPE char3 VALUE ‘INT’,
c_doc_type TYPE char3 VALUE ‘RAW’.

DATA : i_mail_body TYPE STANDARD TABLE OF t_mail_body,
k_doc_data TYPE sodocchgi1,
v_subject TYPE char255.
lv_cnt TYPE i,
lv_sub TYPE string,
lv_receiver TYPE ad_smtpadr,
l_ref_send_request TYPE REF TO cl_bcs,
l_ref_document TYPE REF TO cl_document_bcs,
l_ref_sender TYPE REF TO cl_sapuser_bcs,
l_ref_recipient TYPE REF TO if_recipient_bcs,
l_ref_bcs_exception TYPE REF TO cx_bcs,
lv_sent_to_all TYPE os_boolean.

CLEAR: k_doc_data.

* Populate the email body in internal table i_mail_body[].

* Fill the document data.
DESCRIBE TABLE i_mail_body LINES lv_cnt.

k_doc_data-doc_size = ( lv_cnt – 1 ) * 255.

* ——– create persistent send request ————————
l_ref_send_request = cl_bcs=>create_persistent( ).

* ——– create and set document ——————————-
* create document from internal table with text

l_ref_document= cl_document_bcs=>create_document(
i_type = c_doc_type
i_text = i_mail_body
i_length = k_doc_data-doc_size
i_subject = ‘ ‘ ).

* Subject of the email
lv_sub = ‘The following interface failed, Please check’. ” This can * be greater than 50 characters

CALL METHOD l_ref_send_request->set_message_subject
ip_subject = lv_sub.

* add document to send request
CALL METHOD l_ref_send_request->set_document( l_ref_document ).

* ——— set sender ——————————————-
* note: this is necessary only if you want to set the sender
* different from actual user (SY-UNAME). Otherwise sender is
* set automatically with actual user.

l_ref_sender = cl_sapuser_bcs=>create( sy-uname ).

CALL METHOD l_ref_send_request->set_sender
i_sender = l_ref_sender.

CLEAR lv_receiver.
* Get receiver from the config table

lv_receiver = ‘’.

* ——— add recipient (e-mail address) ———————–
* create recipient – please replace e-mail address
l_ref_recipient = cl_cam_address_bcs=>create_internet_address(
lv_receiver ).

* add recipient with its respective attributes to send request
CALL METHOD l_ref_send_request->add_recipient
i_recipient = l_ref_recipient
i_express = c_check.

* ———- send document —————————————
CALL METHOD l_ref_send_request->send(
i_with_error_screen = c_check
result = lv_sent_to_all ).



*Executing the standard mail sending program for immediate dispatch of mail
SUBMIT rsconn01 WITH mode = c_mode AND RETURN. ” Mode is INT’

Please note: You will not be able to see the email subject in SAP Transaction code SOST. But in the actual email inbox you will be able to see the subject line.


1) This has almost all the features present in the common FM SO_NEW_DOCUMENT_ATT_SEND_API1.

2) In addition we can send email with the message lines greater than 50 characters.

Image source :

Share on Facebook6Share on LinkedIn6Tweet about this on TwitterShare on Google+0
Please Share!!