Show TOC

mimeURL FunctionLocate this document in the navigation structure

Use

Purpose

Generates dynamic links to graphics files, based on language and theme.

Syntax

mimeURL ( [ [~service=] expression, ][ [~theme=] expression,] [ [~language=] expression,] [~secure=] expression,] [~name=] expression)

Parameters

Parameter

Meaning

~service

Service.

If omitted, the name of the current service is used.

~theme

Theme.

If omitted, the current theme (defined in the relevant service file) is used. To omit the whole theme part of the URL path, specify ~theme="".

~language

Language.

If omitted, the current language (defined in the relevant service file or using the logon page) is used. To omit the language part of the URL path, specify ~language="".

~secure

Specifies whether a relative or absolute URL should be used.

  • If ~secure is not used at all: mimeURL() creates a relative URL as prior to ITS 2.2.

  • If ~secure="on": mimeURL() creates an absolute URL and uses the protocol type HTTPS. Use this value to switch from HTTP (unsecure) to HTTPS (secure) communication within a running session.

  • If ~secure="off": mimeURL() creates an absolute URL and uses the protocol type HTTP. Use this value to switch from HTTPS (secure) to HTTP (unsecure) communication within a running session.

~name

Name (and optional subdirectories) of the file to be referenced.

Examples are ok.gif or buttons/roundones/cancel.gif.

You can omit parameter names, but this results in less comprehensible function calls. If you do this, the default order is ~service, ~theme, ~language, ~secure, ~name.

All parameters except ~name are optional and are derived from the current session context if not already defined as an argument. Apart from the file name, specify all other parameters relative to the subdirectory within the ITS directory system. mimeURL forms the path name according to the following pattern:

/<Web server root directory>/SAP/ITS/MIMES/<service>/<theme>/<language>/<name>

  • If the ~service, ~theme and ~language parameters are not specified, the corresponding values from the service description are used

  • If you specify the ~ language parameter without a value (that is, ~language= ""), mimeURL uses the files in the parent theme directory

    This allows you to access language independent files.

Description

You use the mimeURL function to specify links to static files such as graphics and help files that are incorporated into the HTML templates at runtime. These files are stored in the Web server directory, not in the ITS directory.

You cannot use a simple relative URL for this purpose. You must use a URL containing parameters that assign the static file to a specific service, theme and language.

The mimeURL function is intended to replace the imageURL function. mimeURL provides more flexible and easier access to service-, language-, and theme-dependent files like images, sounds and other multimedia data (hence the name m imeURL).

Apart from addressing specific service files, you can use the mimeURL function to address global service files using the ~service ="global" parameter.

The values assigned to the parameters are taken without checks from the ITS to make up the URL. You can thus create further subdirectories linked to the MIMES directory which are addressed via the mimeURL function.

Example

The following example illustrates the use of mimeURL.

If ~URLmime is set to /sap/its/mimes, the current service is vw01, the current language is EN and the current theme is 99, calling mimeURL () results in output as specified below:

  1. <img src="`mimeURL(~name="ok.gif")`">

    results in:

    <img src="/sap/its/mimes/vw01/99/EN/ok.gif">

  2. <img src="`mimeURL(~service="global", ~name="ok.gif")`">

    results in:

    <img src="/sap/its/mimes/global/99/EN/ok.gif">

  3. <img src="`mimeURL("", ~name="buttons/ok.gif")`">

    results in:

    <img src="/sap/its/mimes/99/EN/buttons/ok.gif">

  4. <img src="`mimeURL("","buttons/roundones/ok.gif")`">

    results in:

    <img src="/sap/its/mimes/99/EN/buttons/roundones/ok.gif">

  5. <img src="`mimeURL("", 1, "buttons/roundones/ok.gif")`">

    results in:

    <img src="/sap/its/mimes/1/EN/buttons/roundones/ok.gif">

  6. <img src="`mimeURL("global", 1, "DE", "buttons/roundones/ok.gif")`">

    results in:

    <img src="/sap/its/mimes/global/1/DE/buttons/roundones/ok.gif">

  7. <img src="`mimeURL(~service="system", ~name="ok.gif", 1, "")`">

    results in:

    <img src="/sap/its/mimes/system/1/ok.gif">

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:

  • <img src="`mimeURL(~name="ok.gif")`">

    expands to

    <img src="/sap/its/mimes/vw01/99/EN/ok.gif">

  • <img src="`mimeURL(~name="ok.gif", ~secure="on")`">

    expands to

    <img src="https://myHost:443/sap/its/mimes/vw01/99/EN/ok.gif">

  • <img src="`mimeURL(~name="ok.gif", ~secure="off")`">

    expands to

    <img src="http://myHost/sap/its/mimes/vw01/99/EN/ok.gif">

  • <img src="`mimeURL(~name="ok.gif", ~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.