View previous topic :: View next topic
|
Author |
Message |
ashok4u_it
New User
Joined: 12 Mar 2008 Posts: 53 Location: Chennai
|
|
|
|
Hi,
Can anyone explain how to add three s9(15)v99 fields in cobol.
I tried out many ways. But nothing is helping out me.
Please find the piece of my code below.
Input field:-
05 QMR1-FIELD3 PIC S9(15)V99.
05 QMR2-FIELD3 PIC S9(15)V99.
05 QMR3-FIELD3 PIC S9(15)V99.
Temporary field:-
05 WS-QMR-FIELD3 PIC S9(15)V99 VALUE ZEROS.
Output field:-
05 QMR-FIELD3 PIC -9(15).99 VALUE ZEROS.
COMPUTE WS-QMR-FIELD3 = QMR1-FIELD3 +
+ QMR2-FIELD3 + QMR3-FIELD3
MOVE WS-QMR-FIELD3 TO QMR-FIELD3
In this part, I am getting SOC7 abend saying
"The field causing the exception is located in a temporary work field in
the DSA. The actual field in error is in a data record of program
BDWBQMRQ."
I can say the problem is in temporary storage variable. But, I cannot able to figure out the error exactly.
Can anyone, please help me to get out of this issue.
Thanks in Advance
K.Ashok Kumar |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Have you done a DISPLAY of QMR1-FIELD3, QMR2-FIELD3, QMR3-FIELD3?
And
Quote: |
I can say the problem is in temporary storage variable. |
doesn't mean the problem is what you think. The temporary variable gets its data from your three fields; fix the three fields and the temporary variable issue goes away. The error message is quite clear
Quote: |
The actual field in error is in a data record of program BDWBQMRQ. |
in saying one of the three fields is invalid. |
|
Back to top |
|
|
ashok4u_it
New User
Joined: 12 Mar 2008 Posts: 53 Location: Chennai
|
|
|
|
Hi Robert,
I gave DISPLAY and checked the value of the variable. I can find valid values. Please find the Display output below.
0000001968508.96, 0000002986453.07, 0000002986453.07
While summing up these values i am getting SOC7 error.
Is it anything wrong in moving the summed variable to the variable WS-QMR-FIELD3 and QMR-FIELD3. Is it anything wrong in the variable definition i gave.
Please help me.
Regards
K.Ashok Kumar |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
1. you could have coded your compute statement as:
Code: |
COMPUTE QMR-FIELD3 = QMR1-FIELD3
+ QMR2-FIELD3
+ QMR3-FIELD3
END-COMPUTE
|
also, you are using display numeric fields.
you should preface your compute statement with
Code: |
IF QMR1-FIELD3 NUMERIC
AND
QMR2-FIELD3 NUMERIC
AND
QMR3-FIELD3 NUMERIC
THEN
COMPUTE
ELSE
PERFORM garbage-in-numeric-display-fields
END-IF
|
Plus it is a waste of compile time to initialize temporary fields with VALUE clauses
and certainly, edit-masks never need a VALUE clause |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
You get a S0C7 because a period is not considered a valid numeric character in an S9(15)V99 field. Hence your data is invalid, contrary to your statement -- at least to COBOL. Furthermore, you only show 16 characters per field, so you may have another problem with a space.
Rewrite the PIC clauses to be PIC X(17) instead of S9(15)V99 and then use
Code: |
COMPUTE WS-QMR-FIELD3 = FUNCTION NUMVAL (QMR1-FIELDX) +
FUNCTION NUMVAL (QMR2-FIELDX) +
FUNCTION NUMVAL (QMR3-FIELDX). |
|
|
Back to top |
|
|
ashok4u_it
New User
Joined: 12 Mar 2008 Posts: 53 Location: Chennai
|
|
|
|
Hi Robert,
Thanks a lot.
Your code helped me a lot. It worked fine.
Thanks
K.Ashok Kumar |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Glad to hear your problem is resolved. |
|
Back to top |
|
|
|