For Programmers: Free Programming Magazines  


Home > Archive > Cobol > January 2007 > Interpreting a COBOL numeric field in a raw, fixed width TXT file









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 Interpreting a COBOL numeric field in a raw, fixed width TXT file
craig

2007-01-10, 6:55 pm

Hi,

Please forgive me if this question is too basic. I've done quite a bit
of searching for an answer without any luck.

I am trying to understand a numeric amount field in a publicly
available federal election campaign finance file from the FEC web site
so that I might correctly load it into various databases. I won't be
using COBOL to do any of the data loading.

In the raw, fixed width, text form of this data, there is a 7 character
numeric field described like this by the FEC:

"In the fixed width text file, the amounts
are in COBOL format. If the value is negative,
the right most column will contain a special
character: ] = -0, j = -1, k = -2, l = -3,
m = -4, n = -5, o = -6, p = -7, q = -8,
and r = -9.

In the database file, the amount field contains
positive and negative integers."

I don't understand this explanation. Does anything other than a "]"
indicate the decimal should be shifted for the negative number?

This demonstrates my poor understanding:

"0000100" would be + 100
"000100]" would indicate a negative number, but would it be: - 100?
"000100r" would also indicate a negative number, but how would it be
different from the example above?

Any help on this issue will be very appreciated!

- Thanks,

Craig

Reference: ftp://ftp.fec.gov/FEC/indiv06.txt

Rick Smith

2007-01-10, 6:55 pm


"craig" <craigfmitchell@gmail.com> wrote in message
news:1168464083.491639.98290@k58g2000hse.googlegroups.com...
> Hi,
>
> Please forgive me if this question is too basic. I've done quite a bit
> of searching for an answer without any luck.
>
> I am trying to understand a numeric amount field in a publicly
> available federal election campaign finance file from the FEC web site
> so that I might correctly load it into various databases. I won't be
> using COBOL to do any of the data loading.
>
> In the raw, fixed width, text form of this data, there is a 7 character
> numeric field described like this by the FEC:
>
> "In the fixed width text file, the amounts
> are in COBOL format. If the value is negative,
> the right most column will contain a special
> character: ] = -0, j = -1, k = -2, l = -3,
> m = -4, n = -5, o = -6, p = -7, q = -8,
> and r = -9.
>
> In the database file, the amount field contains
> positive and negative integers."


The characters shown for negative values are actually
the lower case equivalent of the representation of
zoned decimal as they appear in EBCDIC. These are
not a valid COBOL format for any COBOL
implementation I am aware of.

> I don't understand this explanation. Does anything other than a "]"
> indicate the decimal should be shifted for the negative number?
>
> This demonstrates my poor understanding:
>
> "0000100" would be + 100
> "000100]" would indicate a negative number, but would it be: - 100?
> "000100r" would also indicate a negative number, but how would it be
> different from the example above?


When the last position contains a number, place a "+"
before the number.

When the last position contains one of the characters
shown, place a "-" before the number and replace the
character with the correcsponding digit.

"0000100" becomes "+0000100"
"000100]" becomes "-0001000"
"000100r" becomes "-0001009"

Then use the resulting translation.

> Any help on this issue will be very appreciated!
>
> - Thanks,
>
> Craig
>
> Reference: ftp://ftp.fec.gov/FEC/indiv06.txt
>





HeyBub

2007-01-10, 9:55 pm

Rick Smith wrote:

>
> The characters shown for negative values are actually
> the lower case equivalent of the representation of
> zoned decimal as they appear in EBCDIC. These are
> not a valid COBOL format for any COBOL
> implementation I am aware of.


The representation is valid for all forms of COBOL wherein the PIC used is
S9(7).


Richard

2007-01-11, 3:55 am


HeyBub wrote:
> Rick Smith wrote:


>
>
> The representation is valid for all forms of COBOL wherein the PIC used is
> S9(7).


What do you mean by 'all' ? It seems to match none that I know of.
Those characters will certainly be invalid for the ASCII compilers that
I am familiar with and are not the ones that I would associate with
EBCDIC - my references only show '}' and upper-case letters.

Then there may be some of the 'all forms of COBOL' where they use
something completely different for negative.

George

2007-01-11, 3:55 am

Dear Craig,

I cannot read the file ftp://ftp.fec.gov/FEC/indiv06.txt. However, I
guess that the negative value is talking about the exponent of the
amount. That is, the decimal place of the amount.
How, do you think?

Yours sincerely,
George

craig =BCg=B9D=A1G

> Hi,
>
> Please forgive me if this question is too basic. I've done quite a bit
> of searching for an answer without any luck.
>
> I am trying to understand a numeric amount field in a publicly
> available federal election campaign finance file from the FEC web site
> so that I might correctly load it into various databases. I won't be
> using COBOL to do any of the data loading.
>
> In the raw, fixed width, text form of this data, there is a 7 character
> numeric field described like this by the FEC:
>
> "In the fixed width text file, the amounts
> are in COBOL format. If the value is negative,
> the right most column will contain a special
> character: ] =3D -0, j =3D -1, k =3D -2, l =3D -3,
> m =3D -4, n =3D -5, o =3D -6, p =3D -7, q =3D -8,
> and r =3D -9.
>
> In the database file, the amount field contains
> positive and negative integers."
>
> I don't understand this explanation. Does anything other than a "]"
> indicate the decimal should be shifted for the negative number?
>
> This demonstrates my poor understanding:
>
> "0000100" would be + 100
> "000100]" would indicate a negative number, but would it be: - 100?
> "000100r" would also indicate a negative number, but how would it be
> different from the example above?
>
> Any help on this issue will be very appreciated!
>
> - Thanks,
>
> Craig
>=20
> Reference: ftp://ftp.fec.gov/FEC/indiv06.txt


Binyamin Dissen

2007-01-11, 6:55 pm

On 11 Jan 2007 00:20:49 -0800 "Richard" <riplin@Azonic.co.nz> wrote:

:>HeyBub wrote:
:>> Rick Smith wrote:

:>>> "In the fixed width text file, the amounts
:>>> are in COBOL format. If the value is negative,
:>>> the right most column will contain a special
:>>> character: ] = -0, j = -1, k = -2, l = -3,
:>>> m = -4, n = -5, o = -6, p = -7, q = -8,
:>>> and r = -9.

:>> > The characters shown for negative values are actually
:>> > the lower case equivalent of the representation of
:>> > zoned decimal as they appear in EBCDIC. These are
:>> > not a valid COBOL format for any COBOL
:>> > implementation I am aware of.

:>> The representation is valid for all forms of COBOL wherein the PIC used is
:>> S9(7).

:>What do you mean by 'all' ? It seems to match none that I know of.
:>Those characters will certainly be invalid for the ASCII compilers that
:>I am familiar with and are not the ones that I would associate with
:>EBCDIC - my references only show '}' and upper-case letters.

:>Then there may be some of the 'all forms of COBOL' where they use
:>something completely different for negative.

PIC S9(whatever) has the last character defined as carrying the sign.

One would not do a

MOVE 99J TO SIGNED-FIELD

one would do

MOVE -991 TO SIGNED-FIELD

--
Binyamin Dissen <bdissen@dissensoftware.com>
http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel


Should you use the mailblocks package and expect a response from me,
you should preauthorize the dissensoftware.com domain.

I very rarely bother responding to challenge/response systems,
especially those from irresponsible companies.
craig

2007-01-11, 6:55 pm

Thanks Rick and everyone else. The explanation Rick gave:

When the last position contains one of the characters
shown, place a "-" before the number and replace the
character with the correcsponding digit.

"0000100" becomes "+0000100"
"000100]" becomes "-0001000"
"000100r" becomes "-0001009"

makes a lot of sense to me, and now I've heard it from more than one
source. Thanks for all of your efforts. This group is great!

- Craig

Richard

2007-01-11, 6:55 pm


Binyamin Dissen wrote:
> On 11 Jan 2007 00:20:49 -0800 "Richard" <riplin@Azonic.co.nz> wrote:
>
> :>HeyBub wrote:
> :>> Rick Smith wrote:
>
> :>>> "In the fixed width text file, the amounts
> :>>> are in COBOL format. If the value is negative,
> :>>> the right most column will contain a special
> :>>> character: ] = -0, j = -1, k = -2, l = -3,
> :>>> m = -4, n = -5, o = -6, p = -7, q = -8,
> :>>> and r = -9.


> One would not do a
>
> MOVE 99J TO SIGNED-FIELD
>
> one would do
>
> MOVE -991 TO SIGNED-FIELD


And on which system would you get _lower-case_ 'j' in the last postion ?

Sponsored Links







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

Copyright 2008 codecomments.com