“Command Option 1 ) ‘F’ (first unused ISN) returns the next highest unused ISN for the specified file in the ISN field. The “next unused ISN” is determined by referring to the file control block (FCB).”
I would think it returns TOPISN+1, but I don’t know for sure, I’ll try and let the forum know
Isn Reusage is switched off in my case and I am trying to identify the highest isn in use, i’ve used the binary search method and it has produced the results i wanted on ten separate files, the principal code is:-
RESET #HIGHEST-ISN
MOVE 1 TO #START-ISN
MOVE 999999999 TO #END-ISN
*
REPEAT UNTIL #HIGHEST-ISN > 0
*
COMPUTE #SEEK-ISN = ((#END-ISN + #START-ISN) / 2)
RESET #FOUND
READ FILE-XYZ BY ISN FROM #SEEK-ISN
IF #FOUND /* More than one record
DO #START-ISN = *ISN(0380)
RESET #HIGHEST-ISN
ESCAPE BOTTOM
DOEND
MOVE TRUE TO #FOUND
MOVE *ISN TO #HIGHEST-ISN
*
LOOP
IF NOT #FOUND #END-ISN = #SEEK-ISN
LOOP
WRITE ‘HIGHEST ISN IS’ #HIGHEST-ISN
I was hoping to get the highest ISN with a single hit, but this gets the job done so it will do.
Please note that ADAREP shows information from the File Control Block that is on disk. Nucleus might have an updated block in memory that has not been bufferflushed to disk yet. So ADAREP might show old values.
ADAREP is just a report and static snap shot of the file status at the time of reporting.
Same applies to finding the highest ISN by various techniques discussed so far because in a competing record maintenace environment once you have the highest ISN there is always possibility of new ones getting allocated by ADABAS for other users.
I reckon if there was a need for this, SAG would have provided a system variable. I am not sure about the application (usage) value of knowing the highest ISN.