Vous êtes sur la page 1sur 8

Mapplets

A mapplet is a reusable object that you create in the Mapplet Designer. It contains a set of transformations
(more than 1 transformation) and lets you reuse the transformation logic in multiple mappings.
For example, you a similar logic need to add more than 1 mapping. Like concatenate First_Name &
Last_Name, Address_Street_1 & Address_Street_2 etc and this logic is need for Employee_Table,
Student_Table, Patient_Table 3 mappings.
In this scenario instead of repeating the logic, we can have a mapplet for concatenate (Merge) columns and
use this mapplet instance for the above mentioned 3 mappings.
When you use a mapplet in a mapping, you use an instance of the mapplet. Like a reusable transformation,
any change made to the mapplet is inherited by all instances of the mapplet.
Mapplets help simplify mappings in the following ways:

Include source definitions. Use multiple source definitions and source qualifiers to provide source
data for a mapping.

Accept data from sources in a mapping. If you want the mapplet to receive data from the
mapping, use an Input transformation to receive source data.

Include multiple transformations. A mapplet can contain as many transformations as you need.

Pass data to multiple transformations. You can create a mapplet to feed data to multiple
transformations. Each Output transformation in a mapplet represents one output group in a mapplet.

You do not have to connect all mapplet input and


output ports in a mapping.

Contain unused ports.

To use a mapplet in a mapping, first we need to configure it for input and output. In addition to
transformation logic that you configure, a mapplet has the following components:

Mapplet input

Mapplet output
Mapplet ports

Mapplet Input
Mapplet input can originate from a source definition and/or from an Input transformation in the mapplet.
You can create multiple pipelines in a mapplet. Use multiple source definitions and source qualifiers or Input
transformations. You can also use a combination of source definitions and Input transformations.
Mapplet Output
Mapplet Output transformation in a mapplet to pass data through the mapplet into a mapping. A mapplet
must contain at least one Output transformation with at least one connected port in the mapplet. Each
connected port in an Output transformation displays as a mapplet output port in a mapping. Each Output
transformation in a mapplet displays as an output group in a mapping. An output group can pass data to
multiple pipelines in a mapping.
Use the following rules and guidelines when you add transformations to a mapplet:

If you use a Sequence Generator transformation, you must use a reusable Sequence Generator
transformation.

If you use a Stored Procedure transformation, you must configure the Stored Procedure Type to
beNormal.

You cannot include PowerMart 3.5-style LOOKUP functions in a mapplet

You cannot include the following objects in a mapplet:

Normalizer transformations
COBOL sources
XML Source Qualifier transformations

XML sources
Target definitions
Other mapplets

Although reusable transformations and shortcuts in a mapplet can be used, to protect the validity of the
mapplet, use a copy of a transformation instead. Reusable transformations and shortcuts inherit changes to
their original transformations. This might invalidate the mapplet and the mappings that use the mapplet.
Step to Create Mapplet:
1. Connect/Open the folder where you want to create mapplet.
2. From Menu click Tools Select Mapplet Designer

3. From Menu Click Mapplets Select Create

It will pop-up Mapplet Name window.

Enter you choice name mplt_concate_columns and Click on OK.


4. From menu click Transformation --> select Create
It will appear you 'Select the transformation type to create:'

5. Select Mapplet Input from drop down and enter a new name for this transformation as mplt_input,
Click on Create and Done.

Note: Alternate way to create mapplet input is by click Icon.

6. Select mplt_input and double click to edit Go to Ports tab and add port required for it.

Click on Apply and OK.


7. From menu click Transformation --> select Create
It will appear you 'Select the transformation type to create:'

8. Select Mapplet Outpu from drop down and enter a new name for this transformation as mplt_output,
Click on Create and Done.

Note: Alternate way to create mapplet output is by click Icon.

9. Select mplt_output and double click to edit Go to Ports tab and add port required for

it.

Click on Apply and OK.


10. Create an expression transformation in mapplet workspace.

11. Select expression and double to edit Click on Rename to exp_concate_ports.

Go to Ports tab and added input port as below:

12. Link those ports between mplt_input and exp_concate_port as below:

13. Select expression and double to edit Ports and Add output ports highlighted below:

14. Click on Full_Name port to open expression editor to concatenate First_Name and Last_Name with
single space.

Click on Validate and OK.


15. Click on Address port to open expression editor to concatenate Address_Stree_1 and
Address_Street_2 with single space.

Click on Validate and OK.


Click on Apply and OK
16. Link those ports between exp_concate_port and mplt_output as below:

17. From menu select Mapplets Validation

18. Ctrl + S (save).


Now, your mapplet is ready to use in above defined mappings.
Note:
Use the following rules and guidelines when you edit a mapplet that is used by mappings:

Do not delete a port from the mapplet. The Designer deletes mapplet ports in the mapping
when you delete links to an Input or Output transformation or when you delete ports connected to an Input
or Output transformation.

Do not change the datatype, precision, or scale of a mapplet port. The datatype, precision,
and scale of a mapplet port is defined by the transformation port to which it is connected in the mapplet.
Therefore, if you edit a mapplet to change the datatype, precision, or scale of a port connected to a port in
an Input or Output transformation, you change the mapplet port.

Do not change the mapplet type. If you remove all active transformations from an active
mapplet, the mapplet becomes passive. If you add an active transformation to a passive mapplet, the
mapplet becomes active.

MAPPLETS

A mapplet is a reusable object that we create in the Mapplet Designer.


It contains a set of transformations and lets us reuse that transformation logic in multiple
mappings.
Created in Mapplet Designer in Designer Tool.

We need to use same set of 5 transformations in say 10 mappings. So instead of making 5


transformations in every 10 mapping, we create a mapplet of these 5 transformations. Now we use
this mapplet in all 10 mappings. Example: To create a surrogate key in target. We create a mapplet
using a stored procedure to create Primary key for target table. We give target table name and key
column name as input to mapplet and get the Surrogate key as output.
Mapplets help simplify mappings in the following ways:

Include source definitions: Use multiple source definitions and source qualifiers to provide
source data for a mapping.
Accept data from sources in a mapping
Include multiple transformations: As many transformations as we need.
Pass data to multiple transformations: We can create a mapplet to feed data to multiple
transformations. Each Output transformation in a mapplet represents one output group in a
mapplet.
Contain unused ports: We do not have to connect all mapplet input and output ports in a
mapping.

Mapplet Input:
Mapplet input can originate from a source definition and/or from an Input transformation in the
mapplet. We can create multiple pipelines in a mapplet.

We use Mapplet Input transformation to give input to mapplet.


Use of Mapplet Input transformation is optional.

Mapplet Output:
The output of a mapplet is not connected to any target table.

We must use Mapplet Output transformation to store mapplet output.


A mapplet must contain at least one Output transformation with at least one connected port in
the mapplet.

Example1: We will join EMP and DEPT table. Then calculate total salary. Give the output to mapplet
out transformation.
EMP and DEPT will be source tables.
Output will be given to transformation Mapplet_Out.
Steps:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.

Open folder where we want to create the mapping.


Click Tools -> Mapplet Designer.
Click Mapplets-> Create-> Give name. Ex: mplt_example1
Drag EMP and DEPT table.
Use Joiner transformation as described earlier to join them.
Transformation -> Create -> Select Expression for list -> Create -> Done
Pass all ports from joiner to expression and then calculate total salary as described in
expression transformation.
Now Transformation -> Create -> Select Mapplet Out from list > Create -> Give name and
then done.
Pass all ports from expression to Mapplet output.
Mapplet -> Validate
Repository -> Save

Use of mapplet in mapping:

We can mapplet in mapping by just dragging the mapplet from mapplet folder on left pane as
we drag source and target tables.
When we use the mapplet in a mapping, the mapplet object displays only the ports from the
Input and Output transformations. These are referred to as the mapplet input and mapplet
output ports.
Make sure to give correct connection information in session.

Making a mapping: We will use mplt_example1, and then create a filter


transformation to filter records whose Total Salary is >= 1500.
mplt_example1 will be source.
Create target table same as Mapplet_out transformation as in picture above. Creating Mapping
1.
2.
3.
4.
5.
6.
7.
8.

Open folder where we want to create the mapping.


Click Tools -> Mapping Designer.
Click Mapping-> Create-> Give name. Ex: m_mplt_example1
Drag mplt_Example1 and target table.
Transformation -> Create -> Select Filter for list -> Create -> Done.
Drag all ports from mplt_example1 to filter and give filter condition.
Connect all ports from filter to target. We can add more transformations after filter if needed.
Validate mapping and Save it.

Make session and workflow.


Give connection information for mapplet source tables.
Give connection information for target table.
Run workflow and see result.

Vous aimerez peut-être aussi