Re: COBOL format definitions?



Barb wrote:
Hi all,

I'm not a COBOL programmer at all, but I am starting to work with data
that was given to me with a COBOL field format listing. I get most of
the format codes, but there are a few that I need to verify that I'm
understanding them correctly.

For example, I understand that PIC X(03) is an alpha/numeric field
with a length of 3 characters.
I also understand that PIC 9(03) is a numeric integer field with
numbers <= 999.

But I would like to find some sort of online listing or guide to help
me as I encounter other ones such as:

* PIC S9(09) COMP-3

Five bytes, +123456789 looks like 12 34 56 78 9+

* PIC 9(02)V9(04)

Six bytes, 12.3456 looks like 31 32 33 34 35 36 (in ASCII on a PC)

* PIC S9(07)V99 COMP-3

Five bytes. +1234567.89 looks like: 12 34 56 78 9+ (note you can't tell from
the record where the decimal point is located).




I don't need to program an import file (I know that SAS can convert a
COBOL copybook to a SAS informat), but I would like to sound half-way
intellegent with the people who provided the copybook when I have
questions about the files.

Can anyone point me to a good website that just explains the basics of
what these codes mean (there are others besides the 3 above that I
would like to be able to interpret).

You bet there are others besides DISPLAY (the default) and COMP-3.


Thanks for any help you can provide!

Barb

Barb, understanding PIC defintions is a non-trivial undertaking. If you
follow these rules, you should be okay...

1. If the PIC contains ONLY digits and/or Xs, allow 1 byte for each
character.
2. If the PIC contains ONLY digits and a "V," allow one byte for each
character and the "V" locates the decimal point.
3. If the PIC contains ONLY digits and an "S," either the first or (usually)
the last digit is "over-punched" with the sign.
4. If the PIC explicitly (or implicitly*) contains COMP-x, or contains
editting characters "$" "Z" "." "," "CR" "DB" or anything else not
immediately clear, ask us.

--------
* "implicitly" = the format of a numeric field defaults to USAGE DISPLAY
(one byte per digit). Other representations are possible such as 1, 2, 4, or
8 byte binary (in two varieties: little-endian or big-endian), 4 or 8 byte
floating-point, and the one that drives other languages nuts: PACKED
DECIMAL. See the COMP-3 examples above.

BUT

SAS specifications seem to be able to handle the standard USAGE renditions.


.



Relevant Pages

  • Re: Add 4 20 digit numbers in C
    ... 20 digit integers and return the sum back to the COBOL program. ... The reason that COBOL has a limit of 18 digits is because the data ...
    (comp.lang.c)
  • Re: Old broken COBOL programs from the 70s and 80s
    ... the 'dates in which years were expressed in two digits'. ... packages such as SAP and Peoplesoft. ... Y2K was an unrecoverable loss of confidence in Cobol culture .. ...
    (comp.lang.cobol)
  • Re: Long numbers programming
    ... the powers of a number to see what patterns there are, ... It's not in COBOL, but if you go to my web site at ... (easily expandable to more digits). ... (Although you are of course free to ...
    (comp.lang.cobol)
  • Re: COBOL format definitions?
    ... I'm not a COBOL programmer at all, but I am starting to work with data ... that was given to me with a COBOL field format listing. ... COBOL copybook to a SAS informat), but I would like to sound half-way ...
    (comp.lang.cobol)
  • Re: Embedded SQL and MS ACCESS Dates
    ... I am trying to INSERT records as part of a load, into an ACCESS 2003 DB, from COBOL. ... With Access 97 I remember using floating point to update Date fields (the field contained the date as 8 digits on the left of the point, and the time as 4 digits on the right of the point) and this worked fine; ... Set the Host Variable to be pic xand used every date string you can imagine... ... I'm sure this should be simple, but a search of the web finds thousands of people having similar problems with inserting Date data onto Access DBs. ...
    (comp.lang.cobol)