Using variables

A variable is a placeholder for a value in the Java code. This section provides the following information about using variables in transformation code:

Using generated business object variables and attributes

This section provides information about generating business object variables for the source and destination business objects. When you add a business object to the map, Map Designer Express automatically generates the following:

Map Designer Express displays this information in the following locations:

Note:
You can specify whether Map Designer Express displays the names of the variables for the source and destination business objects with the option Defining Map: show business object instance name. By default, this option is enabled and Map Designer Express displays these variable names (ObjBusObj) in both the Table and Diagram tabs. When the option is disabled, Map Designer Express only displays the names of the source and destination business objects. You can change the setting of this option on the General tab of the Preferences dialog. For more information, see Specifying General Preferences.

Steps for modifying business object variables

You can modify these business object variables from the Business Objects tab of the Map Properties dialog (see Figure 88).

This figure shows the Map Properties screen with the Business Object table selected. In the Business Object section ObjClarify_Contact is selected. The Business object instance name field is ObjClarify_Contact and Business object index field is 0.

Figure 88. Business Objects Tab of the Map Properties Dialog

To change the business object type of the source or destination business object in the map in the Map Properties dialog, perform the following steps:

  1. Open the map.
  2. Display the Business Objects tab of the Map Properties dialog in any of the following ways:

    For information on other ways to display the Map Properties dialog, see Specifying map property information..

  3. Select the business object type you want to change.
  4. Click the Change push- button under Business Object Type.
  5. Select the new type.
  6. Click OK to close the Select Business Object dialog.
  7. Click OK to close the Map Properties dialog.

Note:
Invalid transformation rules will be deleted.

Referencing business object attributes

Use the business object variables that Map Designer Express generates to reference business objects and their attributes, as follows:

Creating temporary variables

Map Designer Express lets you create temporary variables that can be accessed in transformation steps throughout the map; that is; temporary variables are global to the map. For example, you can calculate a value in one transformation step, store it in a temporary variable, and reference the variable in another transformation step. This is especially useful if a certain calculation is performed repeatedly; you can perform the calculation once, store the result in a temporary variable, and retrieve the value as needed (for example, with a Move transformation).

Steps for creating temporary business object variables

Temporary variables are defined within a temporary business object. Perform the following steps to create a temporary business object variable:

  1. Select Add Business Object from the Edit menu.

    Result: The General tab of the Add Business Object Properties dialog box appears.

    For information on other ways to display the Add Business Object dialog, see Steps for specifying business objects from the Add Business Object dialog.

  2. Click the Temporary tab. This is where you define the temporary variables. Figure 89 shows the Temporary tab of the Add Business Object dialog. In the Name field appears the temporary business object's name, which Map Designer Express has generated. The first generated name is ObjTemporary. This field is read-only.
    Figure 89. Temporary tab of the Add Business Object dialog
  3. Click in the Attribute field.

    Result: A new row appears in the variables table. Enter the name of the temporary variable.

    Note:
    Do not create two temporary variables with the same name.
  4. Click the Type field and select the temporary variable's data type from the pull-down list.
    Note:
    To be compatible with the InterChange Server Express data type scheme, all temporary variables have an internal type String. The data type specified in the Add Business Object dialog will affect only how the variable is initialized. If you want to write custom Java code to assign values to the temporary variable, the value has to be converted to a String first.
  5. Repeat steps 3 and 4 for each of the temporary variables you need in the map.
  6. Click the Add Temporary Business Object button.
  7. You can either define another temporary business object or click Done to finish.

Steps for using temporary business object variables in transformation steps

Use the temporary variable in a transformation step in this way:

Important:
Because a temporary variable is a global variable, you must explicitly initialize a temporary variable to null when using the Map Instance Reuse option. Otherwise, the value of the temporary variable from a previous execution of the map instance can incorrectly be used as the value of the temporary variable in subsequent executions of the same map. When you do not use the Map Instance Reuse option, the InterChange Server Express system automatically initializes temporary variables between separate invocations of the map.

Result: Once Map Designer Express creates the temporary business object, this business object appears in the Table and Diagram tabs with the map's other business objects, as follows:

Note:
A temporary business object also appears in the Business Object tab of the Map Properties dialog.

Declaring variables

Tips: Keep the following tips in mind when declaring variables:

Copyright IBM Corp. 2004, 2005