To send the Smart form pdf as an email attachment by make use of standard class like
- CL_BCS
- CL_DOCUMENT_BCS
- CL_CAM_ADDRESS_BCS
- CL_SAPUSER_BCS
- CL_BCS: This class is used for sending the request, adding the recipients and sending the document.
- CL_DOCUMENT_BCS: this class is used for adding the attachment, and creating the document.
- CL_CAM_ADDRESS_BCS: This class is used for the creating external recipients.
- CL_SAPUSER_BCS: This class is used to create SAP USERS.
Steps to sending smart form pdf as an email attachment.
- In Report level, we need to get our smart form program by using SSF_FUNCTION_MODULE_NAM
- Convert that into pdf by using function module like CONVERT_OTF.
- Convert the XSTRING data (from smart form) into binary data.
- After converting the data, send the Request by using CL_BCS class.
- I need to send an email to outside of sap users.
- So, here i used class like CL_CAM_ADDRESS_BCS.
- Here, i used method like create_internet_Address. This method helps us to store the receiver’s address, which is receiver outside of sap users.
After, we need to do write the body of an email.
So, what is the information, we would like to send an email, we can send through this “create document” method in cl_document_bcs.
First, we can add the information in work area, we can append that into internal table.
Attachment:
We need to give the information about an email attachment and the subject of pdf.
We need to send an email immediately by using cl_bcs class.
After completion of setting an email.
We need to send an email.
After sending the email, the result will store in that variable lv_result.
If lv_result = ‘x’. An email sent successfully.
Otherwise, it will not send.
When we are sending an email to outside of sap users, we need to use the statement ‘COMMIT WORK’.
If we are sending an email to within sap users, then, this statement is not required.
After, Go to T-code “SOST”-for status of our email.
We can filter our sending request through waiting, errors,send status in send status tab.
And we can also re-process our email sending, and we can also trace our mails.
Configure outbound messages by using SCOT t-code:
1.Go to smtp Connection folder->outbound Messages->SMTP Nodes.
- Create smtp node by using wizards or we can directly create a nodes.
Here, we need to give mail host, according to your system configuration by checking in tcodes – os01.
Steps to find the system mail host and port.
Go to os01 t-code.
Go to Active Application server.,
Double click on that server.
Select server name and click on change view option- to get the IP Address of your system.
Then go to /nSMICM T-code to get details of host name and port.
Address area should start with *your email_id.
- Specify the address area for which the node is to be responsible. Better to provide as a star. then continue it.
- Specify the output formats into which documents in SAP-internal formats are to be converted as like below screenshot otherwise give whatever you want.
- Then continue for further then it will show conformation screen for address type and in that, you can also provide other address types. Here, RAW text should be TXT, otherwise your output of the body text has appeared in a different way.
- If you give it as PDF, then body text of inbound mail is appear as pdf file.
- Then, it will ask the Maximum waiting time for repeat send attempt procedure.
- So, provide what time you want.
- Then click on continue. That’s it, your node will create successfully.
- Then go to settings in SCOT, like as shown in the below path SCOT –>Business Communication Administration–>Settings–>Outbound Messages–>Settings.
- Then give the “Default Domain” name like as shown in below screen shot.
- Now, in the same path, select the “Send jobs” option. Then Activate and Scheduled Send job with the same selected address type.
Then Go to sm37. Execute it with Job name.
- Now do it, a test mail using the transaction code: SO01 [Business workplace of Admin].
- Go to the outbox section.
- Check the documents.
- Then check in session of Send request by using the T-code: SOST.
- We can reschedule our email request and as well as set your own time and send the jobs.
Note: Even after you configured the above configuration, still the mail cannot be delivered sometimes. Because of the below reason…
- The mail server SSL does not support the TLS protocol.
- Here, SAP supports only TLS SSL. Please check with respective team.