You are on page 1of 14

BANGALORE TECHNICAL TRAININGS Onlinetrainingsbglr@gmail.

com +917411642061

Lab 2
Creating a Mapping
Lab at a Glance................................................................2 Objectives..............................................................2 Duration.................................................................2 Exercises.........................................................................3 Exercise 1: Create a Mapping................................3

PowerCenter 9.x Level I Developer Lab Guide

onlinetrainingsbglr@gmail.com

2-1

Lab 2. Creating a Mapping

Lab at a Glance
The exercises in this lab are designed to familiarize the student with the process of creating a mapping. The student will also learn to navigate within the Mapping Designer tool.

Objectives
After completing the lab, the student will be able to: Open the Mapping Designer tool. Create a new mapping. Create an expression transformation. Link sources, transformations, and targets within a mapping. Modify and add ports to an expression transformation. Validate a mapping. The completed mapping should look like this:

Duration
This lab should take approximately 30 minutes.

2-2

PowerCenter 9.x Level I Developer Lab Guide

Lab 2. Creating a Mapping

Exercises
Exercise 1: Create a Mapping
In this exercise, the student will create a mapping that represents the data flow between the EMPLOYEE source and the ODS_EMPLOYEE target. A mapping represents the dataflow between sources and targets. The instructions defined in the mapping tell the Informatica Server how to read, transform and write the data. Step 1. Open the Mapping Designer tool. In the Navigator window, select the Studentxx folder (where xx is your assigned student number). Select Tools | Mapping Designer, or click the Mapping
Designer

button in the toolbar.

Step 2. Create a new mapping. Select Mappings | Create. The Mapping Name dialog box appears. Enter m_ODS_EMPLOYEE_xx for the New Mapping name (where xx is the assigned student number):

Click the OK button.

PowerCenter 9.x Level I Developer Lab Guide

2-3

Lab 2. Creating a Mapping

Step 3. Add source and target definitions.

2-4

PowerCenter 9.x Level I Developer Lab Guide

Lab 2. Creating a Mapping

In the Navigator window, expand the Sources and odbc_source nodes and locate the EMPLOYEE source definition:

Drag-and-drop the EMPLOYEE source definition to the far left side of the workspace. In the Navigator window, expand the Targets node and locate the ODS_EMPLOYEE target definition:

Drag-and-drop the ODS_EMPLOYEE target definition to the far right side of the workspace. The workspace should look as follows:

PowerCenter 9.x Level I Developer Lab Guide

2-5

Lab 2. Creating a Mapping

Step 4. Rename and examine the source qualifier transformation. For purposes of this lab, the source qualifier will be renamed to follow Informatica Velocity best practices. Edit SQ_EMPLOYEE by double-clicking on the header. The Edit Transformations dialog box appears. Click the Rename button. Enter sq_EMPLOYEE in the Transformation Name field. Click OK. Click Apply. Click on the Ports tab to view the port names, datatypes, precisions and scales:

Note that the Data type field indicates the PowerCenter data type for the field, or port. The Informatica Server translates native data types to PowerCenter data types before processing. When the information is written to a target, it is translated to the defined database or flat file data type.

Click the OK button to close the dialog box. Step 5. Create an expression transformation.
Before the target is loaded, the FIRST_NAME and LAST_NAME ports for each row must be concatenated. This concatenation can be done in an Expression transformation. If the toolbar is not visible, activate it by selecting Tools | Customize, then select the Transformations checkbox

Before the target is loaded, the FIRST_NAME and LAST_NAME ports for each row must be concatenated. This concatenation can be done in an Expression transformation.

Locate the Transformation toolbar.


The default location is at the top of the Designer.

Click on the vertical bar at the beginning of the toolbar and drag the toolbar to the center of the Designer workspace.
An alternative is to select
Transformations Create from the menu and then choose Expression

Click on the Expression Transformation toolbar.

button in the

2-6

PowerCenter 9.x Level I Developer Lab Guide

Lab 2. Creating a Mapping

as the transformation type. In this method, you name the transformation at the time you create it.

In order to give yourself more room to work, you may wish to toggle off the navigator window. You can do this by selecting View Navigator from the menu or by clicking the x in the upperright corner of the navigator.

Move the pointer in the workspace to the right of the sq_EMPLOYEE source qualifier. In the workspace, the cursor appears as crosshairs Left-click the mouse. An Expression transformation is created. .

PowerCenter 9.x Level I Developer Lab Guide

2-7

Lab 2. Creating a Mapping

Step 6. Link the Source Qualifier to the Expression transformation.

2-8

PowerCenter 9.x Level I Developer Lab Guide

Lab 2. Creating a Mapping

Link Columns toggles linking on/off.

You must still link the columns, as in the next step.

Select Layout | Link Columns, or click the Link Columns button in the toolbar. In the sq_EMPLOYEE source qualifier, hold down the Ctrl key and select the following ports:
EMPLOYEE_ID FIRST_NAME LAST_NAME DATE_HIRED TYPE_CODE

Drag the ports to an empty line of the expression transformation object and release the mouse button.

PowerCenter 9.x Level I Developer Lab Guide

2-9

Lab 2. Creating a Mapping

Step 7. Rename the Expression transformation. Double-click on the header of the Expression transformation. Click the Rename button. Rename the transformation to exp_ODS_EMPLOYEE. Step 8. Modify/add ports to the Expression transformation. Select the Ports tab. Disable the output ports for FIRST_NAME and LAST_NAME by removing the checkmark in the O (output) column. This will define the port as input only. Click on the LAST_NAME column. Click on the Add button to add a new port. Name the new port NAME_out. Verify the data type is string and increase the precision to 51. Disable the input port for NAME_out by removing the checkmark in the I (input) column. This will define the port as output only:

Step 9. Create an expression formula. Click in the Expression column of the NAME_out port and notice the arrow that appears at the far right:

2 - 10

PowerCenter 9.x Level I Developer Lab Guide

Lab 2. Creating a Mapping

Click on the arrow. The Expression Editor dialog box appears. Delete the text, NAME_out, in the Formula field. Select the Ports tab on the left-hand side of the Expression Editor dialog box.

Ports tab

Using the || string operator instead of CONCAT improves Informatica Server performance in processing the formula.

Double-click on the port FIRST_NAME. Note that it is added to the Formula field. Click on the double-pipe button in the Operator keypad. The concatenation operator is added to the formula. Click on the single-quote button.

Press the spacebar once and click the single-quote button again. This will cause a space to be placed after the FIRST_NAME in the formula.
Note that a formula can also be typed in manually, if the names of the functions and ports are known.

Click on the double-pipe button again. Double-click on LAST_NAME. The concatenation formula is complete, and should look like this: FIRST_NAME||''||LAST_NAME Click Validate. Upon successful parsing of the formula, the Expression parsed successfully message will appear. Click OK.

PowerCenter 9.x Level I Developer Lab Guide

2 - 11

Lab 2. Creating a Mapping

Click OK to close the Edit Transformation dialog box. Save the repository. Step 10. Link the target definition. Click on the following ports in exp_ODS_EMPLOYEE and drag them onto ODS_EMPLOYEE to link the ports: EMPLOYEE_ID EMPLOYEE_ID
NAME_out DATE_HIRED TYPE_CODE

NAME

DATE_HIRED

TYPE_CODE

The mapping is now complete. Right-click in the workspace and select Arrange All the mapping should look like the following:

Step 11. Validate the mapping. Save the repository. Every time a repository is saved, mapping validation checks are performed. Click on the Save tab in the Output window. Expand the Output window and scroll up until the validation test details are visible:

2 - 12

PowerCenter 9.x Level I Developer Lab Guide

Lab 2. Creating a Mapping

Verify that there are no errors. Step 12. Correct any errors If the validation results are INVALID:

Locate the last date/time stamp (when the repository was saved). Locate the first error. Note that there may be more than one error it is best to find and correct the first error, as it may have caused further errors. Correct the error and save the repository, or select
Mappings | Validate.

Check the results in the Output windows Validate tab:

PowerCenter 9.x Level I Developer Lab Guide

2 - 13

Lab 2. Creating a Mapping

Save the repository.

2 - 14

PowerCenter 9.x Level I Developer Lab Guide

You might also like