Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

JavaScript in ABAP Program

0 Kudos
1,101

hi folk,

I have some Javascript codes in my abap program as you can see below.

It does simple not work for me.

But in the debugger mode as I can see the message it says something about:

" ReferenceError: ActiveX Object is not defined "

It has something with Acticve XObject. What am I missing here? Do I need install any additional component?

data JS_CODE type STRING.

data RETURN_JS_VAR type STRING.

data JS_PROC type ref to CL_JAVA_SCRIPT.

JS_PROC = CL_JAVA_SCRIPT=>CREATE( ).

concatenate

'var filePath = "C:
Windows
notepad.exe"; '

'set fso = CreateObject("Scripting.FileSystemObject");'

'var string = fso.GetFileVersion(filePath); '

'function Set_String() '

' { string += ", this is a Blog!"; '

' } '

'Set_String(); '

'string; '

into JS_CODE separated by CL_ABAP_CHAR_UTILITIES=>CR_LF.

JS_PROC->COMPILE( SCRIPT_NAME = 'GETVERSION.JS'

SCRIPT = JS_CODE ).

RETURN_JS_VAR = JS_PROC->EXECUTE( 'GETVERSION.JS' ).

write RETURN_JS_VAR.

5 REPLIES 5

former_member182670
Contributor
0 Kudos
332

You are trying to create object "Scripting.FileSystemObject" which is an ActiveX.

Clemenss
Active Contributor
0 Kudos
332

Hi Ngoc Linh Nguyen,

correct me if I'm wrong: Javascript is used for handling in context with HTML web pages. The code is interpreted by java runtime system installed at frontend.

We created a HTML viewer (CL_GUI_HTML_VIEWER[?]) in a GUI control area. Here we could display an HTML table and react to mouse clicks interpreted by javascript code.

If it helps, I'd search for the code...

Regards,

Clemens

0 Kudos
332

hi Clemens,

SAP doesn't allow me to create an Active X Object which means I can not access to those medthods within the object itself and my program is running in an user exit and it has nothing to display e.g. html viewer. So what is your suggestions it I want to get access to the methods?

Best regards

LNN

0 Kudos
332

Could explain what is the context and business requirement? Maybe having a bigger picture we could propose a different or easier way to achieve the same goal.

Interacting with client OS file system via ABAP->js->activeX looks a bit odd.

Even in the browser you'd probably have problem with this code as running Scripting.FileSystemObject requires lowered Internet security options which is a no-go for many customers.

0 Kudos
332

hi Tomek,

You have absolutely right regarding the security and the problem by using of Active X Object.

My goal was to get the file version from the user's PC and at the beginning I used the method

CL_GUI_FRONTEND_SERVICES->FILE_GET_VERSION but it doesn't work out. So I tried to get the version via Active X Object and it doesn't work either.

Now I've found this function GUI_GET_FILE_INFO and it works perfectly even though it tells me that the function is absolete and suggest to use the method FILE_GET_VERSION instead.

Best regards

LNN