Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

Taking SAP GUI screenshot automatically and send as attachment through mail programmatically

$
0
0

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.

capture.png


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

capture.png

           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

capture.png

         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

capture.png

    

       b)      Create Mail document to include body, attachment etc

capture.png

       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.

capture.png

          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.

capture.png

     e)      Attach sender and recipient address. Add sender, TO, CC, BC address to send request.


capture.png

   f)      Send Mail – Call send method to send mail with attachment

capture.png



Result :


capture.png

Email send with attachment


capture.png


Viewing all articles
Browse latest Browse all 935

Trending Articles