Highest ISN on ADABAS file

Hi,

Does anybody know a quick way of writing a natural program to determine the highest ISN on an ADABAS file ?

I did think of reading by ISN DESCENDING, have since realised DESCENDING clause can only be used on logical keys.

Any help appreciated.

Two options coming to my mind:

a) Set up a “binary search” using GET to peek at specific ISNs

b) use USR1043N to issue a direct call L1 with command option 1 = ‘F’, which will return the first unused ISN

What does “unused” mean? If ISN-reusage is turned on, does your command really return the highest ISN plus one? Or just the next free one?

From the documentation

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 :wink:

Hi,

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.

Thanks for the input.

I used USR1043P and modified it as follows:

ASSIGN CB-CMD     = 'L1'                 
ASSIGN CB-FILE    = <fnr>                    
ASSIGN CB-DBID    = <dbid>                
ASSIGN CB-COP1    = 'F'                  
/*                                       
CALLNAT 'USR1043N' CONTROL-BLOCK         
  FORMAT-ADDR RECORD-ADDR SEARCH-ADDR    
  VALUE-ADDR ISN-ADDR RESPONSE           
/*                                       
WRITE CB-ISN    

The output is TOPISN+1 for both files with and without REUSEISN.

I think if we are allowed to produce report on DB then we can run ADAREP to get TOP-ISN / MAX-ISN for given file number.

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.

Mogens is right.

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.

Looks like Command Option “F” is only available on Mainframe. L1 with COP1=“F” doesn’t work on Open Systems…

Now I need it for replication purposes.