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
 
Adding three s9(15)V99 fields using cobol

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Adding three s9(15)V99 fields using cobol
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: 8201
Location: Dubuque, Iowa, USA

PostPosted: Wed Jun 24, 2009 7:57 pm    Post subject:
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    Post subject: Reply to: Adding three s9(15)V99 fields using cobol
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: 6970
Location: porcelain throne

PostPosted: Wed Jun 24, 2009 8:15 pm    Post subject:
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: 8201
Location: Dubuque, Iowa, USA

PostPosted: Wed Jun 24, 2009 8:20 pm    Post subject:
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    Post subject: Reply to: Adding three s9(15)V99 fields using cobol
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: 8201
Location: Dubuque, Iowa, USA

PostPosted: Thu Jun 25, 2009 4:45 pm    Post subject:
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.    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 SORT BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm
No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am

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