Show TOC Entering content frame

WWW_HTML_MERGER Locate the document in its SAP Library structure

Description

The function module WWW_HTML_MERGER replaces placeholders in HTML templates with data. Use this function module instead of retrieving templates from table WWWDATA and replacing the placeholders directly in the code.

Note

The way in which templates are stored in a database may change in future SAP system releases.

Interface

Interface of WWW_HTML_MERGER

IMPORTING parameters

Function

TEMPLATE

Template ID in WWWDATA.

MERGE_TABLE

Table to merge with template.

MERGE_TEXTPOOL

Text pool.

 

 

EXPORTING parameters

Function

HTML_TABLE

The resulting HTML.

Any function module that calls WWW_HTML_MERGER must:

·        Pass the template name

·        Specify the table where the resulting HTML document is to be placed

·        Pass the placeholders and generated HTML code to the MERGE_TABLE parameter

WWW_HTML_MERGER loads the template from the database. For each row in the MERGE_TABLE, it looks for the specified placeholder starting from the beginning of the template:

·        If the placeholder is found, WWW_HTML_MERGER inserts the HTML code contained in the html field (actually a table) into the template.

·        If the placeholder is not found, WWW_HTML_MERGER skips to the next row in the MERGE_TABLE.

It is possible to have both multiple rows containing the same placeholder name in MERGE_TABLE and multiple occurrences of the same placeholder in a template.

Note

The operation of MERGE_TABLE is governed by the following rules:

§         Any placeholders not specified in MERGE_TABLE are not replaced with data

§         The HTML code for placeholders not specified in a template does not appear in a resulting HTML document

MERGE_TABLE Parameter

Structure of MERGE_TABLE Parameter

Field name

Field type

Description

Example

Name

char(30)

Placeholder value.

<!myplaceholder!>

Command

char(1)

Defines how to replace placeholder.

See table of commands below.

Html

table

Table containing HTML code that will replace placeholder.

‘Incoming Orders’

‘For customers’

Note

The field html is a table with one column of type char(255). This table can contain multiple lines of HTML code that are all replaced for this placeholder.

Suppose you have a template that contains the following lines:

 

 (line before)

Report: <!myplaceholder!>

 (line after)

...

You also have a row in the MERGE_TABLE that contains values shown in the table above.

The resulting HTML document is shown in the following table:

Command

Description

Appearance of resulting HTML document

space

Replace placeholder line (default).

...
(line before)
Incoming Orders
For customers
(line after)
...

B

Insert before placeholder line.

...
(line before)
Incoming Orders
For customers
Report:
<!myplaceholder!>
(line after)
...

A

Insert after placeholder line.

...
(line before)
Report:
<!myplaceholder!>
Incoming Orders
For customers
(line after)
...

R

Replace placeholder only.

...
(line before)
Report: Incoming Orders
(line after)
...

MERGE_TEXTPOOL Parameter

The MERGE_TEXTPOOL parameter allows you to pass text elements for insertion into templates.

In ABAP, texts displayed on the screen are stored as text elements in text pools, not in the programs themselves. This means that when you change texts, you do not have to change the program code, only the relevant text elements. It also means that you can develop programs in several languages because the translation of the texts is a separate process. In the program itself, you merely specify the names of the text elements (for example, TEXT-<xxx>, where xxxrepresents any combination of letters and digits).

If you pass text elements in the MERGE_TEXTPOOL parameter for insertion into a template, WWW_HTML_MERGER:

...

       1.      Looks for any occurrences of <!text-xxx!> in the template

       2.      Replaces them with the text elements of the text pool specified in the MERGE_TEXTPOOL parameter.

 

Leaving content frame