Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Gathering test data


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.
           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.
           open input infile.
           open output outfile.
           read infile
               at end set at-end to true.
           perform 100-read
              until at-end.
           close infile, outfile.

           read infile
               at end set at-end to true
                  go to 100-exit
               not at end
                   unstring in-rec       delimited by ","
                       into out-address

           write out-rec from ws-rec.
       end program Program1.


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2014-12-16 13:57
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.