In [1]:
import cStringIO
import os,sys
import string
import adabas
from adabas.api import *
from adabas.datamap import *

In [2]:
DBID=12;FNR=12 # Vehicle file
STARTISN=0
RCOUNT=5
# define the mapping of data in record buffer to attributes
# of Vehicle class

# create datamap object for Vehicle-List
emp=Datamap('Vehicle',
    String('reg_num',      15),
    Bytes('chassis_num',    4),
    String('personnel_id',  8))

In [6]:
mask_bytes = lambda bytes : '{:<08}'.format(bytes.encode('hex').upper())

In [7]:
lines=''                                         
extraline=''                                     
alter=False                                      
c1=Adabas(rbl=256,fbl=64,sbl=32,vbl=128,ibl=0)   
c1.cb.dbid=DBID
c1.cb.fnr=FNR
c1.cb.cid='1010'                                 
c1.fb.value='AA,AB,AC.'

In [8]:
c1.cb.isn=STARTISN                                                                 
# use emp Datamap on record buffer                                                 
emp.buffer=c1.rb                                                                   
emp.offset=0                                                                       
                                                                                  
count=0                                                                            
                                                                                   
try:                                                                               
    for count in range(RCOUNT):                                                    
        c1.readByIsn(getnext=1)                                                    
                                                                                    
        lines += "{} - {} - {}\n".format(
                emp.reg_num,
                mask_bytes(emp.chassis_num),
                emp.personnel_id)
    extraline+= 'Sequential Read by ISN returned '+str(count+1)+' record(s).'
except DataEnd:
    extraline+= 'Sequential Read by ISN returned '+str(count)+' record(s).'
    pass
except DatabaseError, (line, apa):
    extraline+='</table><br>Database Error:'+line

In [9]:
print lines


344RG94 - 235B0000 - 50000100
401HH75 - 4C040000 - 50000200
999YH75 - 4C040000 - 50000300
65VW75 - B9820100 - 50000400
71KL75 - 9B720100 - 50000500


In [10]:
print extraline


Sequential Read by ISN returned 4 record(s).