In this chapter, we will see recipes of e-mail programming using the Business communication services (BCS). We will look at:
This chapter explores useful recipes related to the programming of e-mail sending. We will start with a brief overview of BCS and the various classes available. Then we will see a simple recipe that will generate an e-mail to an SAP user in his or her inbox. Then, we will show how the same program may be changed in order to send the e-mail to Internet e-mail addresses.
We will then add attachments such as an Excel (XML file) to the e-mail. Creating HTML documents will also be discussed. Finally, we will create a program that will execute another ABAP program, convert its output into PDF, and attach the PDF to an e-mail message.
We will see the most important and commonly used classes (and their methods) used for e-mail creation. In addition to e-mail programming classes such as CL_BCS
and CL_BCS_DOCUMENT
, we will also see classes such as CL_CONVERT_BCS
that are used for converting files into appropriate formats suitable for attaching to e-mail documents.
Throughout the chapter, the terms e-mail and SAP Office Document will be used interchangeably.
The BCS classes provide a newer object-oriented means of generating e-mails programmatically. The function modules should no longer be used for sending e-mails. The BCS classes are much simpler to program, particularly when we have attachments involved.
The classes relevant to e-mail programming are discussed as follows:
Class name |
Use |
---|---|
This class is for creating sent requests. The document (e-mail body and attachments) is assigned to it and recipients are specified. Finally, the request is sent. | |
This is the document class for specifying the content of the e-mail and attachments (if any). | |
This class provides a number of useful methods. The notable one uses an Internet e-mail address such as | |
This class creates a recipient object based on an SAP user ID to be used. | |
This class converts data from one format to another, such as conversion of text string to binary table or from a hexadecimal string to a binary table, and so on. |
3.142.250.203