Application Delivery Management
Application Modernization & Connectivity
CyberRes by OpenText
IT Operations Management
How do I generate a file of test data for testing COBOL syntax?
There is a website, http://www.briandunning.com/sample-data/, that has free sample data for testing. They are 500 records. For a nominal price, you can download even larger data.
The files are comma delimited and line sequential. Therefore, a basic COBOL program can be written to format the data into a usable format.
For example, to test sorting, I downloaded a real estate file that contained the fields: street, city, zip, state,
beds, baths, sq__ft, type, sale_date, price, latitude, longitude.
The following program allowed me to turn the comma delimited file into a formated COBOL sequential file:
program-id. Program1 as "Program1". environment division. configuration section. input-output section. file-control. select infile assign to "realestate.csv" organization is line sequential. select outfile assign to "realestate.dat". data division. file section. fd infile. 01 in-rec pic x(120). fd outfile. 01 out-rec pic x(120). working-storage section. 01 rec-size pic 9(5). 01 ws-eof pic x value "n". 88 at-end value "y". 01 ws-rec. 05 out-address pic x(36). 05 out-city pic x(16). 05 out-zip pic 9(05). 05 out-state pic x(02). 05 out-bedrm pic x(01). 05 out-bath pic x(01). 05 out-sqft pic 9(05). 05 out-type pic x(12). 05 out-saledate pic x(24). 05 out-price pic 9(6). 05 out-lat pic 99V9(6). 05 out-long pic s9(3)V9(4). procedure division. main-para. open input infile. open output outfile. read infile at end set at-end to true. perform 100-read until at-end. close infile, outfile. goback. 100-read. read infile at end set at-end to true go to 100-exit not at end unstring in-rec delimited by "," into out-address out-city out-zip out-state out-bedrm out-bath out-sqft out-type out-saledate out-price out-lat out-long end-unstring end-read. write out-rec from ws-rec. 100-exit. exit. end program Program1.