Hi!
I have a problem. I need to retrieve records within a range. I’m using a super descriptor in a FIND and limiting the range with start and end values, as follows:
1 #SUPER-1-START (A05)
2 #FLAG-1-ST (A01)
2 #YEAR-2 -ST (N04)
*
1 #SUPER-1-END (A05)
2 #FLAG-1-END (A01)
2 #YEAR-2-END (N04)
*******************************************************
#FLAG-1-ST := 'R'
#FLAG-1-END := 'S'
#YEAR-2 -ST := #YEAR-2-END := 2022
*
FIND VIEW WITH SUPER = #SUPER-1-START THRU #SUPER-1-END
But when I run my code, it returns me many records with values for YEAR different that 2022… I don’t understand why. Could somebody point me, please, what I’m doing wrong or explain me the reason for this behaviour?
Thanks in advance.
I would start by writing out what your keys are. Here’s a little sample program:
DEFINE DATA LOCAL
1 #SUPER-1-START (A05)
1 REDEFINE #SUPER-1-START
2 #FLAG-1-ST (A01)
2 #YEAR-2-ST (N04)
*
1 #SUPER-1-END (A05)
1 REDEFINE #SUPER-1-END
2 #FLAG-1-END (A01)
2 #YEAR-2-END (N04)
END-DEFINE
#FLAG-1-ST := 'R'
#FLAG-1-END := 'S'
#YEAR-2-ST := #YEAR-2-END := 2022
*
DISPLAY #SUPER-1-START
#SUPER-1-END
END
Running this program results in:
Page 1
#SUPER-1-START #SUPER-1-END
-------------- ------------
R2022 S2022
So you are doing a FIND of records between R2022 and S2022. Note that the Year is after the Flag so you are reading all R records from R2022 on and all S records up to and including S2022.
If you want only 2022 records, you would need a descriptor that has the year first.
Alternately, since R and S are sequential, you could write your FIND as:
FIND VIEW WITH SUPER = #SUPER-1-START OR = #SUPER-1-END
But that would only work in the special case where the flags you want are sequential and not so well if you are taking user input to fill your search keys.