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

COMP Variables Mismatch


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gayu7

New User


Joined: 19 Dec 2017
Posts: 1
Location: india

PostPosted: Wed Dec 20, 2017 5:06 pm
Reply with quote

Hi,

Can anyone please help me find a solution for this?

One of ma step performs addition of two values in which one is
1.) PIC S9(15)V9(3) COMP-3 and the other is
2.) PIC S9(10)V999 COMP-3

What will be the pic value of the added result? Let the result be 'C'

Next -> C should be divided by a value which is PIC S9(09)V9(09) COMP-3.

Let the divided result be 'D'. This 'D' should be finally moved to an amount value through a cobbat program. The amount pic clause is PIC S9(11)V99 COMP-3.

Am getting errors because of the different comp values. Please advise.

Thanks in advance icon_smile.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Dec 20, 2017 6:36 pm
Reply with quote

Quote:
Am getting errors because of the different comp values
What on earth does this mean? If you are getting actual run-time errors, then you need to find out what is causing them and fix them. If you mean you are not getting the results you expected, then you need to read Appendix A Intermediate results and arithmetic precision in Enterprise COBOL Programming Guide as you can figure out EXACTLY how your results are computed. And no, the computed results may not exactly match your hand calculations due to the limited precision of the computer.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Dec 20, 2017 7:32 pm
Reply with quote

Hi Robert,

With all of the information given I believe that it is line 17 of the code causing the problem

icon_rolleyes.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Dec 20, 2017 7:49 pm
Reply with quote

You are most likely correct, expat! But since it is COBOL I would guess line 170 instead of 17.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Dec 20, 2017 10:53 pm
Reply with quote

Additional thoughts:
Quote:
One of ma step performs addition of two values in which one is
1.) PIC S9(15)V9(3) COMP-3 and the other is
2.) PIC S9(10)V999 COMP-3

What will be the pic value of the added result?
The PICTURE will be whatever you defined. If you want to allow for the largest value, and your compile has ARITH(EXTEND) as one of the compiler options, PIC S9(16)V9(03) will hold any result of the addition. However, if your compile has ARITH(COMPAT) then you are limited to 18 total digits and you must specify PIC S9(15)V9(03) and recognize that you could overflow the result. You may want to investigate ON SIZE ERROR in the COBOL Language Reference manual in this case.

Your results can be impacted by the compiler option used, and whether or not you are rounding your results, and when looking at division you REALLY need to study the intermediate results mentioned earlier.

Finally, what is a "cobbat program"? If you meant COBOL batch, you should SAY "COBOL batch". If it is something else particular to your site, you need to explain to us what it is since the term "cobbat" is certainly not a standard term.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2019
Location: USA

PostPosted: Thu Dec 21, 2017 2:16 am
Reply with quote

gayu7 wrote:
Hi,

Can anyone please help me find a solution for this?

One of ma step performs addition of two values in which one is
1.) PIC S9(15)V9(3) COMP-3 and the other is
2.) PIC S9(10)V999 COMP-3

What will be the pic value of the added result? Let the result be 'C'

Next -> C should be divided by a value which is PIC S9(09)V9(09) COMP-3.

Let the divided result be 'D'. This 'D' should be finally moved to an amount value through a cobbat program. The amount pic clause is PIC S9(11)V99 COMP-3.

Am getting errors because of the different comp values. Please advise.

Thanks in advance icon_smile.gif

The answer is standard, and typical.

1) Read a little bit of the basic COBOL manual(s)

2) Create the code to perform the manipulations you need. At least, create the prototype to perform ONLY those arithmetic you mentioned above.

3) If you are absolutely not familiar with computer programming (as I can conclude from your questions, and terminology) then include temporary debug print statements into your code prototype: for initial data, for intermediate results, and for final results

4) Run your test code in your environment, according to the local rules and agreements.
FYI: Before you can run your test - the COBOL code needs to be COMPILED, and LOAD MODULE must be created by a LINKER (e.g. Linkage Editor). In order to prepare and run your test you may need also to get initial knowledge of JCL

5) Try to analyze the results of your test. Fix obvious errors. Try to find explanation to the encountered errors, and how to fix them.

6) If there is something you are not satisfied with, then please, explain to the public: what did you mean under "Am getting errors"???
- Your computer got fire, and was destroyed?
- Your computer stopped running, or entered indefinite loop?
- Your computer re-booted by itself?
- Your program finished execution, but did not produces any result?
- Your program interrupted in the middle, and did not produce any result?
- Your program caused the operating system (do you know what it is?) to issue an error message? What does it say? What is the meaning of it? What is the explanation about it? Did you try to fix the mentioned problem?
- Your program produced output data not related to your expectations? For instance, you expected
'MY MONTHLY BALANCE IS $123,456.00"
but instead the printout is
"BLAH-BLAH-BLAH )($%@":;~` TREX-PHEX-PEX"
- Your program produced output data slightly different from what you expected? For instance, instead of "Value is 123.4567890123" you got "Value is 123.4567890124"?

7) ONLY IN CASE YOU ARE NOT ABLE TO UNDERSTAND HOW TO DEAL WITH YOUR PROBLEM, you may post your question here, with the following (and using <code> tags!!!!):
- your FULL source code
- your FULL input data
- ALL of your intermediate results
- your FULL output data, and/or error/warning messages, or other execution log
- clear explanation: what did you expect, and what was wrong, and why do you think it is really wrong.

Unless you follow the above said 1-7 steps there is a very little chance you would get from this forum a ready-to-use solution for your (absolutely unknown) task.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts JCL with variables JCL & VSAM 1
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts JCL Variables JCL & VSAM 1
Search our Forums:

Back to Top