The Question is:
Within 'C' how do I read an RMS file created using cobol which has comp fields
The Answer is :
Reading the file is not a particular problem, files simply contain bytes
of data. Interpreting the packed decimal values from within a C program
is the issue here, since C doesn't have native support for this data type.
You can find data type conversion routines in the OTS$ library, or
using the appropriate descriptors, LIB$CVT_DX_DX can convert between
most data types.
Alternatively, you could write your file access routines in COBOL and
have the fields passed back into C in whatever data type you like, use
COBOL to perform the conversions.
If you can't use COBOL, you could choose another language that supports
packed decimal. (eg: BASIC.)
Note however, that there are often very good reasons for choosing to
use packed decimal to represent data, so you need to be careful in
choosing the data type you convert into for C. For example,
calculations involving money should never be performed using floating
point data types as floating point arithmetic is necessarily somewhat
If you were to visit the AskQ website (<http://www.itrc.hp.com/service/james/CPQhome.do>) and
use a query such as the following against the OpenVMS database:
An example of packed decimal in C?
You would find a C example of converting packed decimal to integer
listed among the available answers. There are various other examples
available via AskQ; in the OpenVMS support database. For sources of
support programs and examples, please see the OpenVMS FAQ.