Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 2504
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 Subtract the ZD fields to provide neg... Balaryan DFSORT/ICETOOL 4 Wed Oct 11, 2017 10:51 pm
No new posts Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts display the sign only if the value is... useit DFSORT/ICETOOL 3 Wed Oct 04, 2017 5:53 pm
No new posts LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
No new posts Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us