Script Assistant

Related Topics

The Script Assistant improves scripting syntax accuracy and reinforces lessons on the SAP xMII Applet Object Model. You are provided with an exploration experience of events, method calls, and properties. The tool interactively creates stub function calls based on user selections.

Benefits

The Script Assistant can be launched from Microsoft® FrontPage® once the FrontPage add-in has been properly installed. The FrontPage plug-in works in conjunction with previously created .html or .irpt pages by extracting existing page applet definitions and populating the tool with appropriate events and methods. In contrast, the standalone version retrieves default applet definitions, helping the user create syntactically correct code that can be copied and pasted into any HTML editor.

If you created two SAP xMII applets on a page and call the Script Assistant from the Tools menu, you have the ability to script a single applet or link one applet event to another applet. The Target Applet drop-down list allows you to select any applet on the current page. You can then select the desired event of the target applet from the Target Event drop-down list. The Function Name is used to create the actual JavaScript function and is linked to the target applet event that you chose.

You can then select the applet to which you want to link. It can be the same applet as the target or it can be any other applet on the page. For example, you want to create a JavaScript function named BatchList_Selected. In the example, the target applet is the BatchList. On a selection event from the BatchList applet, you want to change a parameter in the BatchTrend applet so the currently selected batch in the list is the one shown in the trend applet. In the Applet drop-down list, choose the BatchTrend applet. In the Applet Method drop-down list, select getQueryObject() because you want to set a query parameter. Choose setParam method to set Param.1 to a specific value (the batch number of the selected row in the BatchList applet) and update the trend.

Press the Insert key to insert a specific applet.object.method into the text area shown. You can continue to select different applets, objects, and methods from the Applet, Applet Method, and Object Method drop-down lists, and insert syntactically correct script. You can also manually edit the script in the text area  or create it on the page and edit it within the HTML view.

When you press the Save Script button, it creates a function (a function named BatchList_Selected), inputs a parameter into the BatchList applet definition linking the selection event to the BatchList_Selected function, and inserts the JavaScript text into the script block.

The standalone version displays only default applet definitions and is not capable of referencing specific applets in the targeted drop-down list boxes. Its primary use is a quick lookup of the proper syntax for applet methods, as shown below. You can input as many methods as you like, and when you click the Save Script button, it saves the text in the text area to the clipboard from which you can then paste the JavaScript text into any HTML editor.

Script Assistant User Control Definitions

Control Name

Description

Tool Usage

Notes

Target Applet

Host applet name

FrontPage only

Lists all of the applet names that are found on the open .html or .irpt page

Target Event

Host applet event

FrontPage only

Lists all of the supported events for the applet selected in the Target Applet control

Function Name

Host applet function

FrontPage only

Displays the function name that is created by the Script Assistant after the Target Event is selected. It is the name of the function that is inserted into the .html or .irpt page by the tool.

Applet

Applet name

FrontPage or standalone

When used in FrontPage, this control lists only the applet names found in the open Web page. When run as a standalone application, this control lists all SAP xMII applet types.

Applet Method

Applet method's name

FrontPage or Standalone

Lists all of the base applet methods that apply to the type of applet selected in the Applet control. This method is inserted into the text area by the tool when you click the Insert button.

Object Method

Object method's name

FrontPage or standalone

Lists the object method names that apply to the selected applet method. It is only possible if the object method is supported by the applet. The completed expression is inserted into the text area by the tool when you click the Insert button.

Insert

Insert button

FrontPage or standalone

Inserts the selected applet method call into the text area immediately after the cursor

Include Document Object Reference

Auto-prefix document object reference

FrontPage or standalone

If this parameter is selected, the tool adds the document object as a prefix to the applet name. Choose this option before clicking on the Insert button. It is used to properly reference an applet or a control on the page. We recommend that the document object use a prefix whenever possible. For example, an applet method is typically in the following format: document.BatchTrend.getQueryObject();
where the "document." is the document object prefix.

Save Script

Save Script button

FrontPage or standalone

Copies the text in the editor to the paste buffer if the tool is standalone. In the case of the FrontPage plug-in, the text in the editor box is inserted into the corresponding function name and the target applet has a new parameter name-value added referencing the new script function.

Delete Script

Delete Script button

FrontPage only

Removes the script block and applet's function reference defined by the combination of the selected items found in the Target Applet and Target Event controls.

 

Script Assistant Example

To illustrate how the Script Assistant might be used, consider an .html page that contains the familiar BatchTrend chart and the BatchList applets. The applet definition for the BatchTrend applet is as follows:

<APPLET NAME="BatchTrend" WIDTH="715" HEIGHT="45" CODE="iGrid" CODEBASE="/Illuminator/Classes" ARCHIVE="illum8.zip" MAYSCRIPT>

<PARAM NAME="QueryTemplate" VALUE="Training/BatchTrendQuery">

<PARAM NAME="DisplayTemplate" VALUE="Training/BatchTrendChart">

</APPLET>

and the applet definition for the BatchList applet is as follows: 

<APPLET NAME="BatchList" WIDTH="715" HEIGHT="45" CODE="iGrid" CODEBASE="/Illuminator/Classes" ARCHIVE="illum8.zip" MAYSCRIPT>

<PARAM NAME="QueryTemplate" VALUE="Training/BatchListQuery">

<PARAM NAME="DisplayTemplate" VALUE="Training/BatchListGrid">

</APPLET>

Assume you launch the Script Assistant and make the necessary selections. Select the BatchList applet as a host target. It uses SelectionEvent to call the BatchList_Selected function. Choose the BatchTrend applet, the getQueryObject() object, and a corresponding setParam(Index, Value) object method. When you click the Insert button, the document.BatchTrend.getQueryObject().setParam(INDEX, NEWVALUE); expression is inserted into the editor's text box. When you click the Save Script button, the following changes are made to the applet and the JavaScript.

A new function is created. Note that the function is placed in the head section of the Web page, inside its own script block with a unique ID.

<SCRIPT Language="JavaScript" id="BatchList_Updated">

 

function BatchList_Selected() {

document.BatchTrend.getQueryObject().setParam(INDEX, NEWVALUE);

}

</SCRIPT>

The BatchList applet is changed to include an additional parameter name-value pair with Name=SelectionEvent, shown below immediately before the </Applet> tag:

<APPLET NAME="BatchList" WIDTH="715" HEIGHT="45" CODE="iGrid" CODEBASE="/Illuminator/Classes" ARCHIVE="illum8.zip" MAYSCRIPT>

<PARAM NAME="QueryTemplate" VALUE="Training/BatchListQuery">

<PARAM NAME="DisplayTemplate" VALUE="Training/BatchListGrid">

<PARAM NAME="SelectionEvent" VALUE="BatchList_Selected">

</APPLET>

This is a simple example and needs additional logic to be functional; however, it shows the power of the Script Assistant when it is used within FrontPage. Many typographical errors can be automatically eliminated. There is no need to look up specific syntax. This tool helps the developer properly code to the SAP xMII object model. While it does not develop the complete code, it does make the syntax for methods, events, and function calls as easy as point and click. The productivity of the Web page developer can be greatly enhanced by taking advantage of this tool.

Query Error Handling Example

You can use the following object methods to provide query status:

 

For a detailed description of the applets, please see the Applet General Reference and the Applet Object Model Reference. Also, you can refer to the Web Scripting with SAP xMII Objects topic.