Skip to Content

Hello community,

Background Light is a server application, it is an ABAP to COM bridge and a replacement for the CL_GUI_FRONTEND_SERVICES class. It allows to use COM libraries and OS functions with ABAP background processes and without the SAP GUI for Windows.

In a normal ABAP program you can use COM calls and OS functions very easily. But, if you execute the same program as background process, COM calls and OS functions does not work. It is not possible to use COM calls and OS functions in ABAP background processes, because there is no communication between the application and the presentation server in this case.

Also you can not use COM calls with SAP GUI for Java, because it supports no COM calls. But with Background Light it is also possible. Background Light is an SAP server program and offers these possibilities. It is a bridge from your ABAP program to any COM library. After the registering of Background Light in the SAP system of your choice – via transaction SM59 – and the start of the server program on your presentation server you can use COM calls and OS functions in fore- and background processes with the same code and on each platform.

Here an example how to send an e-mail via Outlook:

"-Begin-----------------------------------------------------------------
  Report zBLightExample.

    "-Includes----------------------------------------------------------
      Include ZBLIGHTINCL.

    "-Variables---------------------------------------------------------
      Data Outlook Type Integer Value 0.
      Data olMsg Type Integer Value 0.

    "-Main--------------------------------------------------------------
      BackgroundLightExists DestExists.
      If DestExists = 1.
        CreateObject 'Outlook.Application' Outlook hResult.
        If hResult = S_OK And Outlook <> 0.
          GetPropertyObject Outlook 'CreateItem(0)' olMsg hResult.
          If olMsg <> 0.
            SetProperty olMsg 'e-mail-adress' hResult.
            SetProperty olMsg 'Subject=''Test''' hResult.
            SetProperty olMsg 'Body=''This is a test''' hResult.
            CallMethod olMsg 'Display' hResult.
            CallMethod olMsg 'send' hResult.
            CallMethod olMsg 'Quit' hResult.
            FreeObject olMsg.
          EndIf.
          FreeObject Outlook.
        EndIf.
      EndIf.

"-End-------------------------------------------------------------------

 

Beyond these functionality offers Background Light an enrichment of methods to handle COM libraries. Also open Background Light the gate wide, to use all COM libraries without any customizing of the security options of the SAP Logon program. And it offers with his functional Add-Ons the mighty possibility to use Windows Management Instrumentation (WMI).

Here an example how to read information from the BIOS:

"-Begin-----------------------------------------------------------------
  Report zBLightExample.

    "-Includes----------------------------------------------------------
      Include ZBLIGHTINCL.

    "-Variables---------------------------------------------------------
      Data WMI Type Integer Value 0.
      Data oEnum Type Integer Value 0.
      Data oNext Type Integer Value 0.
      Data ExecQuery Type String Value ''.
      Data BIOSManufacturer Type String Value ''.
      Data BIOSName Type String Value ''.
      Data BIOSVersion Type String Value ''.

    "-Main--------------------------------------------------------------
      BackgroundLightExists DestExists.
      If DestExists = 1.
        GetObject 'winmgmts:\\.\root\CIMV2' WMI hResult.
        If WMI <> 0 And hResult = S_OK.

          ExecQuery = 'ExecQuery('.
          Concatenate ExecQuery '''Select * from Win32_BIOS'''
            Into ExecQuery.
          Concatenate ExecQuery ', ''WQL'', 48' Into ExecQuery.
          Concatenate ExecQuery ')' Into ExecQuery.

          CreateEnumeration WMI ExecQuery oEnum hResult.
          If oEnum <> 0 And hResult = S_OK.
            GetNextEnumerationObject oEnum oNext hResult.
            While oNext <> 0.
              "-Get BIOS manufacturer-----------------------------------
                GetPropertyString oNext 'Manufacturer' BIOSManufacturer
                  hResult.
                Write: / BIOSManufacturer.
              "-Get BIOS name-------------------------------------------
                GetPropertyString oNext 'Name' BIOSName hResult.
                Write: / BIOSName.
              "-Get BIOS version----------------------------------------
                GetPropertyString oNext 'Version' BIOSVersion hResult.
                Write: / BIOSVersion.
              FreeEnumeration oNext.
              GetNextEnumerationObject oEnum oNext hResult.
            EndWhile.
            FreeEnumeration oEnum.
          EndIf.
          FreeObject WMI.
        EndIf.
      EndIf.

"-End-------------------------------------------------------------------

 

Background Light offers an easy interface to start and stop the server thread and to control the incoming calls.

/wp-content/uploads/2015/04/blight_705555.jpg

 

Hint: If you use Background Light with a tiny trick, you can ensure that the COM calls are for the correct user on their presentation server – use as destination the sy-uname variable. In the macro, form and class of Background Light all destinations are sy-uname.

2015/06/05 – A new version of Background Light is available

  • Background Light is not longer only as 32-bit version available, it is now also as 64-bit version available – you can find some reasons here.

 

You can download Background Light here.

Enjoy it.

Cheers
Stefan

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply