Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

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




Report this thread to moderator Post Follow-up to this message
Old Post
Frank
04-25-05 08:55 PM


Re: Data structure question
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


Report this thread to moderator Post Follow-up to this message
Old Post
docdwarf@panix.com
04-25-05 08:55 PM


Re: Data structure question
<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.





Report this thread to moderator Post Follow-up to this message
Old Post
Frank
04-25-05 08:55 PM


Re: Data structure question
"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




Report this thread to moderator Post Follow-up to this message
Old Post
Michael Mattias
04-25-05 08:55 PM


Re: Data structure question
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 syste
m
>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


Report this thread to moderator Post Follow-up to this message
Old Post
docdwarf@panix.com
04-25-05 08:55 PM


Re: Data structure question
..    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 p
flegen. -G.C.Lichtenberg

Report this thread to moderator Post Follow-up to this message
Old Post
Lueko Willms
04-26-05 01:55 AM


Re: Data structure question
If you are getting input from "somewhere else" AND you are able to specify w
hat
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 us
ing
ONLY "Unicode" on your system, then ask them if they have this support on th
eir
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 shou
ld
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, th
en
you will need SOME level of real COBOL expertise (in the compiler and operat
ing
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 syst
em
> 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.
>
>
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
04-26-05 01:55 AM


Re: Data structure question

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


Report this thread to moderator Post Follow-up to this message
Old Post
Richard
04-26-05 01:55 AM


Re: Data structure question
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.



Report this thread to moderator Post Follow-up to this message
Old Post
HeyBub
04-26-05 08:55 AM


Re: Data structure question
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 syst
em
> 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++++                                            ~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~

Report this thread to moderator Post Follow-up to this message
Old Post
LX-i
04-26-05 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:28 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.