Stage Variables Logic to check for a specific pattern

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
Developer9
Premium Member
Premium Member
Posts: 187
Joined: Thu Apr 14, 2011 5:10 pm

Stage Variables Logic to check for a specific pattern

Post by Developer9 »

Hi,

I have the following requirement that I am working on to implement the solution

Input

Code: Select all

Emp_HistID| Emp_NO|EMP_TYPE 
100*1          100         H            
100*2          100         RH
100*3          100         H
100*4          100         R
100*5          100         R
100*6          100         RH
100*7          100         H
100*8          100         R
100*9          100         V
100*10         100         RH
Required output :

Code: Select all

Emp_HistID |Emp_NO|EMP_TYPE| EMP_STATUS
100*7          100       H      ACTIVE
100*10         100      RH      NA
Requirement

Code: Select all

1. Is to check for a latest EMP_TYPE='H' and populate EMP_STATUS ='ACTIVE'

2.If EMP_TYPE changes from H to RH then it should populate as 'NA'

JobDesign Draft :

Code: Select all

seqfile(Input) -->RMD stage -->xfm-->seqfile(ouput)
In Remove Duplicate stage,I used these keys EMP_NO and EMP_TYPE as keys have Duplicates to Retain last option to latest H

Please let me know any ideas to implement this logic while I was testing

Thank you :)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What have you tried? Did it produce the results you expected? If not, what results did it produce?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Developer9
Premium Member
Premium Member
Posts: 187
Joined: Thu Apr 14, 2011 5:10 pm

Post by Developer9 »

Hi Ray,

In the Remove duplicate stage ,I used EMP_NO,EMP_TYPE as keys and performed hash partition on these keys and choose option to Duplicate to Retain 'Last' and SET EMP_STATUS "NEED LOGIC "

I was able to get these 2 records out

Code: Select all

Emp_HistID |Emp_NO|EMP_TYPE| EMP_STATUS 
100*7          100       H      NEED LOGIC 
100*10         100      RH      NEED LOGIC
I am working on the logic to Print "ACTIVE" and "NA " in EMP_STATUS field

May be Using stage variables can achieve this

Thank you :)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Using stage variables would be ideal. See if you can work it out. If not, show us what you tried, and what results were produced.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply