Re: Program to Convert copybook to C structure



Richard wrote:

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.

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.

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.
.




Relevant Pages

  • Re: I need help!!
    ... Most COBOL environments have utilities available to create standard ... but you will still have to deal with the packed fields. ... If you DON'T have a COBOL compiler available you should still try and get ... I would also look at converting the ...
    (comp.lang.cobol)
  • Re: I need help!!
    ... trying to use the java based record editor program on sourceforge to ... Most COBOL environments have utilities available to create standard ... Write a small COBOL program to convert all the packed fields to ... Do you think my Java decimal package will help more people use Java on ...
    (comp.lang.cobol)
  • Re: I need help!!
    ... trying to use the java based record editor program on sourceforge to ... Most COBOL environments have utilities available to create standard ... but you will still have to deal with the packed fields. ... I would also look at converting the ...
    (comp.lang.cobol)
  • Re: VB vs C#
    ... By the way i just saw on a history path list that COBOL has it`s own line ... change your Fortran advice to the C# part. ... a kind of less complex language in the same area as Algol. ... Well for previous VB6 proggers i would definedly say move to VB.Net, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Is it always possible to write a COBOL program using only 1 sentence per paragraph?
    ... > restructure, it will definitely be cheaper to use a good tool. ... > Enterprise COBOL for z/OS. ... > dead code that it could not generate to the output program. ... > work through the panels to set my options and start a conversion ...
    (comp.lang.cobol)