The document provides an overview of the feasibility of multiple mail option for SAP scripts. The challenge in SAP scripts is that the numbers of recipients in the external send transmission medium is limited to one. So enhancing the standard functionality is required. A general knowledge of SAP script and enhancements is required for understanding the document.
Working of SAP script for Transmission Medium 5 (External Send)
In the FM OPEN_FORM (Function Module used for Opening the SAP script) the Recipient and the Sender of the mail are given as importing parameters.
In the FM CLOSE_FORM (Function Module used at the end the SAP script) is the where the Email is actually triggered. In CLOSE_FORM the Form that was generated is converted to an OTF format which is in turn converted to a PDF. The PDF is then mailed to Recipient.
Why the constraint for Multiple Recipients
In the FM OPEN_FORM the Importing Parameter ‘mail_recipient’ is a structure of type SWOTOBJID which means in only one mail recipient is possible. Thus we have to overcome this constraint of standard SAP.
Enhancing FMs OPEN_FORM and CLOSE_FORM is not recommended as they are used for all SAP scripts running in the system.
Below is an overview of the solution and then a detailed step by step procedure with an example.
The SAP script creates an OTF format of the Form data, this data can be imported to the program through CLOSE_FORM. The imported data is sent to the required mail recipients. To be able to obtain the OTF format in CLOSE_FORM, the field ITCPO-TDGETOTF has to be checked in the Importing parameters of OPEN_FORM.
Consider the following Business scenario.
When a Purchase Order is generated in ME21N transaction, a message type NEU is to be triggered and
external mail is to be sent to the Vendor and the PO creator. (Note: This is not the case of Release
strategy but during the creation of the Purchase Order).
If the Mail was to be sent only to the vendor then no enhancement of standard would have been required.
During Purchase Order creation, the SAP script is called through FM ‘ME_PRINT_PO’. The OPEN_FORM is called in the include LMEDRUCKF10.
Before the OPEN_FORM is called, in the structure ITCPO fill the field TDGETOTF = ‘X’ to get the OTF form as an importing parameter in CLOSE_FORM when External send is triggered (NAST-NACHA = 5).
To do the above we can use the enhancement-point LMEDRUCKF10_02 of the enhancement-spot ES_SAPLMEDRUCK. Refer below screen shot.
Declaration of variables for the functionality can be done in the enhancement-point ENDE_01, enhancement-spot ES_SAPLMEDRUCK. Refer below screen shot.
The CLOSE_FORM which was already implemented by Standard SAP is over written as the OTF data has to be imported. The enhancement-point ENDE_02, enhancement-spot ES_SAPLMEDRUCK is used for the same. Refer below screen shot.
The OTF file is obtained in the TABLES parameter. Refer below screen shot.
When the OTF data is imported then standard SAP does not send mail to the partner mentioned in External Send! Thus in
this case we will have to send mail to both the Vendor and PO creator. To determine the mail address of the vendor use the FM ‘ADDR_GET_NEXT_COMM_TYPE’. Refer below screen shot.
The Email address of the PO creator is obtained as below.
The OTF file format has to be converted to PDF. There are many ways to do the same. Below mentioned is one method. The FM ‘CONVERT_OTF’ input the OTF file obtained and import the Hexadecimal PDF file.
We can use the Class CL_BCS to send the mail to more than one recipient and the PDF is attached in the mail. Below screen shots show a sample of filling the data for the class. We can check if the mail has been sent from SAP using the Transaction SOST.
Refer below the Overview of the Enhancement Implementation required.