How to extract the records and generate reports