Transformer Constraint and Rejects

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
vijayrc
Participant
Posts: 197
Joined: Sun Apr 02, 2006 10:31 am
Location: NJ

Transformer Constraint and Rejects

Post by vijayrc »

Hi,
I have this question. I have an input to transformer, and I want to reject few coming in based on few criteria, and the rest would be deviated thru various output links based on various constraints..How do i go about it.
The REST are those that don't match the criteria for the rejects.
Thanks
Vijay

I tried Reject[as an Ouptut1 link] and rest were defined as Otherwise with different constraint. but this didn't seem to work..still trying it out.
Any help is appreciated.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The Otherwise/Log output must be executed AFTER all other output links (except the Reject link, if you have one). Use the output link execution order tool (rightmost on the Transformer stage toolbar) to ensure that this is so.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

You can specify the constraints for all the output links then for the last link check mark as the reject.

Or specify the constraints and someone will set it up for you.

Sam
vijayrc
Participant
Posts: 197
Joined: Sun Apr 02, 2006 10:31 am
Location: NJ

Post by vijayrc »

us1aslam1us wrote:You can specify the constraints for all the output links then for the last link check mark as the reject.

Or specify the constraints and someone will set it up for you.

Sam
Say reject criteria is Cond 1 OR [Cond 2 And Cond3]=Reject output
For any other conditions other than the reject criteria, I need to deviate to Output 1 when Field 1=1
Output 2 when Field 2 =2
Output 3 when Field 3 =3
For records that meet the reject criteria, it might carry Field1=1 or Field2=2 or Field3=3 and I want these records tobe only rejected, and not Reject AND also flow thru other output links. {Hope I didn't confuse}
johnthomas
Participant
Posts: 56
Joined: Mon Oct 16, 2006 7:32 am

Post by johnthomas »

One way is not to have a reject link ,but to have the reject critireon as the constraint in one of the output links .That will work .
create a stage flag1. Have the expression return 0 if false otherwise return 1
eg:
IF cond1 or (cond2 =2 and cond3=3) then 1 else 0

For the 4 output link write constraints as follows

If flag1=0 and Field 1=1 then @TRUE else @FALSE
If flag1=0 and Field 2=2 then @TRUE else @FALSE
If flag1=0 and Field 3=3 then @TRUE else @FALSE
If flag1=0 then @TRUE else @FALSE ( this will have the rejected records,without designating the link as reject link)
JT
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

johnthomas wrote:If flag1=0 and Field 1=1 then @TRUE else @FALSE
If flag1=0 and Field 2=2 then @TRUE else @FALSE
If flag1=0 and Field 3=3 then @TRUE else @FALSE
If flag1=0 then @TRUE else @FALSE
:idea: You all do realize that this 'if then else' to simply set something to true or false is completely unnecessary, yes? Derivations can be expressions that automatically resolve to true or false without all the shenanigans. For example:
me wrote:flag1=0 and Field 1=1
flag1=0 and Field 2=2
flag1=0 and Field 3=3
flag1=0
Gets you the same results. Which also means that if you use this to set something like a Stage Variable to a boolean value that you also don't have to explicitly test against @TRUE either...

If svFred = @TRUE Then 'Y' Else 'N'

Can be expressed as:

If svFred Then 'Y' Else 'N'

Check for @FALSE by 'not'ing the expression:

If Not(svFred) Then 'N' Else 'Y'

FYI. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
johnthomas
Participant
Posts: 56
Joined: Mon Oct 16, 2006 7:32 am

Post by johnthomas »

Good suggestion chullett . I guess that is more appropriate in his case. He can use this approach in case all records rejected are not getting processed . I prefer the other approach since i need to process some of the records which are also rejected , so that we can report those as data which has defects but is that of different (lower ) exception level than the normal rejects . We dont do seperate data profiling , hence this approach
JT
vijayrc
Participant
Posts: 197
Joined: Sun Apr 02, 2006 10:31 am
Location: NJ

Post by vijayrc »

johnthomas wrote:Good suggestion chullett . I guess that is more appropriate in his case. He can use this approach in case all records rejected are not getting processed . I prefer the other approach since i need to process some of the records which are also rejected , so that we can report those as data which has defects but is that of different (lower ) exception level than the normal rejects . We dont do seperate data profiling , hence this approach
Thank you both. In my case, I want certain records to be rejected and not processed at all, while the ones that weren't rejected to be processed. Appreciate your help
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

So your non-reject links lead into other stage types that process them, while your Otherwise/Log link leads somewhere (a Sequential File stage perhaps, or a Copy stage with no outputs) where nothing happens.

Or, if you simply want to discard these input rows, have no Otherwise/Log and no Reject link at all.
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