View previous topic :: View next topic
|
Author |
Message |
lvbntapasvi
New User
Joined: 20 Jul 2006 Posts: 30
|
|
|
|
Hello everyone,
I am reading a continuous strip of data separated by spaces into an array,
Code: |
000000000007452223.6 000000000008155566.0 000000000007530180.2
000000000000000448.0 -000000000000000896.0 000000000000003136.0
|
I have defined the PIC clause of the numeric variable as S9(18)V9 and the positive values are stored properly as viewable from FILE-AID. But, the negative values are not being stored as I could see an error message in the FILE-AID saying PICTURE INCOMPATIBLE.
I have searched this forum, and with the help of one post I changed the PIC clause to -(18)9.9 , but all in vain.
Could you please help on this.
Thanks. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
1. read the manual, learn about ARITH compiler option.
2. a picture clause of PIC -(18)9.9 is an edit mask.
3. reading an strip of data into an array.
well, other than the fact that COBOL calls these things COBOL Internal Tables,
arrays in COBOL are used for DB2 Host Variables.
how are you "moving" the data from the strip to the COBOL Internal Table item? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Your "strip" is of variable position, because sometimes you have a minus sign and some times you have, well, nothing. Minus sign is one long. Nothing is... zero long.
If you want them to go into a (Cobol internal) table from your "strip" you'll have to get "something" (a + or a space) to be present for the positive values.
Else you're going down the UNSTRING route. There are numerous recent examples. |
|
Back to top |
|
|
lindovaldolpn
New User
Joined: 25 Feb 2010 Posts: 16 Location: Brazil
|
|
|
|
Hi
No problem to use -------9.9 when you want read edit-value. It's commom for read values of reports for example.
FILE:
Code: |
-00000000000896.0
-8155566.0
-1008155566.0
1000000896.0 |
COBOL:
Code: |
01 RECORD-TEMP.
03 VALUE1 PIC -(15).9. |
Code: |
File-AID - Browse - D1CHLB.CNTL(TEMP) - 01.09 ------------- LINE 0000 COL 1 17
COMMAND ===> SCROLL ===> CSR
VALUE1
17/AN
(1-17)
1----------------
********************************* TOP OF DATA **********************-CAPS OFF-*
-00000000000896.0
-8155566.0
896.0
-1008155566.0
1000000896.0
******************************** BOTTOM OF DATA ********************-CAPS OFF-* |
the code tags... the fkng code tags
Regards
Lindovaldo |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Beginning with COBOL/370 (about 20 years ago), numerics in a signed/unsigned edit-pattern can be moved to an internal work-area, such as a signed PIC S9(18)V9(9) and the high-order zone of the last byte will resolve either as a X'C' or X'D' (positive or negative, respectively).
You must use the ARITH(EXTEND) compiler option, which allows usage of up to 31-Digit fields, providing your compiler supports this option. IIRC, EXTEND was introduced as an option with OS/390 COBOL Version 2.2.1, around 11-12 years ago. |
|
Back to top |
|
|
lvbntapasvi
New User
Joined: 20 Jul 2006 Posts: 30
|
|
|
|
Thanks Bill, I have added + to the positive values as suggested by you. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
And then you can get them successfully into your table? |
|
Back to top |
|
|
|