Prerequisites
- Products: Liquid UI WS, Liquid UI Server or Local DLL, Client Software
- Commands: load(), del(), set(), pushbutton(), return()
Purpose
This article demonstrates how to create a custom function that enables users to launch a specific application. This is particularly helpful when selecting an Excel, Word, or PDF file for transferring data in bulk to SAP through WS Office.
This is demonstrated using the SAP Easy Access screen and will guide you through the following steps.
- Delete the Image Container on the SAP Easy Access screen
- Add a pushbutton to open the Excel file
- Add a startAppExcel function
- Add a ReadDirectory function
- Add a startApplication function
User Interface
//Create this file inside your script folder for customizing the SAP Easy Access screen, SAPLSMTR_NAVIGATION.E0100.sjs
//Now, let's add the Liquid UI script to the above file and save it.
Customization
- Delete the image container on the SAP Easy Access screen using del().
// Deletes an image container on SAP Easy Access screen del("X[IMAGE_CONTAINER]");
- Add a push button labeled Start Open Excel File that executes the startAppExcel process on click.
// Creates a push button labeled Start Open Excel File and executes the startAppExcel process on click. pushbutton([6,1], "Start Open Excel File", "/0", {"process":startAppExcel});
- Add a startAppExcel function that calls the readDirectory custom function, which defines dialog box attributes and displays them.
//Function to call the directory function startAppExcel(){ load("wsoffice.dll"); var dirName = ""; var fileName = ["Integrated Steel Plant Info.xlsx"]; dirName = readDirectory(0,"Please select a directory",0); set('V[z_search]', dirName); startApplication(z_search + "\\" + fileName[0]); }
- Add a readDirectory custom function, to read the file directory path of a selected file.
// Function to read the directory function readDirectory(wHnd,strTitle,iOptions){ //This function is for selecting a directory //BIF_browseincludefiles //the use of this option enables the selection of file in select directory dialog box var aWshShell = new ActiveXObject("Shell.Application"); var objFolder = aWshShell.BrowseForFolder(wHnd, strTitle, iOptions); objFolder = objFolder.ParentFolder.ParseName(objFolder.Title).Path; println("-------Specified Directory--------" + objFolder + "--------"); aWshShell = void 0; return objFolder; }
- Add a startApplication function to launch an application with ActiveXObject.
// Function to launch the application function startApplication(strFile,strParamStr){ //This function is for starting an application with parameters if specified var aWshShell = new ActiveXObject("WScript.Shell"); if (strParamStr != null) strFile = strFile + " -" + strParamStr; aWshShell.run(strFile); }
SAP Process
- Refresh the SAP Easy Access screen and click the Start Open Excel File push button. This action displays a Browse For Folder dialog window. Now select an Excel file and click OK.
- Once the file is found, the application will be launched successfully, as shown below.