Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
stefan_schnell
Active Contributor


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-------------------------------------------------------------------

 



 

 
"-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.

 



 

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

2 Comments