Creating Transformations

Objectives

After completing this lesson, you will be able to:

  • Create a transformation

Transformations in SAP BW Bridge

Suppose you now have created a data source and an InfoObject with attributes or texts. The field names and even data types may be different in the source and in the target. In this case, the target is the attributes table. Therefore, you need a specific BW bridge object to connect the source and the target fields.

A Transformation is the SAP BW bridge object that defines the mapping between source and target fields. For each mapping, a rule can be defined. Such a rule may change the content of the field for each data record that is transferred.

You can create the transformation using the Context menu within the Data Flow object. You can also create SAP BW/4HANA transformations using the context menu of the target in the tree of the BW bridge project or in a search result list. The easiest way is to directly assign source fields to target fields.

Launch a video to see how a simple transformation is created for master data.

Note
Besides the transformation rule Direct Assignment, other transformation rules are offered in SAP BW/4HANA. More options related to Transformations will be covered later.

Rule Types

In a Transformation, multiple transformation rules are defined. Typically, you define one rule per target field.

Screen captures displaying transformation rules in detail.

Within a transformation rule, the following settings are defined:

  • Source field(s)

  • Rule Type

  • Target fields(s)

  • Aggregation Type for key figures: controls how a Key Figure or data field is updated:

    • Summation (for Standard DataStore Object and Data Mart DataStore Object)
    • Minimum (for Standard DataStore Object and Data Mart DataStore Object)
    • Maximum (for Standard DataStore Object and Data Mart DataStore Object)
    • Overwrite (for Standard DataStore Object and c)
  • Currency/unit conversion for key figures with an associated currency or unit of measure

Rule Types

Several options are available when defining a rule type:

  • Initial: The empty or default value is provided, such as 0 for key figures.

  • Constant: The field is filled directly with the fix value given in the rule definition, for example to always assign 'USD' as the currency code.

  • Direct Assignment: The field is filled directly from the chosen source field or InfoObject, for example to pass an order ID to the target.

  • Time: Whenever you map a source time characteristic to a target time characteristic, automatic time conversion and time distribution are handled. For example, if calendar day is mapped to calendar month, the corresponding month of a date is determined. This may cause key figure values to be aggregated. If calendar year is mapped to calendar month, new rows may be generated and yearly values are then split into monthly values. If calendar year/month is mapped to calendar year/week, time conversion and automatic time broadcasting is handled for the key figures as displayed in the figure, Time Broadcasting.

    This image shows time broadcasting. The lower part of the image shows a source that has sales value 100 for the calendar year/month January 2020. The transformation rule displayed in the middle or the image maps calendar year/month to calendar year/week. As a result, five rows are generated for the five weeks of this month, as shown in the top of the image.

  • Routine: The field is filled by a transformation routine that you have written, for example to determine a rating based on a complex procedure. The programming language can be ABAP or SQL script.

    Note
    For DataStore Objects (advanced) and InfoObjects: You cannot use the return code in the routine for data fields that are updated by being overwritten. If you do not want to update specific records, you can delete these from the start routine. If you fill a target Key Figure with assigned currency from a transformation routine, currency translation has to be performed using the transformation routine. This means that no automatic calculation can be performed.
  • Lookup from InfoObject: An InfoObject is updated by looking up the target value from the master data table of a characteristic that contains the corresponding InfoObject as an attribute, for example the category of a product ID. The rule returns the attribute value that corresponds to the key value provided by the source field(s) of the rule.

    Note
    It is not possible to read additional attributes for the attributes. You have to use routines for this. If the attribute is time-dependent, you also have to define the read time: on the current date (sy-date), at the beginning or end of a period (determined by the time characteristic in the InfoSource), or on a constant date that you enter directly. Sy-date is used in the default setting.
  • Lookup from DataStore Object (advanced): To read from a DataStore object (advanced), the system first provides you with a proposal for how the fields can be assigned, for example to return last year's sales totals for a customer and product combination. The ADSO key fields must be assigned to the source fields of the rule. Then you map a dependent field of the ADSO to the target field. These field names don't have to be identical. You can define how the system should behave if reading fails: the system either displays an error message or provides a constant.

    Note
    The process of reading master data and DataStore Objects (advanced) data on demand is performance-optimized. The disjunctive keys of a complete data package are read from the database using mass access and buffered for further processing. This means that customer-defined buffering with a start routine is not necessary because the performance is very similar. To avoid performance problems here, the key value must be unique. So, the ADSO should not have more key fields than the source fields of the rule.
  • Formula: The target field is updated with a value determined using a formula. A formula can combine functions from the formula library, for example to return the first day of the current month. The library contains system fields, mathematical functions, string operations such as substring or concatenate, date operations, and data type conversion. You can implement self-defined functions in the library in the formula builder, for example if you want to integrate existing function modules.

    The editor, called formula builder, has both standard and expert mode. In standard mode, you can only enter formulas using the buttons and by double-clicking on functions and fields. In expert mode, you can enter formulas directly. You can also toggle between the two modes when entering a formula.

    Note

    A type check is not performed for a formula. This means the system does not check if the formula result matches the type of the target field.

    This is a screen capture from the formula editor.
  • 0RECORDMODE Calculation for ODP: If the source of your transformation is an ODP DataSource and the target is either a DataStore Object (advanced) or InfoObject, you need a specific rule type 0RECORDMODE Calculation for ODP for the ODQ_CHANGEMODE and ODQ_ENTITYCNTR fields. This rule type can also be used to calculate the 0RECORDMODE target field which reflects the change behavior. If you load deltas from an operational data provider that returns more than just one image type (after images, delete images and new images for example), the 0RECORDMODE value is derived from the ODQ_CHANGEMODE and ODQ_ENTITYCNTR fields.

    Note
    The characteristic is used to pass DataSource indicators (from SAP systems) to the update. If you are not loading delta requests to the DataStore Object (advanced), or are only loading from file DataSources, you do not update the 0RECORDMODE characteristic.
Note
When you have already defined one of these rule types and switch to No Update as the rule type, the rule will be removed. In this case, like for a target field that was never defined as a rule target, no values will be updated in the data transfer process. If it is a non-key field, existing values will remain unchanged.

Log in to track your progress & complete quizzes