Header, detail Logic

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

Post Reply
datskosaraju
Premium Member
Premium Member
Posts: 48
Joined: Tue Nov 25, 2008 11:10 pm
Location: Des Moines,IA

Header, detail Logic

Post by datskosaraju »

Hi guys,

Need some logic help!
I have a file with header and detail in the same file format like this
  • 1 xyz 1234
    2 fgg 1234
    2 fgg 1234
    2 dfg 1234
    1 rfr 5678
    2 tgg 5678
    2 gtt 5678
    2 tty 5678
[/list]

we differentiate between header and detail by col 1 ( 1 for header, 2 for detail) and we can uniquely identify detail of every corresponding header by col3 ( i.e if col3 of detail match to that of a header then they belong to the header)

I need to generate o/p like this
  • 1 xyz 1234
    2 fgg 1234 1
    2 fgg 1234 2
    2 dfg 1234 3
    1 rfr 5678
    2 tgg 5678 1
    2 gtt 5678 2
    2 tty 5678 3
i.e the first detail under the header gets 1 and the next detail gets incremented by 1 and so on..... header is not required in the output (just wrote that for simplification).
Can anyone please tell me the logic for this.( Stage variables ?)
"It's easier to go down a hill than up it but the view is much better at the top"
-Bennet,Arnold
Grace J.
Participant
Posts: 22
Joined: Mon Nov 03, 2008 5:34 am

Post by Grace J. »

Sort the records based on col1 and col3 and generate keychange column. And then in next transformer use a stage variable stgvar. Reset the stage variable to 0 if keychange column is 1, else increment the stage variable. And then pass records only with key change column=0
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Since it's already 'sorted' you can skip that step and just set a stage variable to zero when Col1=1 and increment it by one when Col1=2.
-craig

"You can never have too many knives" -- Logan Nine Fingers
datskosaraju
Premium Member
Premium Member
Posts: 48
Joined: Tue Nov 25, 2008 11:10 pm
Location: Des Moines,IA

Post by datskosaraju »

Grace, criag thanks for the replies. The logic worked!!
"It's easier to go down a hill than up it but the view is much better at the top"
-Bennet,Arnold
Post Reply