Friday, October 14, 2005

COBOL: EBCDIC File Formats

I had some file formats I had to import into a database for work and it was in a strange format I had never seen before.

05 RECORD1-RAW                          PIC X(17).
05 RECORD1-AREA REDEFINES RECORD1-RAW
10 REC2-RAW PIC 9(9).
10 REC2-AREA REDEFINES REC2-RAW
15 REC3-F1 PIC X(3).
15 REC3-F2 PIC X(2).
15 REC3-F3 PIC X(4).
10 REC2-FOOTER PIC S9(6)V99.


I saw the word EBCDIC, and I was clued in that I was not using ASCII. I read somewhere that Mac still uses EBCDIC.

http://www.natural-innovations.com/computing/asciiebcdic.html is Google's top link for EBCDIC. But here is a cleaner looking table comparing ascii and ebcdic: http://www.simotime.com/asc2ebc1.htm

Wikipedia's link: http://en.wikipedia.org/wiki/EBCDIC

But what finally helped was when I found: http://www.discinterchange.com/reading_COBOL_layouts_.html

and then used http://www.discinterchange.com/TechTalk_signed_fields_.html to figure out signed fields like above.

No comments: