Send e-mail with subject line greater than 50 characters

SAP email

Let’s get on Send e-mail with subject line greater than 50 characters. In some cases when we send email, according to the business prerequisite, the headline of the email can be more noteworthy than 50 characters. The capability module SO_NEW_DOCUMENT_ATT_SEND_API1, which is typically utilized in sending messages from SAP, has a restriction of email subject of greatest 50 characters.

So in such cases we really want to search for a choice to send messages. We can call the class CL_BCS (Business Correspondence Administration) to finish this. Send e-mail with subject line greater than 50 characters.

Also Read | ABAP Email Subject

CL_BCS is a class that fills in as the connection point from BCS to the applications. The strategies for the class cater for the send capabilities.

ABAP for SAP HANA. ALV Report On SAP HANA – Opportunities And Challenges

Code Snippet:

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

CONSTANTS:
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.
DATA:
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.

TRY.
* ——– 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
EXPORTING
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
EXPORTING
i_sender = l_ref_sender.

CLEAR lv_receiver.
* Get receiver from the config table

lv_receiver = ‘xxxxx@gmail.com’.

* ——— 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
EXPORTING
i_recipient = l_ref_recipient
i_express = c_check.

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

COMMIT WORK.

ENDTRY.

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

If it’s not too much trouble, note: You can not see the email subject in SAP Exchange code SOST. In any case, in the real email inbox you will actually want to see the headline.

Benefits:

1) This has practically every one of the elements present in the normal FM SO_NEW_DOCUMENT_ATT_SEND_API1.

2) what’s more we can send email with the message lines more noteworthy than 50 characters.

YOU MAY LIKE THIS

A Comprehensive Guide to SAP ABAP Training Online

Core Data Services in ABAP for HANA

Setting Up an ABAP Environment in the Cloud

  • Related Posts

    CI/CD Quality Gates

    CI/CD Quality Gates: A Comprehensive Guide for IT Professionals Understanding CI/CD Quality Gates Continuous Integration (CI) and Continuous Delivery or Continuous Deployment (CD) have transformed modern software development by automating…

    Mastering Autonomous AI Agents in 2026 – A Comprehensive Guide for IT Professionals

    Discover the world of autonomous AI agents and learn how to master these complex systems for high-paying jobs and career growth opportunities. Explore various aspects, including basics, eligibility, learning resources, and professional tips.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You Missed

    CI/CD Quality Gates

    • By Varad
    • September 22, 2026
    • 5 views
    CI/CD Quality Gates

    Mastering Autonomous AI Agents in 2026 – A Comprehensive Guide for IT Professionals

    • By Varad
    • September 21, 2026
    • 8 views
    Mastering Autonomous AI Agents in 2026 – A Comprehensive Guide for IT Professionals

    Improving Software Quality for IT Professionals

    • By Varad
    • September 20, 2026
    • 8 views
    Improving Software Quality for IT Professionals

    Preparing for the LLM-as-a-Judge Test: A Guide for Aspiring Legal Professionals | Bright-Minds

    • By Varad
    • September 19, 2026
    • 11 views
    Preparing for the LLM-as-a-Judge Test: A Guide for Aspiring Legal Professionals | Bright-Minds

    Master RAG Systems for Effective IT Project Management

    • By Varad
    • September 17, 2026
    • 15 views
    Master RAG Systems for Effective IT Project Management

    Master Quality Management for Business Success

    • By Varad
    • September 16, 2026
    • 16 views
    Master Quality Management for Business Success