Problem with OR logic in constraint

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
maryann
Participant
Posts: 6
Joined: Mon Jun 13, 2005 9:42 am

Problem with OR logic in constraint

Post by maryann »

This is in mainframe job.

My constraint reads something like this:

Code: Select all

(field1 > ' ' OR field2 ='N') AND ENDOFDATA IS FALSE
field2 is stage variable checks for a numeric field value and sets 'Y' if it is spaces or lowvalues or zero else 'N'.

Problem:
when field1 is put to spaces or low values , even if field2 ='N' (i.e., valid non-zero numeric value), it bypasses the record in the o/p file.

I have tried various alternatives to this solution but end result is still the same :( . Can any one suggest where the problem could be.

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

Post by ray.wurlod »

Welcome aboard! :D

Are field1 and field2 columns from an upstream stage, stage variables, or what?

What is the data type of field1? How does it get its value assigned? Are you confident that field2 is being calculated correctly? Have you checked - perhaps by dumping a copy of the input stream into a text file and viewing that - what values field1 and field2 are getting?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
maryann
Participant
Posts: 6
Joined: Mon Jun 13, 2005 9:42 am

Post by maryann »

ray.wurlod wrote:Welcome aboard! :D

Are field1 and field2 columns from an upstream stage, stage variables, or what?

What is the data type of field1? How does it get its value assigned? Are you confident that field2 is being calculated correctly? Have you checked - perhaps by dumping a copy of the input stream into a text file and viewing that - what values field1 and field2 are getting?
Thanks Ray.
field1 one is PICX(2), and it is coming from source stage(MFF),
and regarding field2 it is a stage variable and when I use just field2 ='N' as constraint I am getting the expected result so I am confident about it.
And only problem comes when I use multiple checks with OR like

Code: Select all

(field1 >' ' OR field2 ='N') AND ENDOFDATA IS FALSE 
field1 must be > ' ' otherwise o/p record doesnt show up regardless of field2 value.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In the comparison for field1, is the constant on the right hand side two characters long (that is, compliant with PIC X(2))? That is, are you comparing field1 against a string containing two space characters.

Clutching at straws a little here. Can you also try surrounding the second expression with parentheses?

Code: Select all

(field1 >'  ' OR field2 ='N') AND (ENDOFDATA IS FALSE)
I know it shouldn't make any difference, but stranger things have fixed problems!

You might also try reversing the logic in the OR expression.

Code: Select all

(field2 = 'N' OR field1 > "  ") AND (ENDOFDATA IS FALSE)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
maryann
Participant
Posts: 6
Joined: Mon Jun 13, 2005 9:42 am

Post by maryann »

ray.wurlod wrote:In the comparison for field1, is the constant on the right hand side two characters long (that is, compliant with PIC X(2))? That is, are you comparing field1 against a string containing two space characters.

Clutching at straws a little here. Can you also try surrounding the second expression with parentheses?

Code: Select all

(field1 >'  ' OR field2 ='N') AND (ENDOFDATA IS FALSE)
I know it shouldn't make any difference, but stranger things have fixed problems!

You might also try reversing the logic in the OR expression.

Code: Select all

(field2 = 'N' OR field1 > "  ") AND (ENDOFDATA IS FALSE)
Two spaces or one space it should not matter. All I need is character values greater than spaces. I agree you never whats lurking inside,I tried all different combinations but I will try it tommorow and will let you know.

Code: Select all

(field2 = 'N' OR field1 > "  ") AND (ENDOFDATA IS FALSE)

Thanks for your valuable time and suggestion.
maryann
Participant
Posts: 6
Joined: Mon Jun 13, 2005 9:42 am

Post by maryann »

I tried all sorts like:

Code: Select all

(field2 = 'N' OR field1 > "  ") AND (ENDOFDATA IS FALSE)
((field2 = 'N') OR (field1 > "  ")) AND (ENDOFDATA IS FALSE)
 and vice versa


Nothing seems to work. If it matters, field1 is normalized variable of OCCURS clause and field2 also sets its value based on Numeric i/p variable , which is also Normalized from OCCURS. Both OCCUR equal number of times.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Maryann,

can you modify your job to see which part of the OR isn't working as expected? My suspicion is that the
(ENDOFDATA IS FALSE)
part isn't doing it - but it is unfounded and I don't have a 390 to try out.
maryann
Participant
Posts: 6
Joined: Mon Jun 13, 2005 9:42 am

Post by maryann »

ArndW wrote:Maryann,

can you modify your job to see which part of the OR isn't working as expected? My suspicion is that the
(ENDOFDATA IS FALSE)
part isn't doing it - but it is unfounded and I don't have a 390 to try out.
well
(ENDOFDATA IS FALSE AND FIELD1 > ' ')
was original condition to start with which was functioning well, but due to the change in requirement another OR condition was added along with field1.
I did similar kind of thg for other jobs but in thatall the fields in the constraint were PICX. So I am guessing sthg fishy when you use PICX field ORed with NUMERIC field.
Post Reply