Skip to Content

Hello community,

 

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.

"-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 = 'file://MyHTML.html'.       "InternetExplorer
            "FileName = 'MyPDF.pdf'.               "Acrobat
            "FileName = 'MyMovie.mp4'.             "Mediaplayer

        Call Screen 1000.

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

 

/wp-content/uploads/2014/08/0032_515118.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 = 'Shell.Explorer'                     "InternetExplorer
          "CLSID = 'AcroPDF.PDF'                       "Acrobat
          "CLSID = 'MediaPlayer.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 = 'Src'                            "Acrobat
          "PROPERTY = 'FileName'                       "MediaPlayer
      "    VALUE = FileName.
      Call Method Call_Method                          "InternetExplorer
        Exporting
          METHOD = 'Navigate'
          P_COUNT = 1
          P1 = FileName.
      Call Method CL_GUI_CFW=>FLUSH.
    EndMethod.

  EndClass.

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

 

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.

 

/wp-content/uploads/2014/08/0033_515119.jpg

 

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

 

Cheers

Stefan

To report this post you need to login first.

2 Comments

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

  1. Balaji Guru

    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?

    Balaji

    (0) 

Leave a Reply