Skip Ribbon Commands
Skip to main content
Navigate Up
Sign In

Quick Launch

Average Rating:

(9 Ratings)
facebook Twitter
Email
Print Bookmark Alert me when this article is updated

Feedback

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 Column2 Columns3
11 12 13
21 22 23
31 32 33

Target

Column1 Column2 Column3
11 21 31
12 22 32
13 23 33
The Active Java transformation can be used to achieve this in the following way:
  1. Open Designer.

  2. Create a mapping with a Source and Target definition.

  3. Create a Java transformation: Click Transformation > Create >Java .

  4. 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.

  1. 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.

  2. Under the Helper Code tab, declare the variables required inside the Java code.
    In this example we declare the required buffer variables.

    Helper Code:

  3. 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

  4. 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:



More Information


Reference


Attachments


Applies To
Product: PowerCenter
Problem Type:
User Type: Administrator
Project Phase:
Product Version: PowerCenter 8.x; PowerCenter 9.x
Database:
Operating System:
Other Software:

Last Modified Date: 6/7/2011 4:12 PM ID: 18681
People who viewed this also viewed

Feedback

Did this KB document help you?



What can we do to improve this information (2000 or fewer characters)