Rational Developer for System z

Step 4.6 Handle the error case where the requested item number is not found

In this step you add to CatalogOrder.seqflow an Assign node that returns an error code and an error message to the invoking program if the requested item is not found in the catalog.

Recall that the node Switch is configured so that the flow of control passes out through the second output terminal if the requested item number is not found by CheckItemAvailabililty.seqflow (see Step 4.2: Add a Switch node to the top-level flow). Now in this step you create an Assign node, connect it to the second output terminal of the node Switch, and add mappings to it to store an error code and an error message in the output parameters of CatalogOrder.seqflow.

Add the Assign node

To add the Assign node:

  1. If CatalogOrder.seqflow is not already open in the flow editor then:

    1. Open CatalogOrder.seqflow in the flow editor.

    2. In the workbench's main menu click View > Zoom Out.

  2. Add a second Assign node immediately to the right of the Switch node Switch. The new Assign node is named Assign2 (the default name).

  3. Create a connection from the output terminal Default of the node Switch to the input terminal of the node Assign2:

    1. Right-click the Switch node Switch.

    2. Click Create Connection. The Terminal Selection window opens.

    3. In the Terminal Selection window:
      1. Click Default.
      2. Click OK.

    4. Complete the connection by clicking the input terminal of Assign2.

  4. Create a connection from the output terminal of Assign2 to the input terminal of o_CatalogOrder.

  5. The flow editor canvas for CatalogOrder.seqflow should now look something like Figure 1:

    Figure 1. CatalogOrder.seqflow
    CatalogOrder.seqflow with the Assign1 node added

  6. Close the flow editor.

Add mappings to the new Assign node

Note: For syntax such as o_CatalogOrder.returnCode see Note on "<Message>.<element>".

In this subtopic you create mappings to set the return code and return the values in the output message o_CatalogOrder of the top-level flow CatalogOrder.seqflow.

Add the two mappings shown in Table 1 to the mapping routine for the Assign node Assign2. Because this Assign node is handling an error case these two mappings store an immediate error code and an immediate error message into the output parameters of the flow:
Table 1. Mappings to be added to node Assign2
SOURCE: maps to TARGET:
99 maps to o_CatalogOrder.returnCode
ITEM WAS NOT AVAILABLE IN THE CATALOG maps to o_CatalogOrder.returnMessage

To create the mappings:

  1. If CatalogOrder.seqflow is not already open in the flow editor then:

    1. Open CatalogOrder.seqflow in the flow editor.

    2. In the workbench's main menu click View > Zoom Out.

  2. Open the mapping routine for the Assign node Assign2:

    1. Right-click the node Assign2.

    2. Click Open Mapping Routine. The mapping editor opens and displays the mapping routine.

  3. Add o_CatalogOrder to the mapping routine as a target message. (This message is the output data message used by the flow CatalogOrder.seqflow.)

    1. On the mapping routine toolbar click the Add a target message Add a target message icon. The Select Message window opens.

    2. In the Select Message window:
      1. Click the message CatalogSample > CatalogSample.Interface > Messages > o_CatalogOrder.sfmxsd > o_CatalogOrder.
      2. Click OK.

      The target message is added to the right side of the mapping routine area.

  4. Create a mapping that stores the integer value 99 into the target element o_CatalogOrder.returnCode:

    1. On the target side of the mapping routine area right-click o_CatalogOrder.returnCode.

    2. Click Create Transform.

    3. Click the transform Assign if it is not already selected.

    4. In the Properties view:
      1. Click the General tab.
      2. In the Value field type the integer value 99 and press Enter.
        Note: The Value field on the General tab of the Assign transform expects normal text not an ESQL expression (see Transforms that create one-sided mappings).
  5. Create a mapping that stores the string Item was not available in the catalog into the target element o_CatalogOrder.returnMessage:

    1. On the target side of the mapping routine area right-click o_CatalogOrder.returnMessage.

    2. Click Create Transform.

    3. Click the transform Assign if it is not already selected.

    4. In the Properties view:
      1. Click the General tab.
      2. In the Value field type the string Item was not available in the catalog and press Enter.
        Note: The Value field on the General tab of the Assign transform expects normal text not an ESQL expression (see Transforms that create one-sided mappings).
  6. Close the mapping editor.

  7. Close the flow editor.

Attention: You have finished building the flow CatalogOrder.seqflow, from which you can now generate a service flow. The next step is to create the properties required for generating runtime code (see Step 5.1: Create and configure the generation properties file for CheckItemAvailability.seqflow).


Feedback