Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Problem while storing negative values

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
lvbntapasvi

New User


Joined: 20 Jul 2006
Posts: 30

PostPosted: Thu Apr 05, 2012 4:12 pm    Post subject: Problem while storing negative values
Reply with quote

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
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Thu Apr 05, 2012 4:18 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu Apr 05, 2012 4:30 pm    Post subject: Reply to: Problem while storing negative values
Reply with quote

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
View user's profile Send private message
lindovaldolpn

New User


Joined: 25 Feb 2010
Posts: 16
Location: Brazil

PostPosted: Fri Apr 06, 2012 1:08 am    Post subject:
Reply with quote

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 icon_evil.gif

Regards

Lindovaldo
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Apr 06, 2012 1:32 am    Post subject: Reply to: Problem while storing negative values
Reply with quote

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
View user's profile Send private message
lvbntapasvi

New User


Joined: 20 Jul 2006
Posts: 30

PostPosted: Tue Apr 10, 2012 1:19 pm    Post subject:
Reply with quote

Thanks Bill, I have added + to the positive values as suggested by you.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Apr 10, 2012 1:50 pm    Post subject: Reply to: Problem while storing negative values
Reply with quote

And then you can get them successfully into your table?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us