Friday, September 20, 2013

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.
  • Contain unused ports. You do not have to connect all mapplet input and output ports in a mapping.

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 be Normal.
  • 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. 


3 comments: