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.
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
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.
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
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.
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
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.