Author Topic: Making System Calls with WS  (Read 3965 times)

Sai Siddhartha

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 47
    • View Profile
Making System Calls with WS
« on: July 13, 2017, 08:27:14 AM »
Purpose:

Making system calls using WS custom functions.

Prerequisite:

wsoffice.dll

Usage:

The ActiveXObject adds support for the Microsoft COM objects. It enables user to make calls to a user local file system among other useful actions.The ActiveXObject requires the wsoffice.dll installed along with WS, it has function call methods from Microsoft office to perform various tasks.

Using ActiveXObject and wsoffice.dll we can create a custom function to make system calls.

In the following example, we are creating a pushbutton on a SAP screen. The pushbutton will call a function that contains an ActiveXObject. When the toolbar pushbutton is clicked, the function will proceed to make a call to the local file system that will result in a pre-specified file being moved from its original location to a new location. TO demonstrate this, please do the following:

1.Log into SAP and go to the Easy Access screen.
2.Open the 'SAPLSMTR_NAVIGATION.E0100.sjs' script file. Create the file if it does not exist. First, create a toolbar pushbutton with the following code:

   pushbutton([TOOLBAR], "Move File    ",{ "process":MoveFile});

3.Create a function that the pushbutton will call.
   An example is shown below:

   function MoveFile(){ 
         load("wsoffice.dll"); 
         var objCopy, test; 
          //Creates ActiveXObject for file system object
         objCopy = new ActiveXObject("Scripting.FileSystemObject"); 
         test = objCopy.GetFile("C:\\guixt\\test.txt"); 
         test.Move("C:\\LiquidUI\\test_moved.txt");
   }

4.   Save your changes and click the toolbar pushbutton to initiate the function.

In the preceding function, we have created a new ActiveXObject named 'objCopy', which now allows us to make calls to the file system through the WSOffice DLL. Methods of this new object are then utilized to get a specified file. A method of the new object is then utilized to move the file to a new location(LiquidUI folder) with new name(test_moved.txt).

Note: In order to use wsoffice.dll features, we need to add following code is included in the script immediately before the new ActiveXObject variable is created.
load("wsoffice.dll");


see attachment for screenshots