Send Emails Using Object Oriented Method – CL_BCS
POSTED ON MARCH 11, 2015 BY ISURU FERNANDO
In newer versions of SAP (newer than 6.10 release) best practice is to send emails using BCS interface instead of API1 interface. BCS interface is easier to use than the older API1 interface. Plus you are not required to fill the packing list which makes it less complicated.
These function modules can be used to send email in older versions.
SO_DOCUMENT_SEND_API1
SO_NEW DOCUMENT_ATT_SEND_API1
SO_NEW_DOCUMENT_SEND_API1
These functions could be replaced by ABAP class CL_BCS (Business Communication Service).
How to handle Email Queues in SAPConnect Send Request (SOST).
When you trigger emails using these FMs or CL_BCS ABAP OO class, queues get generated under SOST (SAPconnect Send Requests). SOST queued emails can be processed using program RSCONN01 (SAPconnect: Start Send Process).
PROCESS SOST QUEUES USING RSCONN01
Set correct parameters such that you do not send out unwanted messages and affect the performance of the servers.
rsconn01 address type
Also these messages can be sent manually using transaction SOST.
Execute SOST email queue
ABAP Program to Send Emails using ABAP OO Class CL_BCS.
When using class CL_BCS to send emails there are few basic steps which should be considered. Depending on the email format and attachment type parameter should be set differently.
In the shown example email is send in HTML format with a text file (.txt) attachment. Email subject, body, recipient email and text for attachment are given in the selection screen.
Selection Screen
ABAP OO email program selection screen
As we are using HTML email format, body text in selection should be converted to HTML format. When attaching TXT or any other attachments to email, attached data should be converted to “SOLIX” format which is accepted by BCS class. Attachments can be text files, PDF files, world documents etc.
Data Declaration
data declaration
Setting email subject, HTML email body and initializing.
Set email body
Convert Data Formats.
Converting attachment string to xstring, converting xstring to SOLIX format and calculating attachment size.
convert data
Adding email recipients and finally pushing the email to SOST.
Add email recipient
SOST
Created email in SOST
Email received
Email attachent
Please leave a comment if you have any queries on CL_BCS class, email driver program or SOST.
This entry was posted in ABAP and tagged ABAP, CL_BCS, Email, HTML, OO, SAP, SO_DOCUMENT_SEND_API1, SO_NEW_DOCUMENT_SEND_API1, SOST.
ISURU FERNANDO
Hi, I am Isuru Fernando, Senior SAP Integration Consultant with 10 years of SAP full-cycle implementation and support project experience. From the early days, I had a passion for coding, software development, and everything tech-related. I started my carrier as an ABAP developer and soon found my love for system integration when I learned SAP XI 3.0 in 2008. Playing a variety of roles from an offshore technical consultant (ABAP, PI/PO, BW, BOBJ) at the beginning of my career to a technical lead managing a team of consultants in different countries, I have gained immense experience in SAP project implementation life cycle. Having the opportunity to work on SAP implementation projects in USA, EU, and Asia, I learned valuable ins and outs of global business processors in Sales and Distribution (SD), Material Management, Retail, Customer Relationship Management (CRM), and Finance and Controlling (FICO). Through this blog, I want to share my expertise in SAP technical areas such as SAP ABAP, PI/PO, AIF, and Basis. I also want to provide a platform for others with similar ambitions who would like to share their SAP technical expertise with the world!
XML Transformation Example with XSLT_TOOL
Create LSMW with BDC Recording Example
Play
Unmute
Loaded: 31.01%
Remaining Time -2:33
Picture-in-Picture
Auto(360pLQ)
ShareFullscreen
Advertisement: 0:23
What is SAP PI PO?
SIGN UP TODAY!
Sign up to receive our monthly newsletter and special deals!
Top of Form
I accept Newsletters & Blog updates.
Bottom of Form
TECH GADGETS I USE EVERY DAY
These are some of the tech gadgets I use every day. If you make a purchase through these links I will earn a small comission at absolutely no extra cost to you.
4 THOUGHTS ON “SEND EMAILS USING OBJECT ORIENTED METHOD – CL_BCS”
Hii, do you provide placent opportunities after the training, I am looking forward to someone who can provide me with placement opportunities!
AUGUST 29, 2015 AT 2:20 AM
REPLY
Thanks , really helpfull, in the case of needing multiple recipients based on distribution lists or custom roles is there any class or fm to do so?
NOVEMBER 27, 2018 AT 3:26 AM
REPLY
How to email dynamic table in Email Body & as excel attachment.
NOVEMBER 19, 2019 AT 3:05 PM
REPLY
Hi Amar,
Check the standard example BCS_EXAMPLE_7.
Cheers!
Isuru
NOVEMBER 22, 2019 AT 12:17 PM
REPLY
Leave a Reply
Top of Form
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Bottom of Form