reading stage variable in another stage

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
santosh
Premium Member
Premium Member
Posts: 28
Joined: Tue Jan 11, 2005 1:09 am
Location: London

reading stage variable in another stage

Post by santosh »

Is there any way where I can pass stage variable(transformer stage) to another stage in same job?

Incidence in my job:
I have to read a typical mainframe file having header, detail and trailer. In trailer there is count of detail records specific. My job needs to verify actual count of records with count provided in trailer.

I am counting total detail records in aggregator. Another stage uses column Import stage to get the count from trailer in a transformer stage.
Now I want to check both counts and abort job if they do not match?
Any Idea on how this can be done.

Also another requirement is I need to write message saying " Trailer records Msmatch" in Datastage joblog before aborting the job.

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

Post by ray.wurlod »

Add an extra column to the output link of the Transformer stage. The derivation for this column is the value of the stage variable. This remains available in downstream stages as far as you want to propagate it.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sachinkc
Participant
Posts: 34
Joined: Sat Apr 17, 2004 11:39 am
Location: USA

Re: reading stage variable in another stage

Post by sachinkc »

You can't. Stage variable stays in the Stage.

Ray's method is a good way. You can concatenate (with ":") any other value to it and propogate it downstream too.

- Sachin
Rgrds & Cheers!

Sachin
sachin@operamail.com
~Life always finds a way~
santosh
Premium Member
Premium Member
Posts: 28
Joined: Tue Jan 11, 2005 1:09 am
Location: London

Re: reading stage variable in another stage

Post by santosh »

sachinkc wrote:You can't. Stage variable stays in the Stage.

Ray's method is a good way. You can concatenate (with ":") any other value to it and propogate it downstream too.

- Sachin
Thanks Ray , Sachin:
I was trying to assign a job variable in transformerA and use it in another transformerB which is not downstream to this stage. But I am sure that transformer B will run after transformerA and I would access job varible to take decesion in transformerB.

Can I assign job variable in stage. Or any other way I can achieve above functionality?

regards,
Santosh
sachinkc
Participant
Posts: 34
Joined: Sat Apr 17, 2004 11:39 am
Location: USA

Re: reading stage variable in another stage

Post by sachinkc »

Store the o/p of xfmA in some temp file (which includes the value of xfmA Stage var), read it along with xfmA Stage var in xfmB.

- Sachin
santosh wrote:
Thanks Ray , Sachin:
I was trying to assign a job variable in transformerA and use it in another transformerB which is not downstream to this stage. But I am sure that transformer B will run after transformerA and I would access job varible to take decesion in transformerB.

Can I assign job variable in stage. Or any other way I can achieve above functionality?

regards,
Santosh
Rgrds & Cheers!

Sachin
sachin@operamail.com
~Life always finds a way~
santosh
Premium Member
Premium Member
Posts: 28
Joined: Tue Jan 11, 2005 1:09 am
Location: London

Re: reading stage variable in another stage

Post by santosh »

Thanks Sachin,


sachinkc wrote:Store the o/p of xfmA in some temp file (which includes the value of xfmA Stage var), read it along with xfmA Stage var in xfmB.

- Sachin
santosh wrote:
Thanks Ray , Sachin:
I was trying to assign a job variable in transformerA and use it in another transformerB which is not downstream to this stage. But I am sure that transformer B will run after transformerA and I would access job varible to take decesion in transformerB.

Can I assign job variable in stage. Or any other way I can achieve above functionality?

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

Post by ray.wurlod »

You could also store the value in the job's user status area, and retrieve it from there in TransformerB.
However, under the covers this does a write to disk anyway, so there's no gain (and there is some pain) in using this method.
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