creating multiple output record layouts based on rec type

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

bpsprecher
Premium Member
Premium Member
Posts: 21
Joined: Mon Mar 08, 2004 11:42 am

Post by bpsprecher »

lfong,

Glad you got it working! Thanks for sharing the good news. You've learned the hard way that you have to define your output metadata first before filling out the rest of the stage.

I was in the midst of typing this long reply, so instead of wasting it, perhaps someone else can benefit later.

----------------------

It takes a bit to get comfortable with the Column Import stage, so let's see if I can do a better job explaining.

You are correct; the output from the first Column Import stage becomes input to the second. But you need 2 Column Import stages because you can only parse a single column at a time with this stage. Since you have 2 columns to parse (COL1 & COL3 in our example), we'll need 2 stages.

Now let's just walk through Record A. We've already defined the metadata for the Sequential File stage, and it has 3 columns.

Next, we go to a Switch. There, we'll define "Selector = RecTyp", and our User-defined Mapping will be Case=A=0 (meaning, a RecTyp of "A" will go down link 0). In Output | Mapping just copy all the columns over.

In the first Column Import stage, go to Output | Columns and define this metadata:
field1 Char(4)
field2 Char(2)
RecTyp Char(1)
COL3 VarChar(23)

In Stage | Properties set "Import Input Column" = COL1. Then, click on "Column To Import" and you will see a bunch of boxes come into focus in the middle. Pick the bottom box, which allows you to select available columns -- choose field1 & field2. Now when you go to Output | Mapping you will see how Column Import actually parses a column.

On to the second Column Import. Define ALL your columns in Output | Columns. This time, your "Import Input Column" = COL3, and your columns to import are field5 & field6.
Brian Sprecher
IBM
Lenexa, KS
Post Reply