The Longest Record of a File

Hello all!

With the utility ADAFIN, I can find out the longest record of a file (in bytes). Here’s the output of my adafin … usage=ds

Records:  Number      =    941,385
          Length: max =      3,170 , min  =         79 , avg    =     417.80

Is there a way to find out the ISN of this 3170-byte-record? I think there is a special reason, why this particular record is so long. But I have to prove this…

My best idea is: make a ADAULD of the whole file and write a script which does the wanted investigations by reading the unloaded file. But this solution would be very time consuming.

Any better ideas?

Instead of trying to use Adabas utilities, why not write a little Natural program to read the whole file and get it to tell you.

Peter

Because Natural returns decompressed records - they will all be the same length. Your “little program” would have to mimic Adabas’ compression routine. (Perhaps deleting trailing blanks in alpha fileds would be a close-enough approximation.) An unload (without decompression) will give you variable-length records, so you’d be able to find the longest one.

If you’re presuming that the differences in length are a factor of the number of PE and/or MU entries, then the “little program” could list ISNs for the records with the largest count fields (C*).

You can get this info - both the compressed and uncompressed length - by writing your own direct call program, either in NAT or C.

If you issue an Lx command, the additions 2 field contains 2 half words, the first being the compressed length and the second is the uncompressed length.

If you write a program in NAT, use the USR1043N interface to make the direct call.

At one time I had a NAT program that read an entire file physically using an L2 call and calculated the longest and average lengths (compressed and uncompressed). A quick cursory look of my personal archive doesn’t find it, but if I do find it, I will upload it.

Kind regards,
Ray Mullins

Good hint! This helps me! Here’s my try - it’s working! :slight_smile:

define data local
*
1 CONTROL-BLOCK  (A80)
1 REDEFINE CONTROL-BLOCK
[snip] /* please have a look at USR1043P
1 RESPONSE      (I04)
*
1 #ISN          (I04)
1 #length-B     (B02)
1 REDEFINE #length-B
  2 #COMPRESSED-LENGTH (I02)
*
end-define
*
REPEAT
*
RESET CB-DBID CB-FNR CB-RSP CB-ISN CB-ISL CB-ISQ CB-FBL
      CB-RBL CB-SBL CB-VBL CB-IBL CB-RESERVED
*
  CB-CMD := 'L2'    /* read physical Command
  CB-CID := '0001'  /* Command ID
  CB-RSP := 010     /* UDB
  CB-FNR := 010     /* File
  CB-FBL := H'03'   /* Format buffer length
  CB-RBL := H'01'   /* Record buffer length
  FORMAT-BUFFER := 'AA.'    /* any field
*
  CALLNAT 'USR1043N'
    CONTROL-BLOCK  FORMAT-ADDR  RECORD-ADDR  SEARCH-ADDR
    VALUE-ADDR     ISN-ADDR     RESPONSE
*
  IF RESPONSE = 0
    #length-B := CB-ADD2
    #ISN := CB-ISN
    display CB-ISN CB-ADD2 (EM=HHHHHHHH) #ISN #COMPRESSED-LENGTH
  ELSE
    ESCAPE BOTTOM
  END-IF
*
END-REPEAT
*
IF RESPONSE NE 0 AND RESPONSE NE 3
  WRITE 'ADABAS response code (L2):' RESPONSE
END-IF
*
RESET CB-DBID CB-FNR CB-RSP CB-ISN CB-ISL CB-ISQ CB-FBL
      CB-RBL CB-SBL CB-VBL CB-IBL CB-RESERVED
*
CB-CMD := 'RC'        /* Release Command
CB-CID := H'00000000'
*
CALLNAT 'USR1043N'
  CONTROL-BLOCK  FORMAT-ADDR  RECORD-ADDR  SEARCH-ADDR
  VALUE-ADDR     ISN-ADDR     RESPONSE
*
IF RESPONSE NE 0
  WRITE 'ADABAS response code (RC):' RESPONSE
END-IF
*
END

Great! Glad I could help! :smiley:

Please to see that a little Natural program solved your issues :lol:

Peter

But you have to admit that the ADABAS L2-command does the job, not the NATURAL-Program :wink: