Re: Program to Convert copybook to C structure
- From: Last Boy Scout <eggbtr@xxxxxxx>
- Date: Tue, 27 Dec 2005 01:56:39 -0600
Richard wrote:
These conversion type programs never work very well. You may need some kind of program in the middle to convert it or that can access it to convert things like packed fields and convert them to unpacked fields that can be accessed. Fortran reads packed numeric fields quite well.Is there a program that will convert a copybook record layout to a C structure?
It is unlikely to be useful to do that. Cobol has types of data that aren't implemented in C so you cannot just map a struct over a Cobol record and then expect to use the data items.
For example a Cobol alphanumeric data item may be PIC X(24) and this is space filled 24 characters. C would usually require a null terminator to make this a string and so would need to be char name[25] with null moved to name[24].
Numeric items may be display format with implied decimal point, or packed decimal or binary.
The data items will need extracting and converting into a C structure of your own devicing.
You could write a program to convert the copybook, but when you run into things like a Redefine statement how do you handle that? COBOL takes the same space and can address it differently under different conditions. For instance Fortran can do this because it uses the distance from the beginning of a record to describe a field. It also can access the right and left nibble in a packed field.
I never really studied Fortran, but I use a program that can read indexed VSAM Files and access them like TABLES. Not exactly SQL but pretty close. You will need to think about a conversion program in-between COBOL Files and ASCII Files. COBOL Can be used to unpack numeric fields and make them more readable. The program we use we sometimes use a COBOL program we can call that parses one record at a time.
.
- Prev by Date: Re: Making money from Java
- Next by Date: Re: Making money from Java
- Previous by thread: Zero supression and tinyCobol
- Index(es):
Relevant Pages
|