Here what official documentation says about Mapplets:
A mapplet is a reusable object that you create in the Mapplet Designer. It contains a set of transformations and lets you reuse the transformation logic in multiple mappings.
When you use a mapplet in a mapping, you use an instance of the mapplet. Any change made to the mapplet is inherited by all instances of the mapplet.
My take on this is, if you have a mapping that you wish to re-use, instead of copying and paste every time you need that flow of transformations, you instead create a mapplet, so the next time you don’t need to copy-paste, you just use the mapplet you created.
Another important take on mapplets is that it’s a set, a group, of transformations. What I mean is, if you can achieve your logic just by using only one transformation, then you do not need mapplet, you just create a re-usable transformation. However, if your logic requires more than one transformation, then yes, mapplets is what you are looking for.
Active or Passive
A mapplet can be active or passive depending on the transformations in the mapplet. Active mapplets contain one or more active transformations. Passive mapplets contain only passive transformations.
All transformation rules apply to the mapplet. For example, as with an active transformation, you cannot concatenate data from an active mapplet with a different pipeline.
Rules for creating a Mapplet
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
Best-practice: 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.
Creating and Using Mapplet
We create mapplets pretty much the same way we create transformations, with some differences, of course.
One very important difference is that mapplets require input and output. You can create input and output by going transformation -> create -> mapplet input / mapplet output, or you can click on menu bar icons.
An important fact about mapplets is that their input or output ports do not have a datatype definition.
You can create mapplets ports manually, like we did in the image above, or your can drag a source to your mapplet and drag all fields to your input/output and then remove your source from your mapplet.
So, let’s say I want to do some text cleansing, like apply lowercase, remove leading or trailing spaces, if it’s null change to ‘not informed’.
Testing our mapplet
To test our mapplet we are creating a .csv flat file, and input it’s result to our MS SQL database.
Here’s our source csv file:
And here is our mapping, using our mapplet:
Notice what we did here;
- we have passed our ID and NAME from source directly to ID and NAME on target,
- and our cleansed data, the one from our mapplet, receives the same NAME from source but store its result in RESULT_CHECK on target. This way, when we query our database we will be able to see the difference between those two fields.
In your workflow session the mapplets transformation will be shown under transformation group, but named with the mapplet name before the transformation name (yeah, I should have named better my mapplet transformations, ops).
Here’s our result, it worked =)
2 thoughts on “Informatica Powercenter – Mapplets”