Skip to Content
Author's profile photo Former Member

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

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






          



Assigned Tags

      20 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      OMG, this is awesome! Learned something new today - thanks for sharing! 🙂

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you

      Author's profile photo Former Member
      Former Member

      Nice Document........

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you

      Author's profile photo Arun Prabhu
      Arun Prabhu

      Very good work. Simple and powerful utility.

      I was looking at the possibility of doing something similar.

      Continue your good work 🙂

      Author's profile photo Abdul Hakim
      Abdul Hakim

      Cool stuff.

      Author's profile photo Naveen Vishal
      Naveen Vishal

      Nice and new stuff..!  Thanks Aruna. 🙂

      Author's profile photo Former Member
      Former Member

      Hi Arun - Good Work!!!

      Author's profile photo Santosh Baratam
      Santosh Baratam

      Loved to see your document!!

      Author's profile photo Former Member
      Former Member

      Nice document !!!!!!

      Author's profile photo Pavan Golesar
      Pavan Golesar

      🙂

      Helpful post.....

      Keep up...

      thank you

      Author's profile photo Former Member
      Former Member

      Useful document .

      Thanks for Sharing .

      Author's profile photo Former Member
      Former Member

      good documet, it is usefull. thakyou.

      Author's profile photo Former Member
      Former Member

      wonderful document. I would like to see more from your side. Keep it up 🙂

      Author's profile photo Kiran K
      Kiran K

      Thanks for sharing this methodology.

      K.Kiran.

      Author's profile photo Yen Shen Lim
      Yen Shen Lim

      Thanks for the sharing. Something new to me!

      Author's profile photo DAMODAR SAI MALLIKA
      DAMODAR SAI MALLIKA

      Hi Arun,

      Thanks a lot for sharing the awesome part of ABAP !! 🙂

      Keep sharing !! 🙂

      Thanks and Regards,

      Damodar Sai

      Author's profile photo Former Member
      Former Member

      Hi Aruna Kumara.

      Can you pls. share the step by step document for Taking SAP GUI screenshot automatically and send as attachment through mail programmatically,

      currently its not available

      Umesh

      Author's profile photo A. Lamps AFM
      A. Lamps AFM

      Amazing......:)

       

      Author's profile photo Former Member
      Former Member

      Any method to attach screenshots to a word document.