This document explains how screen shot of SAP GUI screen can be taken automatically (not using Prtsc manually )and sends it as mail attachment by ABAP program.
Requirement:Taking screenshot of GUI screen like shown below and send it as mail attachments through ABAP.
Approach
1. Use front end GUI service class to take screenshot – Method GET_SCREENSHOT of CL_GUI_FRONTEND_SERVICES.
When you called this method, system will take screenshot of active screen and return screenshot data intern of hexadecimal values (xstring).
As shown in above code, screenshot data is imported by image parameter
2. Convert xstring data into binary data to send it as attachment – Use method XSTRING_TO_SOLIX of class CL_BCS_CONVERT
LT_DOC_CONTENT contains binary data which will be used later to send as attachment in mail.
3. Send screenshot as mail attachment – Use class CL_BCS to send mail with attachment.
a) Create persistent class reference for a mail send request
b) Create Mail document to include body, attachment etc
Above code – Mail subject as ‘Project Status Info’. Mail body can be in I_TEXT parameter.
For this example I not used any mail content.
c) Add screenshot as attachment to mail – Can be Attached as PNG,BMP, GIF, JPG etc format.
Note screenshot content passed here.
Binary content of screenshot data LT_DOC_CONTENT which prepared in step1 and step2
passed to I_ATT_CONTENT_HEX.
d) Attach mail document to send request.
e) Attach sender and recipient address. Add sender, TO, CC, BC address to send request.
f) Send Mail – Call send method to send mail with attachment
Result :
Email send with attachment