Hello everyone,
I am new to SDXchange and Ascential. I need to validate certain data coming in from an outside client an place it in an output file:
My validations looks like this:
If [field 4] > 0, [field 5] should have a date, if not reject the record
If [field 5] has a date, [field 4] should have an amount grater than 0, if not reject the row.
Also,
If [field 6] > 0, [field 7] should have a date if not reject the record
If [field 7] has a date, [field 6] should have an amount grater than 0, if not reject the row.
I tried messing around with constraints and thought I would write if statments but realized that the constraints accepts expressions only . Am I correct about this?
I tried also to have two different transformers and one reject link with each transformer having one validation but that did not work well either.
Any suggestions will be much appreciated.
Emilio
Validating Data question
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 5
- Joined: Tue Oct 07, 2003 8:20 am
- Location: USA
How about adding simple constraint...
NotIsnull(field 5) AND field 4 > 0
And you are correct about the constraints they accept statments as mentioned above only. You can use the same contraint statement as above for your second condition.
I don't think you will need two transformers for the validation
I hope this helps.
Roshan.
NotIsnull(field 5) AND field 4 > 0
And you are correct about the constraints they accept statments as mentioned above only. You can use the same contraint statement as above for your second condition.
I don't think you will need two transformers for the validation
I hope this helps.
Roshan.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Re: Validating Data question
You can do it with one or two Transformers, depending on how you want to treat the rejects (into one file or into separate files).Emilio wrote:Hello everyone,
I am new to SDXchange and Ascential. I need to validate certain data coming in from an outside client an place it in an output file:
My validations looks like this:
If [field 4] > 0, [field 5] should have a date, if not reject the record
If [field 5] has a date, [field 4] should have an amount grater than 0, if not reject the row.
Also,
If [field 6] > 0, [field 7] should have a date if not reject the record
If [field 7] has a date, [field 6] should have an amount grater than 0, if not reject the row.
I tried messing around with constraints and thought I would write if statments but realized that the constraints accepts expressions only . Am I correct about this?
I tried also to have two different transformers and one reject link with each transformer having one validation but that did not work well either.
Any suggestions will be much appreciated.
Emilio
Create a Routine, of type "transform function", with four arguments.
The output constraint expression invokes this routine.
The result of the Routine is either 1 (= true), meaning all constraint requirements are satisfied, or 0 (= false), meaning that at least one of the constraint requirements was not satisfied.
Set up reject output links in the usual way.
Code: Select all
FUNCTION IsValidRow(F4, F5, F6, F7)
Ans = @FALSE ; * assume the worst
If F4 > 0 And F5 Matches "4N'-'2N'-'2N" And F6 > 0 And F7 Matches "4N'-'2N'-'2N"
Then
Ans = @TRUE
End
RETURN(Ans)
If all of the above meets your needs, observe that you could achieve the same result without a routine. The constraint expression would be
Code: Select all
F4 > 0 And F5 Matches "4N'-'2N'-'2N" And F6 > 0 And F7 Matches "4N'-'2N'-'2N"
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.