Show TOC Entering content frame

Background documentation JavaScript in Web Requests Locate the document in its SAP Library structure

The following are examples of uses of JavaScript in the layout of the Business Server pages (BSPs) for Web requests:

 

Calling from JavaScript in the Layout

The following example shows how JavaScript is called when a request is sent:

 

<FORM name=TheHTMLForm method=post onSubmit=”return chkFormular()” >

 

Calling JavaScript when clicking the button Send Request:

 

<INPUT type=submit value=“Submit Request“ name=”onInputProcessing(SUBMIT)” onClick=”return chkFormular()” >

 

In this case, JavaScript is first run with each event and then the BSP event is branched to. Links to other pages can also be used, however you should try to display these pages in a dialog box in order to avoid terminating the navigation.

 

Force round trip with JavaScript

There are cases when a round trip should be carried out using JavaScript and not by double clicking. An example of this is navigating in a BAdI using a specific JavaScript Event. This is programmed for the business partner search in the Sample request SAP_DEMO02 as an example. The BSP application for the business partner search is started in a new dialog box using JavaScript. If the BP entry is selected from the hit list, the data is transferred to the request form and a ‘Submit’ is triggered with the event SEARCH that preassigns the data of the business partner found.

A hidden field with the name "mode" is used for this in the layout.

 

<input name="mode" type="hidden" />

 

The round trip is carried out in JavaScript with “Submit” with this hidden field:

 

document.forms[0].elements ["mode"].name = "onInputProcessing(SEARCH)";

document.forms[0].submit();

 

Use Fields in JavaScript

Calling fields in JavaScript can cause problems as the names of the fields are defined as XPath in the XML request data structure (recognizable by „ / “ separated subnodes).  If you have a problem like this, you can call the fields of the request data structure using the following syntax:

 

document.forms[0].elements["//request/car/length"].value = 1;

 

Or an even better solution would be to use the generated ID:

 

document.getElementById('length').value = 1;

 

 

Leaving content frame