SEQ_FILE

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
pandu80
Participant
Posts: 50
Joined: Fri Apr 08, 2005 5:56 pm

SEQ_FILE

Post by pandu80 »

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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandu80
Participant
Posts: 50
Joined: Fri Apr 08, 2005 5:56 pm

Post by pandu80 »

Hi,
After 'x' record there should be atleast one 'Y' and one 'Z" record.If there is no 'Y' and 'Z' records for the corresponding 'X' record i want to reject the file.

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

Post by ray.wurlod »

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).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandu80
Participant
Posts: 50
Joined: Fri Apr 08, 2005 5:56 pm

Post by pandu80 »

Ray,
Iam not able to make that logic.
could yo please explain me bit more.

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

Post by ray.wurlod »

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
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandu80
Participant
Posts: 50
Joined: Fri Apr 08, 2005 5:56 pm

Post by pandu80 »

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
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

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.
Post Reply