Page 1 of 1

Transformer Constraint and Rejects

Posted: Thu Dec 21, 2006 7:23 pm
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.

Posted: Thu Dec 21, 2006 7:30 pm
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.

Posted: Thu Dec 21, 2006 7:30 pm
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

Posted: Thu Dec 21, 2006 7:34 pm
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}

Posted: Thu Dec 21, 2006 8:08 pm
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)

Posted: Thu Dec 21, 2006 9:16 pm
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:

Posted: Fri Dec 22, 2006 6:27 am
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

Posted: Fri Dec 22, 2006 6:29 am
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

Posted: Fri Dec 22, 2006 3:58 pm
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.