For Programmers: Free Programming Magazines  


Home > Archive > Cobol > April 2005 > Data structure question









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 Data structure question
Frank

2005-04-25, 3:55 pm

Hi,

I'm kinda new at Cobol. I'm writing code that will be reading in a data
file that has cobol records (as defined by a Cobol copybook). I'm trying to
understand what I should be expecting to see in the file for certain PIC
types.

For example, a PIC S99, will it look like +12 or just 12?

Also, I'm trying to understand the difference betwee PIC 9V9 and PIC 9.9.

Any help is appreciated.
Frank



docdwarf@panix.com

2005-04-25, 3:55 pm

In article <wU7be.11912$V02.2894@fe08.lga>, Frank <gunygoogoo@yahoo.com> wrote:
>Hi,
>
>I'm kinda new at Cobol. I'm writing code that will be reading in a data
>file that has cobol records (as defined by a Cobol copybook).


[snip]

>For example, a PIC S99, will it look like +12 or just 12?
>
>Also, I'm trying to understand the difference betwee PIC 9V9 and PIC 9.9.


That you are 'kinda new' might be readily apparent from your questions...
it'd help to know your compiler and platform before an answer is given.

Oh... and just for laughs, please supply the name of the text you used
when learning COBOL.

DD

Frank

2005-04-25, 3:55 pm


<docdwarf@panix.com> wrote in message news:d4j43g$cih$1@panix5.panix.com...
> In article <wU7be.11912$V02.2894@fe08.lga>, Frank <gunygoogoo@yahoo.com>

wrote:
>
> [snip]
>
>
> That you are 'kinda new' might be readily apparent from your questions...
> it'd help to know your compiler and platform before an answer is given.
>
> Oh... and just for laughs, please supply the name of the text you used
> when learning COBOL.
>
> DD
>


I'm not using a Cobol compiler, I'll be getting the data from a Cobol system
and reading it in via a flat file using Java. I guess the compiler and
version of the originating system might be useful. I don't actually know
that right now.




Michael Mattias

2005-04-25, 3:55 pm

"Frank" <gunygoogoo@yahoo.com> wrote in message
news:wU7be.11912$V02.2894@fe08.lga...
> I'm kinda new at Cobol. I'm writing code that will be reading in a data
> file that has cobol records (as defined by a Cobol copybook). I'm trying

to
> understand what I should be expecting to see in the file for certain PIC
> types.
>
> For example, a PIC S99, will it look like +12 or just 12?


Oldie but Goodie: Text and graphics tutorial on COBOL data types:
http://www.flexus.com/ftp/cobdata.zip

Also available: http://www.flexus.com/ftp/cobfd.zip , 'FD Analzyer" (also
old and clunky, but it works).

And, if you need to use COBOL-created data with other programs, here's a
tutorial on that:
http://www.talsystems.com/tsihome_h...oads/C2IEEE.htm


--
Michael Mattias
(author/contributor of all above)
Tal Systems, Inc.
Racine WI
mmattias@talsystems.com



docdwarf@panix.com

2005-04-25, 3:55 pm

In article <mH8be.4174$RP1.3883@fe10.lga>, Frank <gunygoogoo@yahoo.com> wrote:
>
><docdwarf@panix.com> wrote in message news:d4j43g$cih$1@panix5.panix.com...
>
>I'm not using a Cobol compiler, I'll be getting the data from a Cobol system
>and reading it in via a flat file using Java.


Silly me! When I read 'I'm kinda new at Cobol. I'm writing code that
will...' I concluded that you'd be writing code in COBOL... I don't know
how I made such a foolish error.

>I guess the compiler and
>version of the originating system might be useful. I don't actually know
>that right now.


Not to worry... some folks here are patient.

DD

Lueko Willms

2005-04-25, 8:55 pm

.. On 25.04.05
wrote gunygoogoo@yahoo.com (Frank)
on /COMP/LANG/COBOL
in wU7be.11912$V02.2894@fe08.lga
about Data structure question


g> For example, a PIC S99, will it look like +12 or just 12?

If it has a SIGN SEPARATE clause, like +12

There are some other clauses which can influence that

g> Also, I'm trying to understand the difference betwee PIC 9V9 and PIC
g> 9.9.

V is the assumed decimal point, but it is not stored in internal
memory of in a data file.

A PIC 9.9 is an editing picture which tells the compiler how to
present a number in that place, i.e. with a point as decimal
separator.



Yours,
Lüko Willms http://www.willms-edv.de
/--------- L.WILLMS@jpberlin.de -- Alle Rechte vorbehalten --

Er liebte hauptsächlich die Wörter, die nicht in Wörterbüchern vorzukommen pflegen. -G.C.Lichtenberg
William M. Klein

2005-04-25, 8:55 pm

If you are getting input from "somewhere else" AND you are able to specify what
you want to those providing the input, ask them to produce COBOL files with the
following COBOL "clauses"

USAGE DISPLAY

SIGN IS LEADING SEPARATE (for numeric fields)

Only "." as a decimal indicator - not "V"

No REDEFINES

(Possibly) No OCCURS DEPENDING ON structures.

CODE-SET (if your system is ASCII, then ask them to use STANDARD-1 - if your
system is EBCDIC, then ask them to use EBCDIC - if available. If you are using
ONLY "Unicode" on your system, then ask them if they have this support on their
system, probably via the USAGE NATIONAL rather than USAGE DISPLAY clause).

All of this assumes that you have a "good relationship" with those providing you
with the data. If they use all of the above when sending you data, you should
be able to handle it with "ease" no matter what system you are using.

If they are not willing or able to modify the type of data they send you, then
you will need SOME level of real COBOL expertise (in the compiler and operating
system where the data is created) in order to GUARANTEE that you can handle the
data.

--
Bill Klein
wmklein <at> ix.netcom.com
"Frank" <gunygoogoo@yahoo.com> wrote in message
news:mH8be.4174$RP1.3883@fe10.lga...
>
> <docdwarf@panix.com> wrote in message news:d4j43g$cih$1@panix5.panix.com...
> wrote:
>
> I'm not using a Cobol compiler, I'll be getting the data from a Cobol system
> and reading it in via a flat file using Java. I guess the compiler and
> version of the originating system might be useful. I don't actually know
> that right now.
>
>
>
>



Richard

2005-04-25, 8:55 pm


> For example, a PIC S99, will it look like +12 or just 12?


If is it just a PIC S99 then it will most likely occupy 2 bytes as
'12'. If it had a negative value then it would most likely have an
'overpunch' bit set on the least significant digit.

> Also, I'm trying to understand the difference betwee PIC 9V9 and PIC

9.9.

PIC 9V9 occupies 2 bytes and the decimal point is _implied_, so a
content of '12' has a value of 1.2. A PIC 9.9 has an embedded '.' and
occupies 3 bytes so a content will be '1.2'.

However, that is all 'USAGE DISPLAY' which is the default (usually) and
other representations may be used. Beware of a USAGE clause on a group
item that may apply to subordinate fields. eg:

03 Record-Totals USAGE COMP-3.
05 Record-Value PIC S9(9)V99.
05 Record-Tax PIC S9(7)V99.

The two PICs have sizes of 6 bytes and 5 bytes with the digits in BCD
(probably).

HeyBub

2005-04-26, 3:55 am

Frank wrote:
> Hi,
>
> I'm kinda new at Cobol. I'm writing code that will be reading in a
> data file that has cobol records (as defined by a Cobol copybook).
> I'm trying to understand what I should be expecting to see in the
> file for certain PIC types.
>
> For example, a PIC S99, will it look like +12 or just 12?
>
> Also, I'm trying to understand the difference betwee PIC 9V9 and PIC
> 9.9.
>
> Any help is appreciated.
> Frank


The EASIEST way to decipher this is to get the file and look at it. Come
back if anything looks odd.

Now to your questions:

PIC S99 looks like? It doesn't really "look like" anything inasmuch as this
is the definition of an internal representation, unsuitable for reading by a
human. If you printed the field, it COULD be "12" - most likely it will look
like "1B" (3142 in hex). If "-12" it will look like "1R" (3152 in hex).
Assuming ASCII.

The "S" means the sign is carried internally with the value (usually in the
last byte).

"V" vs "." ?

"V" is the location of the implied decimal point. PIC 9V9 containing "12" is
treated by the compiler as if the value were "1.2"

"Decimal point" is an editting symbol and is used to format internal values
for output.

In a PIC field there can be data definition symbols or editting symbols,
depending on the use of the field. There are dozens of these symbols used in
all manner of combinations and permutations. I don't mean to confuse you,
but the same symbol can be used for both defining the data and for editting.
Context determines the difference.

Get a good book on COBOL and give up this Java silliness. Sun's a goner.


LX-i

2005-04-26, 3:55 am

Frank wrote:
> <docdwarf@panix.com> wrote in message news:d4j43g$cih$1@panix5.panix.com...
>
>
> wrote:
>
>
>
> I'm not using a Cobol compiler, I'll be getting the data from a Cobol system
> and reading it in via a flat file using Java. I guess the compiler and
> version of the originating system might be useful. I don't actually know
> that right now.


Ouch - this could be tough. Systems with numbers in "packed" or
"binary" format are often not the best to exchange with other systems.
If you can, see if the file can be generated with all PIC 9's with USAGE
DISPLAY and no "V" characters - and, signed fields (9's with a leading
"S") with the SIGN LEADING SEPARATE clause. At that point, the file
should be completely ASCII, and it'll be easy to lay out the columns.

If they can't (or won't) change, there is also the possibility of
writing a COBOL file-handling class that you could instantiate. I've
never done that, but I believe others in this newsgroup have. Of
course, this would require a commercial COBOL compiler capable of
creating the component.


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ daniel@thebelowdomain ~
~ _____ / \ | ~ http://www.djs-consulting.com ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ ~
~ !O M-- V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e ~
~ h---- r+++ z++++ ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
Sponsored Links







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

Copyright 2008 codecomments.com