Page 1 of 1

Stage Variables Logic to check for a specific pattern

Posted: Wed Aug 26, 2015 2:44 pm
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 :)

Posted: Wed Aug 26, 2015 6:17 pm
by ray.wurlod
What have you tried? Did it produce the results you expected? If not, what results did it produce?

Posted: Fri Aug 28, 2015 11:50 am
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 :)

Posted: Fri Aug 28, 2015 3:10 pm
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.