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
 
COMP Variables Mismatch

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: COMP Variables Mismatch
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: 8211
Location: Dubuque, Iowa, USA

PostPosted: Wed Dec 20, 2017 6:36 pm    Post subject:
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: 8629
Location: Back in jolly old England

PostPosted: Wed Dec 20, 2017 7:32 pm    Post subject:
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: 8211
Location: Dubuque, Iowa, USA

PostPosted: Wed Dec 20, 2017 7:49 pm    Post subject:
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: 8211
Location: Dubuque, Iowa, USA

PostPosted: Wed Dec 20, 2017 10:53 pm    Post subject:
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

Active User


Joined: 29 Apr 2008
Posts: 247
Location: Maryland

PostPosted: Thu Dec 21, 2017 2:16 am    Post subject: Re: COMP Variables Mismatch
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    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 Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm
No new posts CONDITIONAL USING COMP-2 WITH PROBLEMS. JOSUEGENTIL COBOL Programming 7 Wed Nov 08, 2017 11:13 pm
No new posts how can i move s9(9) to s9(9) usage comp HARENDRA CHOUDHARY COBOL Programming 3 Mon Nov 06, 2017 12:10 am
This topic is locked: you cannot edit posts or make replies. Need help how to pass the ESP variabl... Venkichaitu JCL & VSAM 12 Thu Nov 02, 2017 3:53 am
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm

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