To add to Crox's answer, there are loads of tools out there designed for this very purpose.
Starting with your own compiler detalied listing - which many programmers routinely ignore.
My favorite tool is DDL (Data Definition Language). I don't know of many tools better than DDL - which can generate COPYable source (of a record definition) for many languages. Invaluable when using COBOL and other languages to exchange data.
COMP fields have generated controversy and confusion very early on. COMP fields are the least compatible data types in COBOL. Not only do compilers and platforms disagree on their meaning, but other languages choke on it.
To their credit, COMP fields were useful when memory and storage were scarce. These days, its hard to justify its continued use. COBOL is increasingly sharing executables and data exchange services with other languages (ILE, CRE, COM,...), and the single most stumbling block is COBOL specific data types such as COMP.
Luckily, many COBOL compiler designers have solved this problem by incorporating native data types in COBOL (my compiler allows the use of of a data type called NATIVE to describe binary data). Today, you can safely exchange INTEGER data types between COBOL and other languages - instead of trying to wrestle COMP fields into submission.
The major difference between COMP and INTEGER is in the minimum and maximum values they can hold.
COBOL does not have a proper equivalent data type to INTEGER (as seen in C, etc...). An integer can hold up to 5 digits (32,767 or 65,535 - unsigned). PIC 9(4) COMP holds up to only 4 digits: 9,999. And PIC 9(5) COMP goes to 99,999: more than an INTEGER can hold. But, COBOL NATIVE data types use the exact equivalent to INTEGER.
On my compiler, NATIVE-2 uses 2 bytes, NATIVE-4 uses 4 bytes, and NATIVE-8 holds 8 bytes. These data types translate exactly to integers such as short, long, double or whatever your OS or non-COBOL compiler supports.
When calling procedures written in a language other than COBOL, it is safer to use NATIVE data types rather than any of the other computational data types that COBOL supports. NATIVE eliminates data overflow and truncation. Simply find out how many bytes the INTEGER field on your platform is using and select the appropriate NATIVE type.
Dimandja