How to Bind Mapplet Outputs to Mapping Outputs
You can configure a mapplet to return mapping outputs. You can bind the mapping outputs from the mapplet to the mapping outputs at the mapping level.
When you include a mapplet in mapping, the mapplet computes the value of the outputs and passes the output values to the mapping. You can bind more than one output from a mapplet to the same output at the mapping level. You can also bind system-defined outputs from a mapplet to the mapping outputs.
The following image shows the process to configure mapplet outputs and bind them to mapping outputs:
To bind outputs from mapplets to mapping outputs, perform the following steps:
- 1. Create the mapplet.
- 2. Define the mapplet output name and the type of aggregation in the Outputs view of the mapplet.
- 3. Add an Expression transformation to the mapplet and configure the mapping output expression in the Expression Mapping Outputs view.
- 4. Add the mapplet to a mapping.
- 5. Create mapping outputs in the mapping.
- 6. Bind the outputs from the mapplet to the mapping outputs.
Defining Mapplet Outputs
Create a mapplet and define the mapping outputs in the Outputs tab of the mappletProperties view. Each mapping output definition describes what type of aggregation to perform and the data type of the results.
1. After you create a mapplet, click inside the mapping canvas to access the mapplet properties.
2. Click the Outputs view.
3. Click New to create a mapping output.
The Developer tool creates a mapping output with default field values.
4. Change the name that identifies the mapping output.
5. Select a numeric or date mapping output type. If you are creating a numeric type, enter the precision and scale.
6. Choose the aggregation type for the mapping output.
You can summarize the output expression or you can find the minimum or maximum expression value that the mapping processed. Default is SUM.
The following image shows a mapplet output called Total_Sales_Tax with an aggregation type SUM:
7. Click File > Save to save the mapping output.
You must save the mapping output before you can create any mapping output expression in an Expression transformation.
Configuring a Mapping Output Expression in a Mapplet
Configure the expression to aggregate for each row that the mapplet processes.
1. Add an Expression transformation to the mapplet.
Consider the mapplet logic before you decide where to place the transformation.
2. In the Expression transformation, click the Mapping Outputs view.
3. Click New to add an output expression.
The Developer tool creates a mapping output with a output name that matches one of the mapping outputs you created at the mapplet level. You might have more than one output to choose from.
4. Enter an expression with the Expression Editor.
The expression can contain a port name or it can contain functions, ports, and parameters.
5. Click Validate to verify that the expression is valid.
6. Click OK to save the expression.
The following image shows the Mapping Outputs view with a mapping output expression that calculates a sales tax:
7. Click File > Save to save the Expression transformation.
Binding Outputs from a Mapplet to Mapping Outputs
When you include the mapplet in a mapping, you can bind the outputs from the mapplet to the mapping outputs that you define at the mapping level.
1. Define a mapping and add the mapplet to the mapping.
2. Click the mapping canvas to view the mapping Properties.
3. Click the Outputs view.
4. Click New to create a mapping output.
The Developer tool creates a mapping output with default field values.
5. Change the mapping output type, the aggregation type, the precision and the scale to match fields from the mapplet that you want to bind to.
6. Optionally, change the name and enter a description.
7. Click the selection arrow in the Binding field to view a list of outputs.
The following image shows the Outputs Binding dialog box:
8. Select the mapplet ouput to bind to the mapping output.
You can select more than one mapplet output to bind to the same mapping output.
9. Click OK.
The mapplet outputs that you select appear in the Binding field.
The following image shows the mapplet output name in the Binding field of the mapping output: