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.

Generating business object variables

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"..

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

Figure 73. 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 "Providing map property information"..

  3. Select the business object type you want to change.
  4. Click the Change... 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.

Using 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).

Temporary variables are defined within a temporary business object. You create a temporary business object from the Temporary tab of the Add Business Object dialog. To display the Add Business Object dialog, perform the following steps:

  1. Select Add Business Object from the Edit menu.

    For information on other ways to display the Add Business Object dialog, see "From the Add Business Object dialog"..

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

  2. Click the Temporary tab. Figure 74 shows the Temporary tab of the Add Business Object dialog.

    Figure 74. Temporary tab of the Add Business Object dialog

Through the Temporary tab of the Add Business Object dialog, you specify the temporary variables. To define a temporary variable:

  1. Map Designer Express generates the temporary business object's name and displays it in the Name field. This field is read-only. The first generated name is ObjTemporary.
  2. 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.
  3. Click the Type field and select the temporary variable's data type from the pull-down list.
    Note:
    To be compatible with the ICS 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.
  4. Repeat steps 2 and 3 for each of the temporary variables you need in the map.
  5. Click the Add Temporary Business Object button.
  6. You can either define another temporary business object or click Done to finish.

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.

You 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.

Copyright IBM Corp. 2003