Show TOC

wgateURL FunctionLocate this document in the navigation structure

Use

Purpose

Generates URLs that are compatible with the current Web server.

Syntax

wgateURL(parameter = expression {, parameter = expression})
            

Parameters

Parameter

Meaning

~OkCode

Function code to be triggered in SAP transaction.

~target

Name of target frame in a <form> command.

The response to this request appears in the target frame. For full details on using ~target, see Web Browser Independence.

(From ITS 2.2, ~target replaces ~forceTarget.)

~forceTarget

No longer supported.

(From ITS 2.2, use ~target for all browsers.)

~FrameName

Determines URL of a frame in a frame set document.

~secure

Specifies whether a relative or absolute URL should be used:

If ~secure is not used at all:

wgateURL() creates a relative URL as prior to ITS 2.2.

If ~secure="on":

wgateURL() creates an absolute URL and uses the protocol type HTTPS.

Use this value to switch from HTTP (unsecure) to HTTPS (secure) communication within a session.

If ~secure="off":

wgateURL() creates an absolute URL and uses the protocol type HTTP.

Use this value to switch from HTTPS (secure) to HTTP (unsecure) communication within a session.

Screen field name

Fills screen fields in target frame.

Description

This function dynamically generates URLs that agree with the system information for the current Web server. In this way, you can avoid hard-coding URLs in a template and produce HTML templates that are easily portable between servers.

In addition to including system information (such as the ~state field), the wgateURL function also encodes all parameters according to URL requirements. (For details, see writeEnc Function).

Use wgateURL in the following three cases:

  • In <form> commands, you need to specify the URL of the program that will process the contents of the form. This path depends on your ITS installation type and therefore needs to be determined dynamically.

  • When you are using a transaction with several frames, this function gives the target frame. In this case, the URL of the ITS needs to be generated and additional parameters merged with it.

  • Within a frame set document, this function gives the URL for a frame.

Creating Anchors in the URL

Use the ~anchor parameter to generate an HTML anchor in the wgate URL:

<form method="POST" action="`wgateURL(~anchor="footer")`">

This is expanded to:

<form method="POST" action="/scripts/wgate.dll/vw01#footer">

Examples

The following example illustrates the use of mimeURL.

<ul>   `repeat with j from 1 to xlist-matnr.dim`
 <li>
  <a href="`wgateURL(matnr=xlist-matnr[j],
        quantity=xlist-kwmeng[j])`">
        `xlist-matbez[j]`
  </a>
 </li>   `end`
</ul>
            

This HTML template would be expanded as follows:

<ul>
 <li>
   <a href="http://pn0208/scripts/wgate.dll/vw01?~State=4711&matnr=9132&quantity=2"> Microsoft Word Update
   </a>
  </li>
  <li>
   <a  href="http://pn0208/scripts/wgate.dll/vw01?~State=4711&matnr=9133&quantity=1"> Microsoft Excel Update 
   </a>
  </li>
</ul>
            

Note

Always make sure that the value of href is enclosed in double quotation marks (").

Using the ~secure Parameter

To query whether the current request is using HTTP or HTTPS, you can use the system variable ~http_https.

  • For HTTP, ~http_https="off"

  • For HTTPS, ~http_https="on"

The following are examples of how to use the ~secure parameter:

  • <a href="`wgateURL(~okcode="back")`"> expands to <a href="/scripts/wgate/vw01/~sd..f?~okcode=back">

  • <a href="`wgateURL(~okcode="back", ~secure="on")`"> expands to <a href="https://myHost:444/scripts/wgate/vw01/~sd..f?~okcode=back">

  • <a href="`wgateURL(~okcode="back", ~secure="off")`"> expands to <a href="http://myHost:1080/scripts/wgate/vw01/~sd..f?~okcode=back">

  • <a href="`wgateURL(~okcode="back", ~secure=~http_https)`"> expands to either the HTTP or the HTTPS variant, depending on the protocol type of the current request

The ~secure parameter requires additional information in the service file (<service>.srvc), usually the global service file global.srvc:

System Parameter

Description

~hostSecure

Host name and domain of the Web server to be used for secure requests (HTTPS).

If not specified, this parameter defaults to ~hostUnsecure.

~portSecure

Port number to be used for secure requests (HTTPS).

If not specified, this parameter defaults to 443 (standard HTTPS port).

~hostUnsecure

Host name and domain of the Web server to be used for unsecure requests (HTTP).

If not specified, this parameter defaults to ~http_host from the current request HTTP header.

~portUnsecure

Port number to be used for unsecure requests (HTTP).

If not specified, this parameter defaults to 80 (standard HTTP port).

From ITS 2.2, these system parameters are added to the global service file global.srvc.