Re: Cobol Copybook Parsing

From: Robert Jones (rjones0_at_hotmail.com)
Date: 07/02/04


Date: 1 Jul 2004 16:48:56 -0700

Hello Ed,

posting interspersed and at the end

ed_narayanan@yahoo.com (Ed) wrote in message news:<64c2ece4.0407010650.45e1c30d@posting.google.com>...
> Hi,
> I am a java programmer trying to parse cobol copybooks and convert
> them to xsd.
> I was wondering if there were any sample copybooks and associated data
> available anywhere on the net ? The problem is that I am still wading
> thru cobol, so I tht those samples would help clear some doubts.
> Either ways if anyone else has an idea then please answer/confirm the
> following:
>
> 1. Firstly I have concluded that all fields in cobol are fixed
> length(except for some DEPENDING ON stuff taht I have to read.). What
> would be the size of a field which has a V(decimal point). Would the
> data in the file have a "." or only the digits.

          Yes, all fields in COBOL are fixed length according to their
definitions, with the exception of data items containing the depending
on phrase of the occurs clause in their own or their subordinate
entries.

          V for a decimal point indicates an implied decimal point, it
occupies no storage. If a "." actual decimal point is used instead,
then that does occupy a byte and can only be used in edited numeric
data items, which are always of usage display or national.
>
> 2. Similarly for edited numerics and alphanumerics would the data file
> contain the edits like $,. etc. i.e are they in the data or are they
> inserted.
>
          Yes the data file would contain these characters, as per the
actual decimal point "." and each occupy a byte.

> 3. PIC S9(5)V9(2) ... Would the size of this be 7(5+2) ?
>
          The space occupied will depend upon the USAGE clause of the
data item. For usage DISPLAY, which is the default and is probably
what you are currently thinking of, Each digit occupies a character
position, with the exception of the S (for the sign) and the V for the
implied decimal point. The sign of the field is usually held as a
"tweak" to the first or last decimal digit, the exception is where the
SEPARATE phrase is used in the SIGN clause of the data item, in which
case the sign is stored in a separate character. The default for the
SIGN clause, whether or not the SIGN clause is actually written in a
data definition, is that the sign is not separate.

          Yes the siz of your example would be 7 characters/bytes.
 
> 4. Is data arranged sequentially in these files, one record after
> another with no delimeters?
>
          Yas, normally, but there is an option in many compilers to
use a file definition that includes the term "line sequential", in
which case each record is terminated by a line feed or carriage return
as per the compiler in use.

> Thanks,
> Ed

More generally, I advise you to obtain the manuals for the compiler
with which the programs are used. Two types of manual are of
particular interest, the language reference manual, which gives the
syntax of the COBOL for the specific compiler, and the programmer's
guide, which shows how to put the statements together, compile, link
and execute, etc, with examples. Most vendors have their manuals
online, in particular I know that IBM and Microfocus definitely do and
are free, unlike their compilers.

In the numeric data definitions, you may come across the words COMP,
COMP-3, PACKED-DECIMAL, COMP-n where n is a number. These specify the
usage of the numeric data items and allow the storage to be compressed
and make numeric operations much more efficient, you will definitely
want to read the manual if you come across them.

good luck,

Robert



Relevant Pages

  • Scanned FDR2056-101A COBOL manual
    ... I obtained a copy of the 1980 Prime COBOL ... system information which certainly appeared in other Prime manuals was ... Note that there was a later CBL compiler for the COBOL 85 ...
    (comp.sys.prime)
  • Re: Help needed with IFKCBL00
    ... That product was followed by OS/VS COBOL (and Release 2.4 was the ... All of these used the "IKFCBL00" program name. ... some of the ancient COBOL manuals. ... > Among others I have a COBOL compiler, ...
    (comp.lang.cobol)
  • Re: invoking a method
    ... The use of SET as shown here, will not work outside the Fujitsu Object COBOL ... invoke DBObject ... I will admit I have not worked on anyone else's Cobol compiler so I ... typical reference manual for a Cobol Compiler will have line and box based ...
    (comp.lang.cobol)
  • Re: C03 abend when omitting CEE.SCEERUN from JCL
    ... The AMODE, RMODE, RENT, and RES information are link-edit information, not ... "compiler option" information. ... VS Cobol Program is actually OS/VS Cobol (amblist shows 5740CB103 as ... Do you mean VS COBOL II or OS/VS COBOL? ...
    (bit.listserv.ibm-main)
  • Re: COBOL Compiler for Windows
    ... rebadged Micro Focus compiler. ... to run TSO/SPF on your mainframe. ... Or maybe he wants a mainframe emulation environment, ... Why would a small developer pay several thousand for a .NET COBOL ...
    (comp.lang.cobol)