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

Adding three s9(15)V99 fields using cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
ashok4u_it

New User


Joined: 12 Mar 2008
Posts: 53
Location: Chennai

PostPosted: Wed Jun 24, 2009 7:52 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Jun 24, 2009 7:57 pm
Reply with quote

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
View user's profile Send private message
ashok4u_it

New User


Joined: 12 Mar 2008
Posts: 53
Location: Chennai

PostPosted: Wed Jun 24, 2009 8:04 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 24, 2009 8:15 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Jun 24, 2009 8:20 pm
Reply with quote

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
View user's profile Send private message
ashok4u_it

New User


Joined: 12 Mar 2008
Posts: 53
Location: Chennai

PostPosted: Thu Jun 25, 2009 12:48 pm
Reply with quote

Hi Robert,

Thanks a lot.
Your code helped me a lot. It worked fine.

Thanks
K.Ashok Kumar
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Thu Jun 25, 2009 4:45 pm
Reply with quote

Glad to hear your problem is resolved.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top