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:

/wp-content/uploads/2014/08/001_514276.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

To report this post you need to login first.

4 Comments

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

  1. Naimesh Patel

    Hello Stefan,

    Thanks for sharing the article.

    I wonder many times about the existing ActiveX controls. I can view the existing methods using the ActiveXplorer but don’t know if I can get the full coding of the controls. Is COMView able to show that?

    Thanks,
    Naimesh Patel

    (0) 
    1. Stefan Schnell Post author

      Hello Naimesh,

      thanks for your reply.

      No, COMView works like ActiveXplorer, it shows the interface of the library – the methods and attributes, not more and not less. How to use the control is normally part of the technical documentation of the manufacturer.

      Cheers

      Stefan

      (0) 
    1. Stefan Schnell Post author

      Hello Ashish,

      thanks for your reply and your addition. It is interesting to see how programmers come to similar solutions independently.

      Cheers

      Stefan

      (0) 

Leave a Reply