# Find with superdescriptor limiting range

**URL:** <https://techcommunity.softwareag.com/t/find-with-superdescriptor-limiting-range/265034>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, natural-mainframe\
**Created:** [October 21, 2022, 8:39pm UTC](https://techcommunity.softwareag.com/t/find-with-superdescriptor-limiting-range/265034 "2022-10-21T20:39:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Priscilla\_G\_Souza](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@Priscilla\_G\_Souza](https://techcommunity.softwareag.com/u/Priscilla_G_Souza)\
**Post date:** [October 21, 2022, 8:39pm UTC](https://techcommunity.softwareag.com/t/find-with-superdescriptor-limiting-range/265034/1 "2022-10-21T20:39:06Z")

</div>

#### 

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![Jerome\_LeBlanc](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/jerome_leblanc/32/111_2.png) [@Jerome\_LeBlanc](https://techcommunity.softwareag.com/u/Jerome_LeBlanc)\
**Post date:** [October 21, 2022, 9:04pm UTC](https://techcommunity.softwareag.com/t/find-with-superdescriptor-limiting-range/265034/2 "2022-10-21T21:04:00Z")

</div>

I would start by writing out what your keys are. Here’s a little sample program:

```auto
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:

```auto
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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 19, 2023, 9:04pm UTC](https://techcommunity.softwareag.com/t/find-with-superdescriptor-limiting-range/265034/3 "2023-04-19T21:04:52Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
