Skip to Content

This document explains how screen shot of SAP GUI screen can be taken 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.(Note I have enhanced std demo program GRAPHICS_GUI_CE_DEMO to demonstrate screen shot feature ).

Untitled.png

Approach

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


Untitled.png

   As shown in above code, screenshot data is imported by image parameter.


  • Convert xstring data into binary data to send it as attachment – Use method XSTRING_TO_SOLIX  of class CL_BCS_CONVERT

Untitled.png

      LT_DOC_CONTENT contains binary data which will be used later to send as attachment in mail.

  •     Send screenshot as mail attachment – Use class CL_BCS to send mail with attachment.

          a) Create persistent object of type CL_BCS for a mail send request

         Untitled.png

            b) Create Mail document to include body, attachment etc. Mail document type CL_DOCUMENT_BCS

          

         Untitled.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 an attachment  to mail document . screenshot can be PNG, BMP,GIF,JPG etc. Note whatever the 

                 screenshot data taken in previous step 1 and 2 attached as document here

           Untitled.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 object to send request.

              Untitled.png

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

                  Untitled.png

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

                    Untitled.png


Result :


When user click on screenshot button then system takes screen shot and send it as email attachment.


Untitled.png






          



To report this post you need to login first.

19 Comments

You must be Logged on to comment or reply to a post.

  1. K.Arun Prabhu

    Very good work. Simple and powerful utility.

    I was looking at the possibility of doing something similar.

    Continue your good work 🙂

    (0) 

Leave a Reply