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



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

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

Postby zhinghur » Mon Sep 09, 2013 11:29 am

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
zhinghur
 
Posts: 48
Joined: Sun Nov 20, 2011 12:25 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby zhinghur » Mon Sep 09, 2013 11:31 am

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
zhinghur
 
Posts: 48
Joined: Sun Nov 20, 2011 12:25 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby BillyBoyo » Mon Sep 09, 2013 12:42 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

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

Postby NicC » Mon Sep 09, 2013 5:56 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

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

Postby dick scherrer » Mon Sep 09, 2013 8:19 pm

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post