Sending Smartform PDF as an email Attachment by using standard classes

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_NAMDivya_palem_0-1720603058185.png

     

     

Divya_palem_1-1720603058187.png

 

 

  • Convert that into pdf by using function module like CONVERT_OTF. Divya_palem_2-1720603058188.png
  • Convert the XSTRING data (from smart form) into binary data. Divya_palem_3-1720603058189.png

Divya_palem_4-1720603058189.png

  • After converting the data, send the Request by using CL_BCS class. 

Divya_palem_5-1720603058189.png 

Divya_palem_6-1720603058190.png

 

  • I need to send an email to outside of sap users. 
  • So, here i used class like CL_CAM_ADDRESS_BCS. Divya_palem_7-1720603058190.png 

Divya_palem_8-1720603058191.png

 

  • 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. Divya_palem_9-1720603058192.png

     

      

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. 

Divya_palem_10-1720603058192.png

Divya_palem_11-1720603058193.png

Divya_palem_12-1720603058194.png

 

Divya_palem_13-1720603058195.png

 

 

Attachment: 

We need to give the information about an email attachment and the subject of pdf. 

Divya_palem_14-1720603058195.png

 

Divya_palem_15-1720603058196.png

 

Divya_palem_16-1720603058196.png

We need to send an email immediately by using cl_bcs class. 

Divya_palem_17-1720603058196.png

After completion of setting an email. 

We need to send an email. 

Divya_palem_18-1720603058197.png

Divya_palem_19-1720603058197.png

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. 

Divya_palem_20-1720603058198.png

Divya_palem_21-1720603058198.png

 

After, Go to T-code “SOST”-for status of our email. 

Divya_palem_22-1720603058200.png

We can filter our sending request through waiting, errors,send status in send status tab. 

Divya_palem_23-1720603058202.png

And we can also re-process our email sending, and we can also trace our mails. 

Divya_palem_24-1720603058204.png 

Configure outbound messages by using SCOT t-code: 

1.Go to smtp Connection folder->outbound Messages->SMTP Nodes. 

Divya_palem_25-1720603058205.png

  1. Create smtp node by using wizards or we can directly create a nodes. 

Divya_palem_26-1720603058206.png

Divya_palem_27-1720603058207.png

Divya_palem_28-1720603058208.png

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. 

Divya_palem_29-1720603058209.png

Go to Active Application server., 

Double click on that server. 

Divya_palem_30-1720603058209.png

Select server name and click on change view option- to get the IP Address of your system. 

Divya_palem_31-1720603058210.png

Then go to /nSMICM T-code to get details of host name and port. 

Divya_palem_32-1720603058211.png 

Divya_palem_33-1720603058212.png

Divya_palem_34-1720603058213.png

Divya_palem_35-1720603058214.png

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. 
     

Divya_palem_36-1720603058215.png

Divya_palem_37-1720603058217.png

Divya_palem_38-1720603058218.pngDivya_palem_39-1720603058219.png 

 

  • 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. 

Divya_palem_40-1720603058220.png

Divya_palem_41-1720603058222.png 

Divya_palem_42-1720603058223.png

  • 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. Divya_palem_43-1720603058224.png Divya_palem_44-1720603058226.png

     

     

  • Now, in the same path, select the “Send jobs” option. Then Activate and Scheduled Send job with the same selected address type. Divya_palem_45-1720603058228.pngDivya_palem_46-1720603058231.pngDivya_palem_47-1720603058231.pngDivya_palem_48-1720603058232.png

     

     Divya_palem_49-1720603058233.png 

Then Go to sm37. Execute it with Job name. 

Divya_palem_50-1720603058234.png

Divya_palem_51-1720603058235.png

  • Now do it, a test mail using the transaction code: SO01 [Business workplace of Admin]. 
  • Go to the outbox section. 
  • Check the documents. Divya_palem_52-1720603058238.png 

Divya_palem_53-1720603058241.png

  • Then check in session of Send request by using the T-code: SOST. Divya_palem_54-1720603058243.png
  • We can reschedule our email request and as well as set your own time and send the jobs. Divya_palem_55-1720603058246.png 

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. 

 

 

 

 

Scroll to Top