Page 1 of 1

Reading file into a cobol field of S9(3)v(2)..

PostPosted: Mon Sep 09, 2013 11:29 am
by zhinghur
Hi,

This question may sounds basic, but this gives some headache at times.

I have a text file like below description.
Key - 11 bytes
filler - 10 bytes
field 1 - I have defined in COBOL as S9(3)V9(2).
filler - 10 bytes
field 2 - field 1 - I have defined in COBOL as S9(3)9(2).
...... and so on


File

<--key------->< filler ><field 1><filler><field2>
00000000001                 9.32                4.22>
00000000002               11.56              100.11
00000000003              131.56               
00000000003                81.56               30.67



Problem looks like with my S9(3)V9(2). The programs abends even doesnt DISPLAY after going in processing section.

I have to perform some compuation on these field. Can anyone help ?

Code'd

Re: Reading file into a cobol field of S9(3)v(2)..

PostPosted: Mon Sep 09, 2013 11:31 am
by zhinghur
Looks like space vanished.

00000000001 9.32 4.22

Please consider 10 spaces after each field.00000000001<ten spaces> 9.32<ten spaces> 4.22

Re: Reading file into a cobol field of S9(3)v(2)..

PostPosted: Mon Sep 09, 2013 12:42 pm
by BillyBoyo
Use a definition of ZZ9.99 for your input and MOVE that to a field in WORKING-STORAGE to do the calculation. You can't do calculations with fields containing actual decimal points. The definition and MOVE that I suggest is a way to "de-edit" the field, so that the compiler generates code to be happy with the leading spaces and removes the decimal point and aligns the values on the implied decimal point in your WORKING-STORAGE definition. There is little/no point in making your WORKING-STORAGE definition signed in this example.

Re: Reading file into a cobol field of S9(3)v(2)..

PostPosted: Mon Sep 09, 2013 5:56 pm
by NicC
Your spaces disappeared because you did not use the code tags. Billy Boyo would appear to have added these for you so that your input now, somewhat resembles what you posted.

You should know by now when and how to use the code tags If not, search the forum.

Re: Reading file into a cobol field of S9(3)v(2)..

PostPosted: Mon Sep 09, 2013 8:19 pm
by dick scherrer
Hello,

Reading file into a cobol field of S9(3)v(2).
00000000001 9.32 4.22
Neither value is valid for the PICture used . . .

You need to re-read and understand what BB provided.