View previous topic :: View next topic
|
Author |
Message |
neelima.sinha
New User
Joined: 14 Sep 2007 Posts: 30 Location: Bangalore
|
|
|
|
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 |
|
|
icemanroh
New User
Joined: 23 Aug 2008 Posts: 25 Location: Mumbai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
Back to top |
|
|
|