Start of Content Area

Background documentation Mapping Fields Within a Context  Locate the document in its SAP Library structure

The way in which a message mapping field maps within a context depends on whether it is a structure field or a value field. Structure fields are elements with sub-elements that cannot have their own value. Attributes and elements with a type (“leaf nodes” in the hierarchy) are value fields.

Mapping Structure Fields

The question of whether or not to generate structure fields depends on how often they occur in the target structure and whether a target field mapping has been defined for the structure field. The following table provides an overview of when you have to define target field mappings for structure fields according to the schema definition of the target structure. The mapping editor shows these fields in red.

Target Field Mappings Required for Structure Fields in the Target Structure


Conditions for Generation

n = minOccurs = maxOccurs > 0

Message mapping generates these structure fields automatically because they have to occur n times in the target structure independently of the target field mapping. You can nevertheless assign a target field mapping to such structure fields (for example, by using the standard function createIf() to select the correct source structure field from a selection of several).

minOccurs = 0

The structure field is optional. Whether or not it is generated depends on whether you have assigned a target field mapping to it (for example a structure field of the source structure). Note the following:

·        If you assign a target field mapping to the structure field, you have to do the same for obligatory sub-elements/attributes. If you do not, the message mapping is incomplete (the mapping editor indicates this by showing it in red).

·        If you want to generate optional structure fields it is not sufficient to generate a target field mapping for sub-elements/attributes. The message mapping suppresses optional structure fields (including sub-nodes) without a target field mapping.

The number of times that optional structure fields are generated is bounded by maxOccurs and the target field mapping. The same rules apply here as to value fields (see below).

0 < minOccurs < maxOccurs

You have to define a target field mapping for these structure fields. The number of times that these structure fields are generated depends on minOccurs, maxOccurs and the target field mapping. The same rules apply here as to value fields (see below).

For information on how to transfer structures from the source structure into other structures, see Structure Mapping by Setting the Context.

Occurrence of Value Fields and Structure Fields

Even if a source field in accordance with an XML schema definition is not limited in how often it can occur, it only actually occurs in the XML document for which the message mapping was executed. The target field attributes minOccurs and maxOccurs then determine how often it occurs in the target structure. For the purpose of the statements below, sourceElem is a source structure field and targetElem is a target structure field that is assigned to this field in the mapping editor (without using functions):

·        The targetElem tag with minOccurs=“<n>“ occurs a minimum of <n> times in the target structure. If sourceElem does not occur a sufficient number of times in the source structure, the mapping runtime throws an exception.

·        The targetElem tag with maxOccurs=“<n>“ occurs a maximum of <n> times in the target structure. If sourceElem occurs more frequently in the source structure, values are lost. If it occurs less frequently, then an equal number of target and source fields are generated.


The mapping runtime ignores default values that are contained in the XSD schema for fields.

Generating Functions

The standard functions of the Constants function category do not have an input value. Therefore, they generate a value for a target field instead of taking it from a source field. In addition to these functions, all functions (regardless of whether they are standard or user-defined functions) that do not have input values are referred to as Generating Functions.

If generating functions are assigned to a target field, the attributes minOccurs and maxOccurs determine how frequently a value is generated:

·        If minOccurs = 0 the value of the function is generated once.

·        Otherwise, the value of the function is generated as often as is specified by minOccurs.


This applies regardless of the value set in maxOccurs. Even if maxOccurs = “unbounded“, the mapping runtime will still only generate the value as often as is specified by minOccurs.

If generating functions are assigned to a function, it is the input queue with the most values for the current context that determines how often the generating function generates a value (see also: Processing an Input Queue).





End of Content Area