Quantcast
Channel: SCN : Blog List - ABAP Connectivity
Viewing all articles
Browse latest Browse all 68

Tip: Easy Way of ABAP ActiveX Connectivity

$
0
0

Hello community,

 

a long time ago Thomas Jung published his very good blog about "Using Classic ActiveX Controls in the ABAP Control Framework" here.

I asked myself, is there an easier way to realize a connectivity between an ActiveX control and an ABAP program, e.g. for prototyping.

Here now my result: I use a selection screen with a docking container, and the docking container is linked to the ActiveX control. That's all

 

At first the program:

001.jpg

 

"-Begin-----------------------------------------------------------------

  Program Z_TEST.

 

    "-Variables---------------------------------------------------------

      Data Ref_Dock Type Ref To CL_GUI_DOCKING_CONTAINER.

      Data Ref_Media Type Ref To Z_CL_MEDIA.

 

    "-GUI---------------------------------------------------------------

      Selection-Screen Begin Of Block Media.

        Parameters pa_Dummy(1).

      Selection-Screen End Of Block Media.

 

    "-Main--------------------------------------------------------------

      At Selection-Screen.

 

        Create Object Ref_Dock

          Exporting

            REPID = sy-repid

            DYNNR = sy-dynnr

            SIDE = CL_GUI_DOCKING_CONTAINER=>dock_at_right

            RATIO = 50

          Exceptions

            Others = 1.

 

        Create Object Ref_Media

          Exporting

            PARENT = Ref_Dock

          Exceptions

            Others = 1.

 

        Call Method Ref_Media->setdatasource

          Exporting

            FileName = 'MyMovie.mp4'.

 

        Call Screen 1000.

 

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

 

As you can see, only a selection screen with a dummy parameter, the docking container, the media class and a method call to set the file name property.

 

Now the class for the ActiveX control, in my case the Windows Media Player:

002.JPG

 

"-Begin-----------------------------------------------------------------

 

  Class Z_CL_MEDIA Definition Public Inheriting From CL_GUI_CONTROL

    Final Create Public .

    Public Section.

      Type-Pools CNTL .

      Methods Constructor Importing Parent Type Ref To CL_GUI_CONTAINER.

      Methods Dispatch Redefinition.

      Methods SetDataSource Importing FileName Type String.

  EndClass.

 

  Class Z_CL_MEDIA Implementation.

 

    Method Constructor.

      Call Method Super->constructor

        Exporting

          CLSID = 'MediaPlayer.MediaPlayer'

          PARENT = Parent

          LIFETIME = 2

        Exceptions

          Others = 1.

    EndMethod.

 

    Method Dispatch.

      Call Method CL_GUI_CFW=>Flush.

    EndMethod.

 

    Method SetDataSource.

      Call Method Set_Property

        Exporting

          PROPERTY = 'FileName'

          VALUE = FileName.

      Call Method CL_GUI_CFW=>FLUSH.

    EndMethod.

 

  EndClass.

 

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

 

As you can see, also nothing special. In the constructor method is the name of the ActiveX control (ClassID) defined and the method SetDataSource sets the property FileName of the control.

 

Here now an example result:

003.JPG

With only 53 lines code you can implement the Windows MediaPlayer ActiveX control inside a selection screen.

 

Hint: To analyze the control you can use also COMView, a phantastic tool for viewing Windows COM things.

 

Cheers

Stefan


Viewing all articles
Browse latest Browse all 68

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>