For Programmers: Free Programming Magazines  


Home > Archive > Cobol > February 2007 > COBOL format definitions?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author COBOL format definitions?
Barb

2007-01-06, 6:55 pm

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
* PIC 9(02)V9(04)
* PIC S9(07)V99 COMP-3

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

Thanks for any help you can provide!

Barb

Vivian

2007-01-06, 6:55 pm

http://publibfp.boulder.ibm.com/cgi...RSTHIT#FIRSTHIT


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
> * PIC 9(02)V9(04)
> * PIC S9(07)V99 COMP-3
>
> 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).
>
> Thanks for any help you can provide!
>
> Barb


Michael Mattias

2007-01-06, 6:55 pm

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



Tutorial on COBOL datatypes : http://www.flexus.com/ftp/cobdata.zip (that's
direct, don't know if it works)
alternate: http://www.flexus.com/download.html, page down to COBDATA.ZIP and
download.

ZIP archive includes text and MS-DOS (yes, you heard correctly, MS-DOS)
software.

Interesting related info:
http://www.talsystems.com/tsihome_h...oads/C2IEEE.htm
That's a tutorial on "Using COBOL-created data in non-COBOL programs"


Michael C. Mattias
Author/contibutor of both
Tal Systems Inc.
Racine WI
mmattias@talsystems.com
http://www.talsystems.com


Donald Tees

2007-01-06, 6:55 pm

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
> *
> * PIC S9(07)V99 COMP-3
>
> 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).
>
> Thanks for any help you can provide!
>
> Barb
>

Comp fields of all sorts are platform dependent, so to give you
information, we need more. Usually they are word oriented fields, or BCD
nibble oriented fields.

The PIC 9(02)V9(04) fields and the numeric fields without the "V" are
always byte oriented numeric, with leading decimals. The V is an
implied decimal, so 123456 in a 9(02)V9(04) field is 12.3456, and
000123 is 0.01234, for example.

Most other characters in picture clauses are only used for editing, and
are not usually used for storing data. For example, a picture zz9.999
is a 6 digit plus actual decimal(a dot) with the decimal after the first
three digits, and zero supression on the first two digits. The field
would be 7 characters long. As a general rule, Cobol fields are fixed
length.

That should give you a start, anyway. Once you provide a platform and
compiler for the source of the data, someone should be able to give you
a hand on the comp fields.

Donald



HeyBub

2007-01-06, 6:55 pm

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.


Michael Russell

2007-01-06, 6:55 pm

Top post:

... and remember the inherited usages ...

e.g. if a level 05 contains level 07s & the 07s don't have
specific usages, they inherit from the 05
(is that quite right?)

'usage' = display, comp, comp-2, comp-3, comp-5, comp-x ...
if no 'usage' is declared, it's implicitly 'display', which
means one defined 'character' = 1 platform's byte (how else to
put that?)
'level' is a way of specifying a hierarchy of definitions of data.

e.g.

05 Name-and-Address.
07 Name pic x(20).
07 Address-1 pic x(20).
07 Zip pic x(7). or whatever.
I'm sure you probably understand that.

So, in the following, all the higher-numbered levels are comp-3:

05 Numeric-data comp-3.
07 First-numeric pic 99.
07 Second-numeric pic s9(3)v99.

.... more or less ... but there are odd instances where you
begin to wonder, depending on the compiler!

hth

Michael

HeyBub wrote:
> Barb wrote:
>
> Five bytes, +123456789 looks like 12 34 56 78 9+
>
>
> Six bytes, 12.3456 looks like 31 32 33 34 35 36 (in ASCII on a PC)
>
>
> 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).
>
>
>
>
> You bet there are others besides DISPLAY (the default) and COMP-3.
>
>
> 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.
>
>

Robert Jones

2007-01-06, 6:55 pm

Top post

I believe that specifying the USAGE at the group level for COBOL 85 was
an IBM extension, they may not have been the only ones. I think the
2002 standard now supports this.

If Bill is reading this, he may wish to elaborate and make any
corrections.

Robert

message snipped

Michael Russell wrote:
> Top post:
>
> ... and remember the inherited usages ...
>
> e.g. if a level 05 contains level 07s & the 07s don't have
> specific usages, they inherit from the 05
> (is that quite right?)
>
> 'usage' = display, comp, comp-2, comp-3, comp-5, comp-x ...
> if no 'usage' is declared, it's implicitly 'display', which
> means one defined 'character' = 1 platform's byte (how else to
> put that?)
> 'level' is a way of specifying a hierarchy of definitions of data.
>
> e.g.
>
> 05 Name-and-Address.
> 07 Name pic x(20).
> 07 Address-1 pic x(20).
> 07 Zip pic x(7). or whatever.
> I'm sure you probably understand that.
>
> So, in the following, all the higher-numbered levels are comp-3:
>
> 05 Numeric-data comp-3.
> 07 First-numeric pic 99.
> 07 Second-numeric pic s9(3)v99.
>
> ... more or less ... but there are odd instances where you
> begin to wonder, depending on the compiler!
>
> hth
>
> Michael
>


Rick Smith

2007-01-06, 6:55 pm


"Robert Jones" <rjones0@hotmail.com> wrote in message
news:1167657824.616060.319740@42g2000cwt.googlegroups.com...
[snip]
> I believe that specifying the USAGE at the group level for COBOL 85 was
> an IBM extension, they may not have been the only ones. I think the
> 2002 standard now supports this.
>
> If Bill is reading this, he may wish to elaborate and make any
> corrections.


The LRM for IBM ANS COBOL (68) does not
show it as an extension. The LRM for Micro Focus
COBOL 3.2 (74 and 85) does not show it as an
extension. The FDIS for ISO/IEC 1989:2002 COBOL
does not show it as a substantive change from the
previous ISO standard. These references seem to
suggest that "specifying the USAGE at the group level"
has been standard COBOL since the first official standard.



Robert Jones

2007-01-06, 6:55 pm

message snipped

Yes I was wrong, it was in the 1985 standard, see 5.14 The USAGE
clause, 5.14.4 GR 1. on page VI-46. I don't know why I thought
otherwise!!

George

2007-01-11, 3:55 am

Dear Barb,

PIC S9(09) COMP-3 means 999999999 with sign and in computational-3
mode. Computational-3 is equalivent to packed-decimal. You can
translate the packed-decimal field into normal numeric field by the
following COBOL statements:

01 PACKED-NUM S9(09) COMP-3.
01 NORMAL-NUM S9(09).
PROCEDURE DIVISION.
...
MOVE PACKED-NUM TO NORMAL-NUM.

PIC 9(02)V9(04) means 99.9999.

PIC S9(07)V99 COMP-3 means 9999999.99 with sign and in computational-3
mode.

Yours sincerely,
George

Barb =BCg=B9D=A1G

> 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 <=3D 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
> * PIC 9(02)V9(04)
> * PIC S9(07)V99 COMP-3
>
> 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).
>=20
> Thanks for any help you can provide!
>=20
> Barb


relaxanz@yahoo.co.uk

2007-01-18, 6:55 pm

Hi Barb

This page looks like quite a good one http://www.felgall.com/cob1.htm

I should be able to tell you myself but it's
a long time since I dealt with this stuff. The main thing I remember
is that V is an implied decimal i.e. it's not stored, just assumed by
input and output but can't remember the Comp-3 in detail.

Good luck
Hinemoa

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
> * PIC 9(02)V9(04)
> * PIC S9(07)V99 COMP-3
>
> 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).
>
> Thanks for any help you can provide!
>
> Barb


Dog1369

2007-01-24, 6:55 pm

"George" <georgech@hkstar.com> wrote:
>

If you can get to mvshelp.com (has all the COBOL manuals user manauls). Dump 10 record and check the file for the data. This will allow you chack the formate that is used.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
jnjsle1@optonline.net

2007-02-03, 6:55 pm

Hi Barb,

If you're still there try the following link,; the sub-topis links
should help.

http://publibz.boulder.ibm.com/cgi-...920180651&CASE=



On Jan 24, 11:46 am, "Dog1369" <RSei...@aol.com> wrote:
> "George" <georg...@hkstar.com> wrote:
>
> If you can get to mvshelp.com (has all the COBOL manuals user manauls). Dump 10 record and check the file for the data. This will allow you chack the formate that is used.
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com