You are on page 1of 3

PowerCenter Java transformation example

Content
The following example uses the Java Transformation in PowerCenter 8.x to transpose input string values as follows:

Source
Column1 11 21 31 Column2 12 22 32 Columns3 13 23 33

Target
Column1 11 12 13 Column2 21 22 23 Column3 31 32 33

The Active Java transformation can be used to achieve this in the following way: 1. 2. 3. 4. Open Designer. Create a mapping with a Source and Target definition. Create a Java transformation: Click Transformation > Create >Java . Select Active .

5. Add input and output ports to the transformation. Add input ports in the input group and output ports in the output group.

6. Select the Java Code tab. With the Active Java transformation, the number of input rows can differ from the number of output rows. The input values can be stored in memory and the output is generated when needed. The PowerCenter Java API generateRow() will generate rows according to the defined output ports values. 7. Under the Java Code tab, select the Import Packages tab. Add import statements for the required Java packages which would be used inside the Java transformation code. 8. Under the Helper Code tab, declare the variables required inside the Java code. In this example we declare the required buffer variables.

Helper Code:

9. Under the On Input Row tab, when an input row enters into this transformation, we can describe what action the transformation should perform. In this example, we buffer the input row values. Whenever the input row comes, it stores all the values in the buffer sequentially.

On Input Row

10. Under the On End of Data tab, we can describe what the transformation should do when all the input data has been read. In this example we generate output rows from this tab and buffer the entire input and generate output based on the requirement.

On End of Data

Mapping: The simple mapping using this example Java transformation will look as follows:

Applies To
Product(s): PowerCenter Product Version(s): PowerCenter 8.x; PowerCenter 9.x

Last Modified Date: 6/7/2011 4:12 PM ID: 18681

You might also like