Show TOC

Adapting the HTML CodeLocate this document in the navigation structure

Use

To merge SAP system screen data dynamically into HTML templates, SAP provides a macro language called HTMLBusiness.

When a user starts a Web transaction from a Web browser, this triggers an Internet Transaction Server (ITS) service, which corresponds to an SAP transaction. For each screen of a SAP transaction, there is an HTML template, which contains standard HTML code and HTMLBusiness statements.

At runtime, the ITS replaces all HTMLBusiness statements with SAP system data, SAP system texts, non-SAP system texts or graphics, dynamically generated URLs, SAP system error messages or standard HTML source code. The complete HTML page is then sent to the Web browser via the ICM.

This section summarizes the main features of HTMLBusiness such as:

  • Embedding HTMLBusiness in standard HTML

  • Field and array replacement

  • if, repeat, and for statements

  • HTMLBusiness functions

Embedding HTMLBusiness in HTML

To enable the ITS to differentiate between HTMLBusiness and standard HTML, you must enclose all HTMLBusiness statements in special delimiters. These delimiters are either the server commands <server> and </server>, or back quotes (`). The back quotes are needed for inserting HTMLBusiness inside HTML tags.

The <server>.....</server> container cannot be nested in another HTML tag. For example, the following statement is invalid:

<a href=<server>.....</server>>

For more information see:

Field and Array Replacement

Replacing Fields

With the exception of reserved keywords, each HTMLBusiness expression is treated as the name of a screen field, and replaced with the value of that field. If the field cannot be found, the ITS generates a runtime error. You can also:

  • Use field contents in simple expressions

    Example: VBCOM-KUNDE >= 1000

  • Limit the number of characters transferred

    Example: VBCOM-KUNDE:2

  • Find out attributes of the SAP system field

    Example: array.dim

For further information, see Referring to SAP System Fields.

Replacing Arrays

The ITS also processes arrays. On the SAP system side, the arrays are either step loops on the screen or tables sent from the screen to the ITS via RFC. You can access individual elements in an array by specifying an index (in angle brackets) after the field name.

Example: array[j]

This assignment is valid for step loop fields in either direction. For further information, see Referring to SAP System Arrays.

IF, REPEAT, and FOR Statements

If you want to replace a field repeatedly, or only under certain conditions, HTMLBusiness provides the following statements:

  • if

  • repeat

  • for

if Statement

Depending on some condition, you may want ITS to insert varying hyperlinks, suppress empty fields or change the arrangement of fields on the screen.

  • if (expr) statements1 else statements2 end
                      
  • if (expr1)statements1
      if (expr2)statements2
        elsif (expr3)statements3
      end
      elsif (expr4)statements4
      else statements1
    end
                      

For further information, see if Statement.

repeat and for Statements

When processing fields that contain several values (such as step loops and internal tables), you must ask the ITS to perform multiple replacements. The repeat and for commands execute a specific sequence of statements several times.

Examples of syntax are:

  • repeat expr times statementend

  • repeat with register in field statement end

  • repeat with indexfield from expr1 to expr2 [by expr3] statement end

  • for( expr1 ; expr2 ; expr3) statement end

For further information, see repeat and for statements.

Expression Evaluation

You can code standard expressions in HTMLBusiness. The ITS evaluates these expressions when executing your if, repeat, and for statements.

For information on expression syntax, see Expressions.

HTMLBusiness Functions

HTML templates with hardcoded URLs or path names to graphics files may not always work correctly when transferred to other systems. HTMLBusiness provides functions that generate URLs and other HTML texts dynamically. You must use these functions to ensure that your templates are correct, regardless of Web server or ITS configuration.

  • assert

    The assert function gets error messages from SAP system. If an error is triggered during an SAP transaction, SAP system determines the field responsible and passes a standard error text to the ITS. The ITS replaces the assert statement with this message text.

  • write and writeENC

    The write function writes field contents and other information to the HTML document.The only difference between write and simple replacement is that write adds no spaces for separating individual values.

    The writeENC function works similarly, except that the output is coded according to URL requirements, so that spaces and special characters are replaced with their hexadecimal code. This function lets you construct URLs correctly from fields that contain spaces and special characters.

  • wgateURL

    This wgateURL function ensures browser independence by generating URLs that dynamically take the location of the Web server into account.

  • mimeURL and imageURL

    The mimeURL function specifies links to static files (for example, graphics and help files) that are to be incorporated in the HTML template at runtime. These files are not stored in the ITS directory but in the HTTP server directory.

    The imageURL function is an older version of mimeURL.

More Information

For further information about HTMLBusiness, see