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 with compute

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

New User


Joined: 14 Sep 2007
Posts: 30
Location: Bangalore

PostPosted: Fri May 21, 2010 3:53 pm    Post subject: problem with compute
Reply with quote

I have input value

03 NS-PTP-DAY-1 PIC S9(2)V9(2)
SIGN LEADING SEPARATE.

ANOTHER I/P IS

05 JLPTP-PTP-DAY-1 PIC S9(2)V9(1) USAGE COMP-3.


I need to sum the two values and have result in following format.

WW-SUM-PTP-DAY-1 PIC S9(2)V9 COMP-3 VALUE ZERO.


suppose NS-PTP-DAY-1 = +15.23
JLPTP-PTP-DAY-1 = +10.22 I NEED TO DO

WW-SUM-PTP-DAY-1 = NS-PTP-DAY-1 + JLPTP-PTP-DAY-1


How can i do this. I am getting S0C7. Where am i wrong
Back to top
View user's profile Send private message

icemanroh

New User


Joined: 23 Aug 2008
Posts: 25
Location: Mumbai

PostPosted: Fri May 21, 2010 4:09 pm    Post subject:
Reply with quote

Move NS-PTP-DAY-1 into a Working storage variable which shud have the same PIC clause of the output variable (In ur case its WW-SUM-PTP-DAY-1)

for e.g.

Code:
05 WS-NS-PTP-DAY-1 PIC S9(2)V9(1) USAGE COMP-3.


So in the code:

Code:
MOVE NS-PTP-DAY-1 TO WS-NS-PTP-DAY-1
COMPUTE WW-SUM-PTP-DAY-1 = WS-NS-PTP-DAY-1 + JLPTP-PTP-DAY-1.


Also pls try to do Numeric checks for all the fields before adding them.

Let me know if this works.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8195
Location: East Dubuque, Illinois, USA

PostPosted: Fri May 21, 2010 4:42 pm    Post subject:
Reply with quote

The S0C7 abend means one of your data fields does not contain valid numeric data. You can avoid this by
Code:
IF  NS-PTP-DAY-1 NUMERIC
AND JLPTP-PTP-DAY-1 NUMERIC
    COMPUTE WW-SUM-PTP-DAY-1 = NS-PTP-DAY-1 + JLPTP-PTP-DAY-1
ELSE
    do whatever you want to flag the error
END-IF
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri May 21, 2010 8:35 pm    Post subject:
Reply with quote

Hello,

NUMVAL is very handy if it is guaranteed that the fields will be numeric (i.e. created by an already tested program). NUMVAL is not good for "user input" because if the data is not numeric, the code abends. . .

As much of my "input" data originates on Win-based and UNIX systems, NUMVAL is heavily used.

I keep hoping for an extension to NUMVAL that would intercept the abend and set some "variable" if the value was not numeric. . . Then we could have the ease of use of NUMVAL and protection from the abend icon_smile.gif
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 Having a problem FTP'ng to the MF pahiker All Other Mainframe Topics 2 Fri Nov 10, 2017 8:20 pm
No new posts LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
No new posts Problem commiting to DB2 from IMS MPP Ole Soerensen IMS DB/DC 2 Wed Jul 26, 2017 5:19 pm
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm

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