(ACU)COBOL Vision File Conversion and Processing
In addition to data, indexed files contain information that maps the data to specified key values. This allows the file to be randomly accessed in key order. One or more keys may be used to create one or more indexes, allowing indexed file data to be read in more than one key order. Some indexed file formats place indexes and data in separate physical files, while others combine them in a single file.
Given the field layout of a Micro Focus ISAM or Vision index file, the SortCL program in the IRI CoSort data management package can extract the data, sort, convert, and otherwise manipulate it. The COBOL edition of the IRI NextForm data migration package performs a subset of SortCL functions, including: field reformatting, data-type and file-format conversion, data replication, and reporting.
The NextForm job scripts below demonstrate: the creation of a Vision file from a flat file, conversion from the Vision file to a flat file, and data repositioning in each case. See this article for a discussion of the source and target metadata in Vision environments.
Input file (chiefs12):
Truman, Harry S. 1945-1953 DEM MI 33 Eisenhower, Dwight D. 1953-1961 REP TX 34 Kennedy, John F. 1961-1963 DEM MA 35 Johnson, Lyndon B. 1963-1969 DEM TX 36 Nixon, Richard M. 1969-1973 REP CA 37 Ford, Gerald R. 1973-1977 REP NB 38 Carter, James E. 1977-1981 DEM GA 39 Reagan, Ronald W. 1981-1989 REP IL 40 Bush, George H.W. 1989-1993 REP TX 41 Clinton, William J. 1993-2001 DEM AR 42 George, Bush W. 2001-2009 REP CT 43 Barack, Obama H, 2009-2016 DEM HI 44
Conversion to Vision (fields repositioned in the output):
/INFILE=chiefs12.txt /PROCESS=RECORD /FIELD=(president,POSITION=1,SIZE=22) /FIELD=(service,POSITION=24,SIZE=9) /FIELD=(party,POSITION=36,SIZE=3) /FIELD=(state,POSITION=41,SIZE=2) /FIELD=(ordinal,POSITION=44,SIZE=2) /REPORT /OUTFILE=chiefs12VISION.dat /PROCESS=VISION /LENGTH=46 /FIELD=(ordinal,POSITION=1,SIZE=2) /FIELD=(president,POSITION=4,SIZE=22) /FIELD=(service,POSITION=27,SIZE=9) /FIELD=(party,POSITION=39,SIZE=3) /FIELD=(state,POSITION=44,SIZE=2)
The script above converts the chiefs12.txt file from the flat ASCII file into Vision Indexed format by creating two output files: chiefs12VISION.dat containing the data, and chiefs12VISION.vix containing the index information. Vision files are organized with a header and data segments, so there is empty space in this example.
A Hex dump of the Vision file indicates its unreadable nature:
Vision data file, chiefs12VISION.dat:
Offset(h)00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00000000 10 12 14 19 00 05 00 01 00 00 00 01 00 00 00 01 ................ 00000010 00 00 06 00 00 00 00 00 06 00 00 00 00 00 04 DC ...............Ü ... 00000070 00 00 0A 00 00 00 00 00 00 00 7F FF FA 00 00 00 ...........ÿú... 00000080 06 00 00 00 0A 00 00 00 00 00 00 00 00 00 00 00 ................ 00000090 00 00 00 00 00 00 00 00 2E 00 00 00 2E 01 00 00 ................ 000000A0 2E 00 63 72 65 61 74 65 64 20 62 79 20 41 43 55 ..created by ACU 000000B0 46 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FH.............. 000000C0 00 00 00 00 08 00 00 00 02 01 01 2E 00 2E 00 00 ................ .... 000001F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00000200 00 00 00 2E 00 00 00 2E 00 00 00 00 00 00 00 33 ...............3 00000210 33 20 54 72 75 6D 61 6E 2C 20 48 61 72 72 79 20 3 Truman, Harry 00000220 53 2E 20 20 20 20 20 20 20 31 39 34 35 2D 31 39 S. 1945-19 00000230 35 33 20 20 20 44 45 4D 20 20 4D 49 20 00 00 00 53 DEM MI ... 00000240 2E 00 00 00 2E 00 00 00 00 01 00 00 33 34 20 45 ............34 E 00000250 69 73 65 6E 68 6F 77 65 72 2C 20 44 77 69 67 68 isenhower, Dwigh 00000260 74 20 44 2E 20 20 31 39 35 33 2D 31 39 36 31 20 t D. 1953-1961 00000270 20 20 52 45 50 20 20 54 58 20 00 00 00 2E 00 00 REP TX ...... 00000280 00 2E 00 00 00 00 02 00 00 33 35 20 4B 65 6E 6E .........35 Kenn 00000290 65 64 79 2C 20 4A 6F 68 6E 20 46 2E 20 20 20 20 edy, John F. 000002A0 20 20 20 31 39 36 31 2D 31 39 36 33 20 20 20 44 1961-1963 D 000002B0 45 4D 20 20 4D 41 20 00 00 00 2E 00 00 00 2E 00 EM MA ......... 000002C0 00 00 00 03 00 00 33 36 20 4A 6F 68 6E 73 6F 6E ......36 Johnson 000002D0 2C 20 4C 79 6E 64 6F 6E 20 42 2E 20 20 20 20 20 , Lyndon B. 000002E0 31 39 36 33 2D 31 39 36 39 20 20 20 44 45 4D 20 1963-1969 DEM 000002F0 20 54 58 20 00 00 00 2E 00 00 00 2E 00 00 00 00 TX ............ .... 000005F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Vision index information, chiefs12VISION.vix:
Offset(h)00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00000000 10 12 14 18 00 05 00 00 00 00 0A 00 00 00 00 0D ................ 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ ... 000001F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00000200 03 00 00 00 00 00 00 00 00 00 00 00 00 30 00 00 .............0.. 00000210 33 33 20 54 72 75 6D 61 6E 2C 20 48 61 72 72 79 33 Truman, Harry 00000220 20 53 2E 20 20 20 20 20 20 20 31 39 34 35 2D 31 S. 1945-1 00000230 39 35 33 20 20 20 44 45 4D 20 20 4D 49 20 FF FF 953 DEM MI ÿÿ 00000240 FD C3 00 00 00 00 00 01 2E 02 34 20 45 69 73 65 ýÃ........4 Eise 00000250 6E 68 6F 77 65 72 2C 20 44 77 69 67 68 74 20 44 nhower, Dwight D 00000260 2E 20 20 31 39 35 33 2D 31 39 36 31 20 20 20 52 . 1953-1961 R 00000270 45 50 20 20 54 58 20 FF FF FD 86 00 00 00 00 00 EP TX ÿÿý†..... 00000280 02 2E 02 35 20 4B 65 6E 6E 65 64 79 2C 20 4A 6F ...5 Kennedy, Jo 00000290 68 6E 20 46 2E 20 20 20 20 20 20 20 31 39 36 31 hn F. 1961 000002A0 2D 31 39 36 33 20 20 20 44 45 4D 20 20 4D 41 20 -1963 DEM MA 000002B0 FF FF FD 49 00 00 00 00 00 03 2E 02 36 20 4A 6F ÿÿýI........6 Jo 000002C0 68 6E 73 6F 6E 2C 20 4C 79 6E 64 6F 6E 20 42 2E hnson, Lyndon B. 000002D0 20 20 20 20 20 31 39 36 33 2D 31 39 36 39 20 20 1963-1969 000002E0 20 44 45 4D 20 20 54 58 20 FF FF FD 0C 00 00 00 DEM TX ÿÿý.... ... 00000680 0A 2E 02 33 20 47 65 6F 72 67 65 2C 20 42 75 73 ...3 George, Bus 00000690 68 20 57 2E 20 20 20 20 20 20 20 20 32 30 30 31 h W. 2001 000006A0 2D 32 30 30 39 20 20 20 52 45 50 20 20 43 54 20 -2009 REP CT 000006B0 FF FF FB 61 00 00 00 00 00 0B 2E 02 34 20 42 61 ÿÿûa........4 Ba 000006C0 72 61 63 6B 2C 20 4F 62 61 6D 61 20 48 2C 20 20 rack, Obama H, 000006D0 20 20 20 20 20 32 30 30 39 2D 32 30 31 36 20 20 2009-2016 000006E0 20 44 45 4D 20 20 48 49 20 00 00 00 00 00 00 00 DEM HI ....... 000006F0 00 00 00 02 00 7F 00 00 00 00 00 00 00 00 00 00 ................ ... 000009F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
This NextForm job script converts the Vision input file to a flat ASCII output file, and demonstrates further field repositioning:
/INFILE=chiefs12VISION.dat /PROCESS=VISION /FIELD=(ordinal,POSITION=1,SIZE=2) /FIELD=(president,POSITION=4,SIZE=22) /FIELD=(service,POSITION=27,SIZE=9) /FIELD=(party,POSITION=39,SIZE=3) /FIELD=(state,POSITION=44,SIZE=2) /REPORT /OUTFILE=chiefs12.txt /PROCESS=RECORD /FIELD=(ordinal,POSITION=1,SIZE=2) /FIELD=(president,POSITION=4,SIZE=22) /FIELD=(party,POSITION=27,SIZE=3) /FIELD=(service,POSITION=33,SIZE=9) /FIELD=(state,POSITION=44,SIZE=2)
The re-converted and re-formatted output is:
33 Truman, Harry S. DEM 1945-1953 MI 34 Eisenhower, Dwight D. REP 1953-1961 TX 35 Kennedy, John F. DEM 1961-1963 MA 36 Johnson, Lyndon B. DEM 1963-1969 TX 37 Nixon, Richard M. REP 1969-1973 CA 38 Ford, Gerald R. REP 1973-1977 NB 39 Carter, James E. DEM 1977-1981 GA 40 Reagan, Ronald W. REP 1981-1989 IL 41 Bush, George H.W. REP 1989-1993 TX 42 Clinton, William J. DEM 1993-2001 AR 43 George, Bush W. REP 2001-2009 CT 44 Barack, Obama H, DEM 2009-2016 HI
All IRI product job scripts use the same metadata and command syntax, and run on Unix, Linux and Windows platforms. They are also supported in a free Eclipse GUI (called IRI Workbench), which can create, run, and manage the jobs. Click here for more information on the COBOL edition of IRI NextForm, and here for standard COBOL tools in IRI CoSort.