Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Issue with COMP-3 computation calc

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
kumarvis
Warnings : 1

New User


Joined: 31 Mar 2007
Posts: 14
Location: Chennai

PostPosted: Wed Apr 04, 2007 10:54 am    Post subject: Issue with COMP-3 computation calc
Reply with quote

Hi,
I did xpeditor test on program. During testing I am not clear with the following statement.

THIS IS HOW THE BELOW VARIABLES ARE DEFINED.

WORKING STORAGE SECTION.
05 WS20-PRT-CNTER PIC S9(09) COMP VALUE +0.
05 WS20-STODAT-TOTAL-READ PIC S9(09) COMP VALUE +0.


COMPUTE WS20-PRT-CNTER
= 1
+ (WS20-STODAT-TOTAL-READ
- (WS20-STODAT-TOTAL-READ / 1000) * 1000)
END-COMPUTE

In xpeditor, it shows the value of WS20-PRT-CNTER after computation is 2. Can u explain how is this possible?
Back to top
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Wed Apr 04, 2007 1:41 pm    Post subject: Re: Issue with COMP-3 computation calc
Reply with quote

Quote:
In xpeditor, it shows the value of WS20-PRT-CNTER after computation is 2.

Are you sure ?

If not, put some displays before and after compute statement to check what your output variable gets. As your compute statement doesnt seem other than increament by 1.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 04, 2007 10:04 pm    Post subject:
Reply with quote

Hello,

Where is the WS20-STODAT-TOTAL-READ field incrememnted?

Before the "problem" calculation, the WS20-STODAT-TOTAL-READ field may have been incremented to 1 from the first record read.
Back to top
View user's profile Send private message
kumarvis
Warnings : 1

New User


Joined: 31 Mar 2007
Posts: 14
Location: Chennai

PostPosted: Thu Apr 05, 2007 4:55 am    Post subject: Re: Issue with COMP-3 computation calc
Reply with quote

This is for to give u the detailed explaination of the above comp-3 computation issue with screen shots mentioned in the attachment doc.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Apr 05, 2007 5:24 am    Post subject:
Reply with quote

The way I read the compute:

(WS20-STODAT-TOTAL-READ / 1000) * 1000) truncates to zero, so
WS20-PRT-CNTER = 1 + 1 - 0 = 2
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Apr 05, 2007 6:27 am    Post subject:
Reply with quote

Hello,

If the result was not 2, that would be a surprise.

From your original post
Code:
COMPUTE WS20-PRT-CNTER
= 1
+ (WS20-STODAT-TOTAL-READ
- (WS20-STODAT-TOTAL-READ / 1000) * 1000)
END-COMPUTE

and in your attachment, you provide
Quote:
Before coming to the below computation, WS20-STODAT-TOTAL-READ was
Incremented by 1.

so, the calculation is as Jack said 1 + 1 - 0 = 2.

We're here if this is not clear icon_smile.gif
Back to top
View user's profile Send private message
kumarvis
Warnings : 1

New User


Joined: 31 Mar 2007
Posts: 14
Location: Chennai

PostPosted: Thu Apr 05, 2007 6:50 am    Post subject: Hi d.sch
Reply with quote

Hi,
Thanks for ur respoce. I do have another concern on this issue.
May I know under what circumstances does the
(WS20-STODAT-TOTAL-READ/1000) * 1000 = zero.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Apr 05, 2007 7:37 am    Post subject:
Reply with quote

Hello kumarvis,

With the code as it is written, i believe this
Quote:
(WS20-STODAT-TOTAL-READ/1000) * 1000
will be zero until WS20-STODAT-TOTAL-READ becomes greater than 1000.

Rather than focus on this particular calculation, please explain the use of the WS20-PRT-CNTER? As coded, it will increase at an increasing rate as the number of records reaches each successive thousand.

If we understand what this accomplishes, we may be able to offer better suggestions.
Back to top
View user's profile Send private message
monga

New User


Joined: 18 Apr 2006
Posts: 13

PostPosted: Thu Apr 05, 2007 10:31 am    Post subject:
Reply with quote

WS20-STODAT-TOTAL-READ = 1

The code says
Code:
COMPUTE WS20-PRT-CNTER
= 1
+ (WS20-STODAT-TOTAL-READ
- (WS20-STODAT-TOTAL-READ / 1000) * 1000)
END-COMPUTE


which is

Code:
COMPUTE WS20-PRT-CNTER = 1 + ( 1 - (1/1000) * 1000)


But as COMPUTE WS20-PRT-CNTER is declared as a COMP variable and not a COMP-3
the resultant 0.999 would be equivalent to 0

Code:
WS20-PRT-CNTER = 1 + ( 1 - (0) * 1000)

WS20-PRT-CNTER = 1 + ( 1 - 0)

WS20-PRT-CNTER = 2

I hope this would clear your doubts. Also let me know if my understanding is not correct here.

Thanks,

monga
Back to top
View user's profile Send private message
monga

New User


Joined: 18 Apr 2006
Posts: 13

PostPosted: Thu Apr 05, 2007 10:33 am    Post subject:
Reply with quote

Just one correction - Read the resultant value as 0.001 (and not 0.999 as stated above)
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Thu Apr 05, 2007 12:22 pm    Post subject:
Reply with quote

Is is just me who got confused? icon_confused.gif
WS20-STODAT-TOTAL-READ and WS20-PRT-CNTER both are +0.
why you guys are taking 1 at WS20-STODAT-TOTAL-READ icon_question.gif

Quote:
COMPUTE WS20-PRT-CNTER = 1 + ( 1 - (1/1000) * 1000)


If i have learnt my fifth grade maths correct then answer should be 1.

Because of Dick's comment, I even gave it a try.
Surprise! I am correct! answer is 1 icon_lol.gif
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Chennai

PostPosted: Thu Apr 05, 2007 12:25 pm    Post subject: Re: Issue with COMP-3 computation calc
Reply with quote

Folks,
I guess it is turning from a Mainframe Forum to Maths Forum icon_lol.gif
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Thu Apr 05, 2007 12:29 pm    Post subject:
Reply with quote

Sorry Folks!
I missed reading the attachment! Till then 'original post' was my Bible.
The attachement enlightened me about incrementing value.
But my maths is good! icon_lol.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Apr 05, 2007 8:47 pm    Post subject:
Reply with quote

Hi Abhijit,

As has been said, "Sometimes you get the bear, sometimes the bear gets you" icon_smile.gif

Now, if kumarvis comes back with more info, we may be able to offer some suggestions. . .
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 Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts Execessive parameter issue Sumeendar JCL & VSAM 5 Mon Dec 19, 2016 4:35 pm
No new posts DFHRESPONSE returns issue divated CICS 3 Wed Nov 02, 2016 6:32 pm
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us