Creating a Transformation for a Hierarchy
You can flexibly load hierarchies by using transformations. You can also make unlimited use of the transformation functions when working with hierarchies. Every field in the hierarchy structure can be transformed. This includes normal InfoObjects as well as special InfoObjects in the hierarchies (such as NODEID). Hierarchies can be loaded from any source. You can also load hierarchies from DataStore objects or InfoCubes. The data has to be converted to the required form (using a start, end or expert routine if necessary).
When flexible loading is used, the hierarchies are usually loaded in multiple segments. It might be necessary to load the hierarchy without segmenting it however. This can be done by selecting the option Hierarchy (One Segment). This is necessary for updating hierarchies to an open hub destination for example. In this case, the hierarchy has a format similar to a flat file and can be loaded into other systems using the open hub destination.
Special features for the transformation of hierarchies:
-
Target segment for level texts:
A target segment is available for level texts. This allows you to create or change texts for hierarchy levels. No segment for level texts exists in hierarchy DataSources. Therefore normal mapping is not possible. The fields are not filled or have to be filled by a routine (start, end or expert routine).
-
When assigning the fields in the hierarchy header, we recommend setting InfoObject 0H_NORESTNO (Display Assigned Nodes Only) to 'X' using a constant. This means that non-assigned nodes (attribute values that occur in the attribute table of the InfoObject but not in the hierarchy) are not saved in the hierarchy SID table and do not have to be loaded into memory at runtime. This can help to achieve significantly improved performance.
-
Dependencies of transfer method:
The appearance of the source structure in the transformation depends on whether the DataSource loads using the transfer method PSA or IDoc. In both cases, it is possible to load using the PSA and use transformation and DTP. The following differences exist in the hierarchy structure however:
-
IDoc format:
This format is used for many SAP standard hierarchy DataSources from SAP systems. This format is also often used for files and BAPI DataSources.
The node segment contains the fields IOBJNM and NODENAME. The name of the InfoObject, for example 0MATERIAL, is entered in the field IOBJNM. This field should be mapped to the InfoObject 0H_IOBJNM of the target hierarchy structure. You may have to adjust the name (for example, using a routine or formula) if no content InfoObjects are used (ZCOSTCENTER for example). The NODENAME field contains the value of the specified InfoObject. This value must be applied to the target InfoObject in the hierarchy structure, ZCOSTCENTER for example. As NODENAME contains the values of all InfoObjects, it is normally possible to perform simple 1:1 mapping to the target InfoObjects. This does not work if the compound length in the source system is different to the length in the target system. In this case, you need to create a routine.
If this not the case, choose rule type Hierarchy Split. With non-compound characteristics, you can also use rule type Direct Assignment.
Intervals in IDOC format: The interval segment in IDoc format is not compatible with the interval segment of the target structure. You therefore need to create a start routine that writes the From value of the interval to the node structure segment. The corresponding function call is created by default as a comment in a new start routine. You simply have to remove the comments and enter the correct source field of the hierarchy basis characteristic. In the interval segment you assign the LEAFTO field to the corresponding target InfoObjects. Note: The LEAFFROM field cannot be used.
-
PSA format:
The hierarchy source structure contains the FIELDNM. This indicates which field in the structure the value of the node for this row is stored in, for example MATNR. The hierarchy structure thus contains other fields which the values are transferred to. The field is assigned in the transformation to the corresponding InfoObject in the target structure. The FIELDNM field must be assigned to InfoObject OH_IOBJNM in the target structure using rule type Hierarchy Derivation.
-
-
Derivation from InfoObject names:
InfoObject 0H_IOBJNM (characteristics for hierarchies) is used to derive node names from the InfoObject names. To do this, assign InfoObject 0H_IOBJNM to the FIELDM field (field name). In the rule details, select rule type Derive Hierarchy Characteristic. At runtime, the InfoObject is automatically entered in the 0H_IOBJNM field. The InfoObject is assigned to the same field name that is contained in FIELDNM at runtime.
-
Splitting a node name (hierarchy split):
Rule type Hierarchy Split is used if the NODENAME field from hierarchy structures in IDoc format is assigned to the target InfoObjects of the hierarchy. The NODENAME field has to be assigned to the basis characteristic and external characteristics of the hierarchy. Rule type Hierarchy Split is used dialog as the rule type in the rule detail. The value in the 0H_IOBJNM field must contain the name of the node InfoObject. At runtime, the hierarchy split takes the relevant part of the value from the field NODENAME and enters them in the corresponding compound components of the target InfoObject.
-
Object identification:
InfoObject 0OBJECTID (object identification in segments) is used if several hierarchies are loaded in one request. This is not relevant for normal DataSources, as usually only one hierarchy is supplied per request.
Process
-
In the Data Warehousing Workbench under Modeling, select the InfoProvider tree.
-
Navigate to your characteristic. In the context menu of the hierarchy of the characteristic, choose Create Transformation.
-
Choose the relevant source for your transformation and choose Create Transformation. The system proposes a transformation. You can use this transformation as it is, or modify it accordingly.
-
In the transformation maintenance screen, you can use
Source Segments and
Target Segments to select the segment that you want to create the transformation for. You must create at least one transformation for the hierarchy header and one for the hierarchy nodes. The segments are listed in the correct order for source and target in the drop-down lists of the segment selection switches. -
Proceed as described in the general procedure for creating transformations.
More information: Creating Transformations
Example
More information: Example of a Transformation of a Hierarchy