# How to READ/FIND Adabas file in breaks?

**URL:** <https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [February 25, 2012, 12:56pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783 "2012-02-25T12:56:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shashank\_Gite1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/shashank_gite1/32/351_2.png) [@Shashank\_Gite1](https://techcommunity.softwareag.com/u/Shashank_Gite1)\
**Post date:** [February 25, 2012, 12:56pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/1 "2012-02-25T12:56:49Z")

</div>

How to READ/FIND Adabas file in breaks?  
I am reading an Adabas file with certain criteria. I am reading only 10 records in one time ( In one Read/Find loop) and coming out of the loop…  
Now suppose the file is having 100 records satisfying my criteria. In my first Read/Find loop 1 to 10 records will be read, in the next loop how can I read 11 to 20 records, 21 to 30 records and so on…

---

<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:** [February 25, 2012, 1:34pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/2 "2012-02-25T13:34:31Z")

</div>

When you exit a loop … you exit a loop.

You will have to remember where you left and where you need to start  
the next loop, check into the RETAIN clause for FIND (it will help you to  
not having to create the result set over and over again), and the  
STARTING WITH clause for FIND and READ.

---

<div class="post-metadata">

**Author:** ![Shashank\_Gite1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/shashank_gite1/32/351_2.png) [@Shashank\_Gite1](https://techcommunity.softwareag.com/u/Shashank_Gite1)\
**Post date:** [February 25, 2012, 7:42pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/3 "2012-02-25T19:42:34Z")

</div>

I think if I save the \*ISN (in #ISN) of last record of every loop, the next loop can be started using WHERE \*ISN \> #ISN. Can it work correctly for all READ/FIND loops?

---

<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:** [February 25, 2012, 7:59pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/4 "2012-02-25T19:59:42Z")

</div>

NO, because you can NOT assume ISNs to be ascending when you read / find by descriptor !

That’s why I pointed you to [STARTING WITH](http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat427mf/sm/find.htm#operand5_find)

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [February 26, 2012, 4:29pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/5 "2012-02-26T16:29:55Z")

</div>

I am guessing that this question, in conjunction with your question on Maps, is indicative of an application where, for example, a user wants to scroll through all orders between two dates. Suppose there are 50 orders that satisfy the dates constraints. I am guessing you have designed a screen with ten lines (orders) for display and possible selection.

If this is indeed what the application is all about, and if a user would typically scroll through all (or at least most of) the records, it would probably be easier to code, and hence to maintain, your program to read all the records that satisfy the criteria and store them in an X-array. You could then control the starting and ending subscripts in the Map. Even better, you could also use Processing Rules, so that all the scrolling takes place in the Map, thus eliminating going back and forth from the program to the Map.

You can extend this concept to deal with even really large sets of records that satisfy the specified criteria.

steve

---

<div class="post-metadata">

**Author:** ![Shashank\_Gite1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/shashank_gite1/32/351_2.png) [@Shashank\_Gite1](https://techcommunity.softwareag.com/u/Shashank_Gite1)\
**Post date:** [February 26, 2012, 6:19pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/6 "2012-02-26T18:19:26Z")

</div>

Yes Steve! you got it right. I have already implemented an array of 1000 occurrence but Natural can’t read more then 1000 records in one READ loop in online mode. If there are more then 1000 records satisfying a criteria or user wants to read all the records in that case I’ll have to save last record address, close the loop and read again starting with the last address I stored previously.

---

<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:** [February 26, 2012, 6:39pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/7 "2012-02-26T18:39:03Z")

</div>

> [@Shashank Gite](#):
>
> Natural can’t read more then 1000 records in one READ loop in online mode

isn’t quite right, this is not a “natural” limitation, it’s one the Natural administrator sets.

And this limit is rather high, it doesn’t make sense to read-ahead even 1000 records “just in case”,  
how often will a user really page forward 80 or 100 pages and then back again ?

This is bad design, and if you need to take care of “scrolling” anyway - set the limit lower.

---

<div class="post-metadata">

**Author:** ![Shashank\_Gite1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/shashank_gite1/32/351_2.png) [@Shashank\_Gite1](https://techcommunity.softwareag.com/u/Shashank_Gite1)\
**Post date:** [February 26, 2012, 6:44pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/8 "2012-02-26T18:44:57Z")

</div>

I think 100 is the best size of array and in case user wants more then 100th record, I can save ISN of every 100th record and use STARTING WITH #ISN for fetching next 100 records .

---

<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:** [February 26, 2012, 6:50pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/9 "2012-02-26T18:50:58Z")

</div>

That sounds a lot more reasonable, yes 😉

---

<div class="post-metadata">

**Author:** ![Shashank\_Gite1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/shashank_gite1/32/351_2.png) [@Shashank\_Gite1](https://techcommunity.softwareag.com/u/Shashank_Gite1)\
**Post date:** [February 26, 2012, 6:54pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/10 "2012-02-26T18:54:53Z")

</div>

Thanks a lot Wolfgang and Steve for your so precious suggestions. 🙂

---

<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:** [February 27, 2012, 1:32am UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/11 "2012-02-27T01:32:04Z")

</div>

when working with a READ statement, you may be able to use the “STARTING WITH ISN” clause. See [http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat822mf/sm/read.htm](http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat822mf/sm/read.htm).

Note that the ISN you supply is not returned, but the next ISN is. This means you can readily keep track of the last ISN read (note that you also have to keep track of the last descriptor/superdescriptor value read) and supply those as the starting point when you re-enter the loop.

FIND loops, while not as easy to reposition, also shouldn’t be returning very large sets of results, particularly for online applications or you are wasting a lot of search effort.

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [February 28, 2012, 11:46am UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/12 "2012-02-28T11:46:16Z")

</div>

> [@Shashank Gite](#):
>
> I think if I save the \*ISN (in #ISN) of last record of every loop, the next loop can be started using WHERE \*ISN \> #ISN. Can it work correctly for all READ/FIND loops?

That would work for an unsorted find - because the default FIND-sort is by isn.

But as Douglas Kelly said, there’s maybe a better solution…

---

<div class="post-metadata">

**Author:** ![ZohebK](https://avatars.discourse-cdn.com/v4/letter/z/41988e/32.png) [@ZohebK](https://techcommunity.softwareag.com/u/ZohebK)\
**Post date:** [February 29, 2012, 9:09pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/13 "2012-02-29T21:09:57Z")

</div>

browse is done based on a key rt? save the key details as #Key depending upon whether up or down is pressed, example if next is choosen then move the key details of the last record on the screen to #Key and the 1st record if prev is choosen.read with starting from #key ascending / descending depending on what is selected. ignore the first record as it will be repeated. This will hit the database every time you hit prev or next

---

<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:** [February 29, 2012, 10:38pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/14 "2012-02-29T22:38:13Z")

</div>

> [@](#):
>
> ignore the first record as it will be repeated.

Unnecessary. You can avoid the overhead of reading and rejecting the starting record by following Douglas’ advice and coding the STARTING WITH ISN clause.

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [March 1, 2012, 7:48am UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/15 "2012-03-01T07:48:29Z")

</div>

> [@ZohebK](#):
>
> browse is done based on a key rt? save the key details as #Key depending upon whether up or down is pressed, example if next is choosen then move the key details of the last record on the screen to #Key and the 1st record if prev is choosen.read with starting from #key ascending / descending depending on what is selected. ignore the first record as it will be repeated. This will hit the database every time you hit prev or next

That would only work if the key is unique, right?

---

<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:** [March 1, 2012, 8:38am UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/16 "2012-03-01T08:38:32Z")

</div>

> [@Matthias](#):
>
> That would only work if the key is unique, right?

But it would be fun when you can’t scroll any further than Smith or Meier because  
there are more than a screen full - good learning effect 😉

---

<div class="post-metadata">

**Author:** ![ZohebK](https://avatars.discourse-cdn.com/v4/letter/z/41988e/32.png) [@ZohebK](https://techcommunity.softwareag.com/u/ZohebK)\
**Post date:** [March 1, 2012, 9:02am UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/17 "2012-03-01T09:02:02Z")

</div>

> [@Matthias](#):
>
> > [@ZohebK](#):
> >
> > browse is done based on a key rt? save the key details as #Key depending upon whether up or down is pressed, example if next is choosen then move the key details of the last record on the screen to #Key and the 1st record if prev is choosen.read with starting from #key ascending / descending depending on what is selected. ignore the first record as it will be repeated. This will hit the database every time you hit prev or next
> 
> That would only work if the key is unique, right?

yes it will work only for unique keys. sorry i forgot to mention

---

<div class="post-metadata">

**Author:** ![Nikolay\_Kuhta](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nikolay\_Kuhta](https://techcommunity.softwareag.com/u/Nikolay_Kuhta)\
**Post date:** [March 1, 2012, 4:17pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/18 "2012-03-01T16:17:31Z")

</div>

Well,  
To be more precise, “…that would only work if the key does not repeat itself more times than the scrolling screen size”. It`s unnecessary to require the absolute uniqueness of a key, as I think…

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [March 2, 2012, 10:19am UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/19 "2012-03-02T10:19:05Z")

</div>

> [@Nikolay Kuhta](#):
>
> To be more precise, “…that would only work if the key does not repeat itself more times than the scrolling screen size”.

I think it would be very confusing for the user, that “page down” is only half a screen sometimes …

---

<div class="post-metadata">

**Author:** ![Brian\_Johnson1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/brian_johnson1/32/163_2.png) [@Brian\_Johnson1](https://techcommunity.softwareag.com/u/Brian_Johnson1)\
**Post date:** [March 2, 2012, 2:23pm UTC](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783/20 "2012-03-02T14:23:20Z")

</div>

Is that really an issue when re positioning using the last ISN displayed within a non-unique descriptor value (see Douglas Kelly’s response)?

[Next page](https://techcommunity.softwareag.com/t/how-to-read-find-adabas-file-in-breaks/99783.md?page=2)
