Saturday 16 April 2011

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. Open folder where we want to create the mapping.
  2. Click Tools -> Mapplet Designer.
  3. Click Mapplets-> Create-> Give name. Ex: mplt_example1
  4. Drag EMP and DEPT table.
  5. Use Joiner transformation as described earlier to join them.
  6. Transformation -> Create -> Select Expression for list -> Create -> Done
  7. Pass all ports from joiner to expression and then calculate total salary as described in expression transformation.
  8. Now Transformation -> Create -> Select Mapplet Out from list –> Create -> Give name and then done.
  9. Pass all ports from expression to Mapplet output.
  10. Mapplet -> Validate
  11. 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. Open folder where we want to create the mapping.
  2. Click Tools -> Mapping Designer.
  3. Click Mapping-> Create-> Give name. Ex: m_mplt_example1
  4. Drag mplt_Example1 and target table.
  5. Transformation -> Create -> Select Filter for list -> Create -> Done.
  6. Drag all ports from mplt_example1 to filter and give filter condition.
  7. Connect all ports from filter to target. We can add more transformations after filter if needed.
  8. Validate mapping and Save it.

clip_image002

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

No comments :

Post a Comment