IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Problem while storing negative values


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 6966
Location: porcelain throne

PostPosted: Thu Apr 05, 2012 4:18 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 05, 2012 4:30 pm
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
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Apr 06, 2012 1:32 am
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Apr 10, 2012 1:50 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Storing a BLOB/CLOB in PL/I PL/I & Assembler 4
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
Search our Forums:

Back to Top