# Alfanumeric superdescriptor assortment on FIND .. WITH ..THRU

**URL:** <https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134>\
**Category:** Forum\
**Tags:** Adabas-Natural, Adabas, Natural, NaturalONE\
**Created:** [April 3, 2024, 8:11pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134 "2024-04-03T20:11:11Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 3, 2024, 8:11pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/1 "2024-04-03T20:11:11Z")

</div>

During debugging a FIND … WITH … THRU loop I’ve gotten unexpected and undesired records.  
I’d like to understand the arranging behind the THRU option when the superdescriptor has an initial letter and numbers.  
Here’s an example:

```
DEFINE DATA LOCAL
	1 STATUS-TYPE-DEADLINE-INI (A13) 1 REDEFINE STATUS-TYPE-DEADLINE-INI
		2 STATUS (A01) /* N = NOT PROCESSED YET , S = SUCESSFULY PROCESSED 
		2 TYPE (N04) 
		2 DEADLINE (N08) /* AAAAMMDD
	1 STATUS-TYPE-DEADLINE-FIN (A13) 1 REDEFINE STATUS-TYPE-DEADLINE-FIN
		2 STATUS (A01)
		2 TYPE (N04)
		2 DEADLINE (N08)
...
STATUS-TYPE-DEADLINE-INI := N888820201201
STATUS-TYPE-DEADLINE-FIN := S888820201231
F3X. FIND CTRL-FILE WITH 
	STATUS-TYPE-DEADLINE = STATUS-TYPE-DEADLINE-INI
                      THRU STATUS-TYPE-DEADLINE-FIN
    SORTED BY STATUS-TYPE-DEADLINE
    ...
    END-FIND

```

The undesired record that I got:

```
	N888820210120
	(That is, this deadline is off the range)

```

Ultimately, my main doubt is why this record was selected even if the “numeric part of the string” is a larger number than the limit of the range.  
If someone could give an example of this arrangement, I appreciate it. I didn’t found this in the documentation.  
Comments:  
- I can’t use another superdescriptor and I don’t have subdescriptor  
- I can’t change the statuses  
- I’m considering using " WHERE DEADLINE GT … AND LT … " to avoid this record but I don’t know if this could work.  
- If the WHERE doesn’t work I think I could use REJECT or ACCEPT or IF … ESCAPE TOP .  
Any deliberation is welcome. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Eugene.Miklovich](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@Eugene.Miklovich](https://techcommunity.softwareag.com/u/Eugene.Miklovich)\
**Post date:** [April 3, 2024, 8:44pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/2 "2024-04-03T20:44:25Z")

</div>

I believe what you want is the equivalent below.

If you had any STATUS values of O, P, Q, R your query would get all of them…

FIND … WITH

STATUS-TYPE-DEADLINE = N888820201201  
THRU N888820201231  
OR

STATUS-TYPE-DEADLINE = S888820201201  
THRU S888820201231

Eugene (Gene) Miklovich  
ADABAS/NATURAL Systems Support and DBA  
Cell: 916-202-7047  
Normal Hours: 8am-4pm E.T.  
Please call or text if assistance needed outside these hours.

---

<div class="post-metadata">

**Author:** ![Douglas\_Kelly](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/douglas_kelly/32/102_2.png) [@Douglas\_Kelly](https://techcommunity.softwareag.com/u/Douglas_Kelly)\
**Post date:** [April 3, 2024, 8:45pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/3 "2024-04-03T20:45:41Z")

</div>

A few points to start:

- a READ on the super you have will perform the selection and sort far more efficiently than a FIND THRU SORTED.
- There is no difference between WHERE, ACCEPT/REJECT or IF ESCAPE TOP from the database processing point of view - the 3 approaches do the same database processing. The differences in Natural processing are that ACCEPT/REJECT or IF ESCAPE TOP can do other processing on the records before returning to the database statement (READ or FIND). The WHERE clause is applied before any other processing is done in the loop, so rejected records are not processed and are not counted in \*COUNTER (the other 2 are).

The records are selected based on the entire superdescriptor, not the components of the super. That is FIND file WITH STATUS = ‘N’ OR = ‘S’ and TYPE = ‘8888’ and DEADLINE = 20201201 thru 20201231 is NOT the same the FIND on the superdescriptor. The value “N888820210120” is between “N888820201201” and “S888820201231”, so it is selected - any “N” or “S” status value less than “S88882021231” will be selected

If you are looking for everything with the deadline between 20201201 and 20201231 and can only use the superdescriptor you have, then I would suggest trying this:  
for #I = 1 to 2  
if #i = 1  
STATUS-TYPE-DEADLINE-INI.STATUS := ‘N’  
else  
STATUS-TYPE-DEADLINE-INI.STATUS := ‘S’  
end-if  
STATUS-TYPE-DEADLINE-FIN.STATUS := STATUS-TYPE-DEADLINE-INI.STATUS  
READ CTRL-FILE WITH STATUS-TYPE-DEADLINE = STATUS-TYPE-DEADLINE-INI TO STATUS-TYPE-DEADLINE-FIN  
…  
END-READ  
END-FOR

Or Gene’s FIND/OR works but with more database work.

---

<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:** [April 3, 2024, 8:46pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/4 "2024-04-03T20:46:37Z")

</div>

Tomas, the record N888820210120 is being returned because it is within your specified range, “N888820201201” through “S888820200123”. Your FIND as written would also return any records that had a status of O, P, Q, or R, as well as all records with status S with types lower than 8888.

I can only guess that you want records with Status = N or S, AND Type = 8888, AND Deadline between 12/1/2020 and 12/31/2020. If that is the case you could write it like this:

```auto
FIND CTRL-FILE WITH STATUS-TYPE-DEADLINE = 'N888820201201' THRU 'N888820201231'
                 OR STATUS-TYPE-DEADLINE = 'S888820201201' THRU 'S888820201231'
...

```

or, with variables for the keys:

```auto
STATUS-TYPE-DEADLINE-INI-N := 'N888820201201' 
STATUS-TYPE-DEADLINE-FIN-N := 'N888820201231'
STATUS-TYPE-DEADLINE-INI-S := 'S888820201201' 
STATUS-TYPE-DEADLINE-FIN-S := 'S888820201231'

FIND CTRL-FILE WITH 
          STATUS-TYPE-DEADLINE = STATUS-TYPE-DEADLINE-INI-N THRU STATUS-TYPE-DEADLINE-FIN-N
       OR STATUS-TYPE-DEADLINE = STATUS-TYPE-DEADLINE-INI-S THRU STATUS-TYPE-DEADLINE-FIN-S
...

```

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [April 3, 2024, 8:49pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/5 "2024-04-03T20:49:03Z")

</div>

Adabas is giving you what you asked for:  
N888820201201 thru N999999999999  
all O, P, Q, R records  
S000000000000 thru S888820201231

I think what you want is

```auto
FIND CTRL-FILE WITH STATUS-TYPE-DEADLINE = 'N888820201201'
                                      THRU 'N888820201231'
                 OR STATUS-TYPE-DEADLINE = 'O888820201201'
                                      THRU 'O888820201231'
                 OR STATUS-TYPE-DEADLINE = 'P888820201201'
                                      THRU 'P888820201231'
                 OR STATUS-TYPE-DEADLINE = 'Q888820201201'
                                      THRU 'Q888820201231'
                 OR STATUS-TYPE-DEADLINE = 'R888820201201'
                                      THRU 'R888820201231'
                 OR STATUS-TYPE-DEADLINE = 'S888820201201'
                                      THRU 'S888820201231'

```

By the way, the SORTED BY clause is never a good idea. It is likely to cause performance issues. I think you need a subdescriptor on DEADLINE or TYPE-DEADLINE.

---

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 3, 2024, 8:51pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/6 "2024-04-03T20:51:40Z")

</div>

The point is that for any status i need to ensure the deadline within the limits, avoiding the numeric parts that are off the range.

---

<div class="post-metadata">

**Author:** ![wolfgang.winter](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wolfgang.winter/32/17954_2.png) [@wolfgang.winter](https://techcommunity.softwareag.com/u/wolfgang.winter)\
**Post date:** [April 3, 2024, 8:55pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/7 "2024-04-03T20:55:59Z")

</div>

This superdescriptor, as designed, will NOT give you what you are looking for.

If the DEADLINE is the primary criterion you will need to move it in front of STATUS and TYPE.

---

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 3, 2024, 9:24pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/8 "2024-04-03T21:24:07Z")

</div>

The domain of the status field for now is just [N, S].  
Now I understand that ADABAS will bring all N records up to the limit (N999999999999) before moving to the next status

---

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 3, 2024, 9:26pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/9 "2024-04-03T21:26:16Z")

</div>

I thought that SORTED could improve the performance. I think I can remove it.

---

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 3, 2024, 9:31pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/10 "2024-04-03T21:31:59Z")

</div>

I didn’t know we can use WITH … OR .  
Maybe this is a good approach for now, because I don’t want to change a lot the program.

---

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 3, 2024, 9:42pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/11 "2024-04-03T21:42:11Z")

</div>

Thanks for the tip. Maybe I’ll write a test version using READ.

---

<div class="post-metadata">

**Author:** ![Eugene.Miklovich](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@Eugene.Miklovich](https://techcommunity.softwareag.com/u/Eugene.Miklovich)\
**Post date:** [April 4, 2024, 1:28pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/12 "2024-04-04T13:28:40Z")

</div>

You will either need two READS: 1 for N series and 1 for s seriers, or

A READ with a reposition to “S…” when it gets to end of N series……

Eugene (Gene) Miklovich

ADABAS/NATURAL Systems Support and DBA

Cell: 916-202-7047

Normal Hours: 8am-4pm E.T.

Please call or text if assistance needed outside these hours.

---

<div class="post-metadata">

**Author:** ![Eugene.Miklovich](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@Eugene.Miklovich](https://techcommunity.softwareag.com/u/Eugene.Miklovich)\
**Post date:** [April 4, 2024, 1:30pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/13 "2024-04-04T13:30:41Z")

</div>

Just remember to use OR not AND.

In English we say AND but in logic we need OR.

Eugene (Gene) Miklovich

ADABAS/NATURAL Systems Support and DBA

Cell: 916-202-7047

Normal Hours: 8am-4pm E.T.

Please call or text if assistance needed outside these hours.

---

<div class="post-metadata">

**Author:** ![Eugene.Miklovich](https://avatars.discourse-cdn.com/v4/letter/e/ce73a5/32.png) [@Eugene.Miklovich](https://techcommunity.softwareag.com/u/Eugene.Miklovich)\
**Post date:** [April 4, 2024, 1:32pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/14 "2024-04-04T13:32:23Z")

</div>

SORTED does internal ADABAS SORT which sometimes is costly.

If you need data sorted I recommend READ LOGICAL as per other response (READ… REPOSITION).

Eugene (Gene) Miklovich

ADABAS/NATURAL Systems Support and DBA

Cell: 916-202-7047

Normal Hours: 8am-4pm E.T.

Please call or text if assistance needed outside these hours.

---

<div class="post-metadata">

**Author:** ![Tomas\_Moraes](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/tomas_moraes/32/6982_2.png) [@Tomas\_Moraes](https://techcommunity.softwareag.com/u/Tomas_Moraes)\
**Post date:** [April 4, 2024, 2:51pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/15 "2024-04-04T14:51:04Z")

</div>

Thank you for the clarification on ADABAS processing versus NATURAL processing. It is a very important point to consider.

---

<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:** [October 1, 2024, 2:51pm UTC](https://techcommunity.softwareag.com/t/alfanumeric-superdescriptor-assortment-on-find-with-thru/294134/16 "2024-10-01T14:51:50Z")

</div>

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