HI, I HAVE A SEQFILE
X008999999999999999999
Y008999999999999999999
Z008999999999999999999
Z008999999999999999999
X008999999999999999999
Y008999999999999999999
Z008999999999999999999
Y008999999999999999999
Z008999999999999999999
Z008999999999999999999
X008999999999999999999
Y008999999999999999999
Z008999999999999999999
HERE I WANT TO CHECK FOR THE EXISTANCE OF 'Y' AND 'Z' RECORDS IN BETWEEN TWO 'X' RECORDS.
IN BETWEEN TWO 'X' RELEASTCORDS I CAN HAVE MULTIPLE 'Y' AND 'Z' RECORDS. AND IN BETWEEN TWO 'Y' RECORDS
I CAN HAVE MULTIPLE 'Z' RECORDS.
BUT ATLEAST ONE 'Y' AND ONE 'Z' INBETWEEN TWO 'X' RECORDS.
HOW DO I CHECK THIS?
PLEASE THROW SOME LIGHT ON THIS.
TIA.
SEQ_FILE
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Be more precise with your requirement.
What, exactly, is your required output for each line processed? For example, for each X record, do you need the number of preceding Y and Z records (separate counts or combined count)? What is the output for Y and Z records?
The solution will certainly make use of stage variables, and maybe an aggregator stage, but the actual solution would depend on the precise requirement.
What, exactly, is your required output for each line processed? For example, for each X record, do you need the number of preceding Y and Z records (separate counts or combined count)? What is the output for Y and Z records?
The solution will certainly make use of stage variables, and maybe an aggregator stage, but the actual solution would depend on the precise requirement.
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:
Keep counts of Y and Z records. Detect these values when an X record shows up. If either is zero, reject the file (stop the job?).
Otherwise reset counts to 0 for X record after making the test (for example in another stage variable).
Otherwise reset counts to 0 for X record after making the test (for example in another stage variable).
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:
Stage variables
svRecType init @NULL derivation Left(InLink.Column, 1)
svTest init 0 derivation If (svRecType = "X") And (@INROWNUM > 1) Then (svYCount = 0) Or (svZCount = 0) Else @FALSE
svYCount init 0 derivation If svRecType = "X" Then 0 Else svYCount + 1
svZCount init 0 derivation If svRecType = "X" Then 0 Else svZCount + 1
Constraint expression
svTest
svRecType init @NULL derivation Left(InLink.Column, 1)
svTest init 0 derivation If (svRecType = "X") And (@INROWNUM > 1) Then (svYCount = 0) Or (svZCount = 0) Else @FALSE
svYCount init 0 derivation If svRecType = "X" Then 0 Else svYCount + 1
svZCount init 0 derivation If svRecType = "X" Then 0 Else svZCount + 1
Constraint expression
svTest
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.
sorry. ray
let me put my requirement in right way.
my requirement is,
X--->Y---->Z
'X' IS PARENT FOR 'Y' AND 'Y' IS PARENT FOR 'Z'
SO IN VALID COMBINTAIONS ARE
X
Z-------> THERE IS NO PARENT RECORD FOR 'Z'
Y
Z-------> THERE IS NO PARENT RECORD FOR 'Y'
Z-------> THERE IS NO PARENT RECORD FOR 'Z'
IN THE ABOVE CASES I WANT TO REJECT THE FILE.
TIA
let me put my requirement in right way.
my requirement is,
X--->Y---->Z
'X' IS PARENT FOR 'Y' AND 'Y' IS PARENT FOR 'Z'
SO IN VALID COMBINTAIONS ARE
X
Z-------> THERE IS NO PARENT RECORD FOR 'Z'
Y
Z-------> THERE IS NO PARENT RECORD FOR 'Y'
Z-------> THERE IS NO PARENT RECORD FOR 'Z'
IN THE ABOVE CASES I WANT TO REJECT THE FILE.
TIA
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
You can try this,
stgFirstChar <- (default) ' '
stgXFound <- (default) 'N'
stgYFound <- (default) 'N'
stgZFound <- (default) 'N'
stgErrFound <- (default) 'N'
stgFirstChar <- left(link.record, 1)
stgErrFound <-
If (stgFirstChar = 'Z' and stgYFound = 'N') Or
(stgFirstChar = 'Y' and stgXFound = 'N') Then 'Y' Else 'N'
stgXFound <- if stgFirstChar = 'X' Then 'Y' Else stgXFound
stgYFound <- if stgFirstChar = 'Y' Then 'Y' Else stgYFound
stgZFound <- if stgFirstChar = 'Z' Then 'Y' Else stgZFound
Have the rows written to the output on the constraint that
(stgErrFound = 'Y')
stgZFound is optional for further processing. Also make the error message more meaningful to your requirement.
stgFirstChar <- (default) ' '
stgXFound <- (default) 'N'
stgYFound <- (default) 'N'
stgZFound <- (default) 'N'
stgErrFound <- (default) 'N'
stgFirstChar <- left(link.record, 1)
stgErrFound <-
If (stgFirstChar = 'Z' and stgYFound = 'N') Or
(stgFirstChar = 'Y' and stgXFound = 'N') Then 'Y' Else 'N'
stgXFound <- if stgFirstChar = 'X' Then 'Y' Else stgXFound
stgYFound <- if stgFirstChar = 'Y' Then 'Y' Else stgYFound
stgZFound <- if stgFirstChar = 'Z' Then 'Y' Else stgZFound
Have the rows written to the output on the constraint that
(stgErrFound = 'Y')
stgZFound is optional for further processing. Also make the error message more meaningful to your requirement.