Logic in stage variable
Moderators: chulett, rschirm, roy
Logic in stage variable
Hello there,
Dataset o/p
RIDER RIDER_TYPE
x13 DR
x13 DR
x13 DR
x13 NULL
x13 DR
x13 DR
x13 DR
x13 DR
x13 DR
x13 MH
x13 MH
x13 MH
M10 VS
M10 VS
M10 VS
M10 BI
M10 NULL
M10 BI
M10 BI
M10 BI
M10 VS
M10 VS
M10 VS
M10 VS
M10 VS
M10 VS
M10 VS
OUTPUT
X13 DR:DR:DR:DR:DR:DR:DR:DR:MH:MH
M10 VS:VS:VS:BI:BI:BI:BI:VS:VS:VS
I have to concatinate first 10 values for each rider.If NULL is enountered in rider_type then I have to drop them.
Source is dataset( which is o/p of a join of couple of tables).
I am using stage variable to perform this logic.
To give you a overview of the things
one stage variable to perform concatination of field (rider_type).
Stage varaible for counting the incomming rows.
I am close but yet far from the solution.
Please let me know how to perform this and is there any other way to do the same.
I tried to do a search got some hints but I wast able to built on those.
Thanks
Sai
Dataset o/p
RIDER RIDER_TYPE
x13 DR
x13 DR
x13 DR
x13 NULL
x13 DR
x13 DR
x13 DR
x13 DR
x13 DR
x13 MH
x13 MH
x13 MH
M10 VS
M10 VS
M10 VS
M10 BI
M10 NULL
M10 BI
M10 BI
M10 BI
M10 VS
M10 VS
M10 VS
M10 VS
M10 VS
M10 VS
M10 VS
OUTPUT
X13 DR:DR:DR:DR:DR:DR:DR:DR:MH:MH
M10 VS:VS:VS:BI:BI:BI:BI:VS:VS:VS
I have to concatinate first 10 values for each rider.If NULL is enountered in rider_type then I have to drop them.
Source is dataset( which is o/p of a join of couple of tables).
I am using stage variable to perform this logic.
To give you a overview of the things
one stage variable to perform concatination of field (rider_type).
Stage varaible for counting the incomming rows.
I am close but yet far from the solution.
Please let me know how to perform this and is there any other way to do the same.
I tried to do a search got some hints but I wast able to built on those.
Thanks
Sai
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Sainath,
Thanks for the response
Let me reiterate my qestion
I have to concatinate rider types for every unique rider option.
And only 10 such values have to be concatinated and if null is encountered in between it has to be droped.
Like this
X13 DRDRDRDRDRDRDRDRMHMH
M10 VSVSVSBIBIBIBIVSVSVS
Please let me know all the steps dealing with stage variables.
Thanks
Sai
Thanks for the response
Let me reiterate my qestion
I have to concatinate rider types for every unique rider option.
And only 10 such values have to be concatinated and if null is encountered in between it has to be droped.
Like this
X13 DRDRDRDRDRDRDRDRMHMH
M10 VSVSVSBIBIBIBIVSVSVS
Please let me know all the steps dealing with stage variables.
Thanks
Sai
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Stage variable has to be overwritten when the change key (generated in upstream Sort stage) is set, or accumulated otherwise.
Let's call the stage variable svOutputRow
Let's call the stage variable svOutputRow
Code: Select all
If inlink.changeKey = 1 Then inlink.col2value Else If IsNull(inlink.col2value) Then svOutputRow Else If Len(svOutputRow) >= 20 Then svOutputRow Else svOutputRow : inlink.col2value
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Ray,
Thanks for your responce
I implemeted the Change key using svValueHasChanged stage variable as below.Please correct me if I am wrong.
svPreviousValue = svCurrentValue
svCurrentValue = input.field
svValueHasChanged = If svCurrentValue = svPreviousValue Then 0 Else 1
svCounter = If svValueHasChanged Then svCounter + 1 Else svCounter
( I am not sure will I have to implement this)
Also I guess
If inlink.changeKey = 1 Then inlink.col2value Else If IsNull(inlink.col2value) Then svOutputRow Else If Len(svOutputRow) >= 20 Then svOutputRow Else svOutputRow : inlink.col2value
should be assinged to svOutputRow
If all this is correct the o/p of the above stage variable(svOutputRow) doest give me the conncatinated values as we expected. If gives me 2 byte values.
Please let me know
Thanks
Sai
Thanks for your responce
I implemeted the Change key using svValueHasChanged stage variable as below.Please correct me if I am wrong.
svPreviousValue = svCurrentValue
svCurrentValue = input.field
svValueHasChanged = If svCurrentValue = svPreviousValue Then 0 Else 1
svCounter = If svValueHasChanged Then svCounter + 1 Else svCounter
( I am not sure will I have to implement this)
Also I guess
If inlink.changeKey = 1 Then inlink.col2value Else If IsNull(inlink.col2value) Then svOutputRow Else If Len(svOutputRow) >= 20 Then svOutputRow Else svOutputRow : inlink.col2value
should be assinged to svOutputRow
If all this is correct the o/p of the above stage variable(svOutputRow) doest give me the conncatinated values as we expected. If gives me 2 byte values.
Please let me know
Thanks
Sai
Chulett,
This is order
svCurrentValue = input.field
svPreviousValue = svCurrentValue
svValueHasChanged = If svCurrentValue = svPreviousValue Then 0 Else 1
If svValueHasChanged = 1 Then inlink.col2value Else If IsNull(inlink.col2value) Then svOutputRow Else If Len(svOutputRow) >= 20 Then svOutputRow Else svOutputRow : inlink.col2value
Please let me know is this is the right way
Thanks
Sai
This is order
svCurrentValue = input.field
svPreviousValue = svCurrentValue
svValueHasChanged = If svCurrentValue = svPreviousValue Then 0 Else 1
If svValueHasChanged = 1 Then inlink.col2value Else If IsNull(inlink.col2value) Then svOutputRow Else If Len(svOutputRow) >= 20 Then svOutputRow Else svOutputRow : inlink.col2value
Please let me know is this is the right way
Thanks
Sai
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The order is not correct. Also, stage variables in parallel jobs can not be null.
Code: Select all
svCol2NotNull <== NullToValue(inlink.col2value,"<<NULL>>")
svIsChanged <== svCol2NotNull <> svPreviousValue
svPreviousValue <== NullToValue(inlink.col2value,"<<NULL>>")
svOutputCol <== If svIsChanged Then If IsNull(inlink.col2value) Then "" Else inlink.col2value Else If IsNull(inlink.col2value) Then svOutputCol Else svOutputCol : inlink.col2value
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: