Page 1 of 1

input and output fields need to keep decimal

PostPosted: Fri Feb 17, 2012 11:01 pm
by basmith11
How can I add up the fields and get the same output including the decimal???
58335.26
41186.55
47051.15
50015.01
21595.61

currently defined as alpha
ACCT-AMT-H 140 11 A
ACCT-AMT-DOLS-H 140 8 A
ACCT-AMT-CENT-H 149 2 A

TOT-AMT-HOLD W 11 N 2
TOT-AMT-DOLS W 9 N
TOT-AMT-CENT W 2 N 2

How do I bring them back together like using COBOL levels in working storage
01 TOT-AMT.
05 TOT-AMT-DOLS PIC 9(9).
05 TOT-AMT-CENT PIC v99.
MOVE ACCT-AMT-DOLS-H TO TOT-AMT-DOLS.
MOVE ACCT-AMT-CENT-H TO TOT-AMT-CENT.

TOT-AMT-HOLD = TOT-AMT-HOLD + TOT-AMT.

Re: input and output fields need to keep decimal

PostPosted: Sat Feb 18, 2012 1:08 am
by BillyBoyo
In your sample data you are showing an actual decimal point, not an implicit one. Was that just for us?

If yes, then:

ACCT-AMT-H-NUMERIC ACCT-AMT-H 11 N 2


If it is an actual decimal point, let us know, as you need to do something quite different (note, this would not match the Cobol definitions you have shown).

Re: input and output fields need to keep decimal

PostPosted: Sat Feb 18, 2012 1:09 am
by basmith11
Yes, it is an actual decimal on the input file.

Re: input and output fields need to keep decimal

PostPosted: Sat Feb 18, 2012 1:20 am
by BillyBoyo
Well, your Cobol is wrong as well, then. Do you need that fixing?

Re: input and output fields need to keep decimal

PostPosted: Sat Feb 18, 2012 1:27 am
by BillyBoyo
First, note that your field has "shrunk" in size, to remove the decimal point.

TOT-AMT-HOLD            W     10  N  2
TOT-AMT-DOLS            TOT-AMT-HOLD     8  A   
TOT-AMT-CENT            TOT-AMT-HOLD +8 2  A   


Personally, I'd

  1. Use an S not a W
  2. Prefix the datanames with S-
  3. Test that the numbers are numeric
  4. Test the undefined position on your input file, to see that it is actually a "."

Re: input and output fields need to keep decimal

PostPosted: Sat Feb 18, 2012 2:03 am
by basmith11
Thank you everyone, I finally got it to work.....