Skip to Content
Technical Articles

Tip: Easy Way of ABAP ActiveX Connectivity (Addendum)

I presented here an approach for an easy way to use ActiveX controls inside ABAP. I got a few e-mails with questions about the possibility to use different ActiveX control. Here now other examples to show that it isn’t only easy, it is also very flexible.

Here now two little modifications to use the Acrobat PDF control and the Internet Explorer control – changes are marked in red.

  Program Z_TEST.

      Data Ref_Dock Type Ref To CL_GUI_DOCKING_CONTAINER.
      Data Ref_Media Type Ref To Z_CL_MEDIA.

      Selection-Screen Begin Of Block Media.
        Parameters pa_Dummy(1).
      Selection-Screen End Of Block Media.

      At Selection-Screen.

        Create Object Ref_Dock
            REPID = sy-repid
            DYNNR = sy-dynnr
            SIDE = CL_GUI_DOCKING_CONTAINER=>dock_at_right
            RATIO = 50
            Others = 1.

        Create Object Ref_Media
            PARENT = Ref_Dock
            Others = 1.

        Call Method Ref_Media->setdatasource
            FileName = 'file://MyHTML.html'.       "InternetExplorer
            "FileName = 'MyPDF.pdf'.               "Acrobat
            "FileName = 'MyMovie.mp4'.             "Mediaplayer

        Call Screen 1000.







  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.

  Class Z_CL_MEDIA Implementation.

    Method Constructor.
      Call Method Super->constructor
          CLSID = 'Shell.Explorer'                     "InternetExplorer
          "CLSID = 'AcroPDF.PDF'                       "Acrobat
          "CLSID = 'MediaPlayer.MediaPlayer'           "MediaPlayer
          PARENT = Parent
          LIFETIME = 2
          Others = 1.

    Method Dispatch.
      Call Method CL_GUI_CFW=>Flush.
    Method SetDataSource.
      "Call Method Set_Property
      "  Exporting
          "PROPERTY = 'Src'                            "Acrobat
          "PROPERTY = 'FileName'                       "MediaPlayer
      "    VALUE = FileName.
      Call Method Call_Method                          "InternetExplorer
          METHOD = 'Navigate'
          P_COUNT = 1
          P1 = FileName.
      Call Method CL_GUI_CFW=>FLUSH.




As you can see you must change of course the ClassID of the control and also the property resp. method to open the document. Acrobat uses the property Src and Internet Explorer uses the method Navigate.




With a little bit more than 50 lines of ABAP code you can create interesting applications.

You must be Logged on to comment or reply to a post.
  • Hello Stefan,

    Looks interesting. So with this enabling Active-X control in SAP ABAP System we can view any pdf documents in our SAP?

    I am quite not able to understand the catch here..

    Thanks in advance. I am looking for option to open and process PDF in ABAP without Adobe document services, will the above functionality help?