Show TOC Start of Content Area

Background documentation Structure Mapping by Setting the Context  Locate the document in its SAP Library structure

In the default setting, each field is in the context of the higher-level field.

This graphic is explained in the accompanying text

Fix and Foxy are in the first flat context, Jolly Jumper and Lucky Luke are in the second, and all four are in the first street context. The first <street> field is in the first city context and so on.

Let us assume that you want to map this structure to the following list to include all those people from the first city and the first street:

<personList minOccurs=”1” maxOccurs=”1”>
  <person minOccurs=“0” maxOccurs=”unbounded“>

Note

The root node (in this case <personList>) always appears exactly once. This is displayed explicitly in the target structure.

You want to list all four people from the first street context (Fix, Foxy, Lucky Luke, and Jolly Jumper). Define a target field mapping for <person>:

\personList\person=\root\city\street\flat\person

This XML instance produces the following result:

<personList>
   <person> Fix </person>
   <person> Foxy </person>
</personList>

It only generates Fix and Foxy from the first flat context. To understand why this is the case, we can look at the processing:

...

       1.      The root node <personList> is generated because it is obligatory.

       2.      The message mapping checks in the <personList> context whether there is a target field mapping for \personList\person and whether there are values for this in the XML instance. The mapped \root\city\street\flat\person field is in the first flat context.

       3.      The message mapping generates fields in the target structure for Fix and Foxy in the first flat context. Once the first flat context has been processed it is closed along with the <personList> context in the target structure.

The transformation is completed with the last step because all target structure fields have been processed. The example shows the following:

·        The <flat> structure node is implicitly assigned to the <personList> root node during mapping. <personList> is generated as often as is predefined in the schema, therefore once (see also: Mapping Fields Within a Context).

·        The list only includes Fix and Foxy because they are in a different context to Jolly Jumper and Lucky Luke.

You can set the context individually for each field in the source structure in the Data-Flow Editor context menu. If you set the <street> context for \root\city\street\flat\person, then prior to the mapping, all <person> fields are appended to the next highest field, which is <street>. Depending on how you set the context in the source structure, you will get the following results:

Structure Mappings Using Different Contexts of the <Person> Source Field

Context of \root\city\street\flat\person

Results list

flat (default setting)

<personList>
   <person> Fix </person>
   <person> Foxy </person>
</personList>

street

<personList>
   <person> Fix </person>
   <person> Foxy </person>
   <person> Jolly Jumper </person>
   <person> Lucky Luke </person>
</personList>

city

<personList>
   <person> Fix </person>
   <person> Foxy </person>
   <person> Jolly Jumper </person>
   <person> Lucky Luke </person>
   <person> Asterix </person>
   <person> Obelix </person>
</personList>

root

<personList>
   <person> Fix </person>
   <person> Foxy </person>
   <person> Jolly Jumper </person>
   <person> Lucky Luke </person>
   <person> Asterix </person>
   <person> Obelix </person>
   <person> Valerian </person>
</personList>

Note

The removeContexts() standard function assigns the fields assigned to it to the root node. You will get the same effect if you assign the root context to this type of field.

Note

The higher-level context of an attribute is the element to which it is assigned. The above statements relating to fields also apply to attributes.

Technically speaking, the XML instance is imported into the queues before the target field mappings are processed. The contexts are separated in the queue by a context change. You can address these queues directly in advanced user-defined functions.

 

 

 

 

 

End of Content Area