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
 

 

Problem with movind 99v99 to v999 field

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

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Wed Apr 14, 2010 8:56 am    Post subject: Problem with movind 99v99 to v999 field
Reply with quote

Hi,

i am facing a problem in cobol when moving data from a varaible with picture caluse V9999 to a variable with picture clause V999 comp-3 and the problme is as below.

WS-VAR1 pic 99v99 values 10.25
WS-VAR2 pic v999 comp-3.
WS-VAR3 pic v9999 values .0000

now i am computing WS-VAR3 = WS-VAR1 * 0.01 = 10.25*0.01 = .1025

Then i am moving WS-VAR3 to WS-VAR2.

now WS-VAR2 is displaying '.025'. I dont know on what basis '.025' is moving to WS-VAR2 instead of '.102'. Can someone help me what is causing the issue here? Please note that i cannt change the picture clause of WS-VAR2 since it is a variable used in the program in so many places.

Regards,
Sasikumar.K
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Apr 14, 2010 11:43 am    Post subject:
Reply with quote

Quote:
now i am computing WS-VAR3 = WS-VAR1 * 0.01 = 10.25*0.01 = .1025

Then i am moving WS-VAR3 to WS-VAR2.


don't believe you,
cut and paste the exact data definitions and
the code in the module.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Wed Apr 14, 2010 5:06 pm    Post subject:
Reply with quote

You are obviously NOT pasting the precise code used since VALUES gives a syntax error. When I copied what you said you were doing and tried it out:
Code:
       77  WS-VAR1 PIC 99V99 VALUE  10.25 .
       77  WS-VAR2 PIC V999 COMP-3.
       77  WS-VAR3 PIC V9999 VALUE  .0000 .

       PROCEDURE DIVISION.
           COMPUTE WS-VAR3 = WS-VAR1 * .01 .
           MOVE WS-VAR3                TO  WS-VAR2.
           DISPLAY 'WS-VAR1 ' WS-VAR1.
           DISPLAY 'WS-VAR2 ' WS-VAR2.
           DISPLAY 'WS-VAR3 ' WS-VAR3.
gives me results of
Code:
 WS-VAR1 1025
 WS-VAR2 102
 WS-VAR3 1025
exactly as expected.

So you are either not doing what you told us you are doing, or your changes from the actual code to pasting here added another factor.
Back to top
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Fri Apr 16, 2010 6:58 am    Post subject: Reply to: Problem with movind 99v99 to v999 field
Reply with quote

Hi,

Thanks for looking into my problem.

i verified the variable WS-VAR2, its picture clause is pic VP999 comp-3. Its a packed decimal value. I am getting 0.025 in this instead of 0.102. Can you please let me know what is causing problem here.?

regards,
Sasikumar.K
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Apr 16, 2010 7:41 am    Post subject:
Reply with quote

Quote:
its picture clause is pic VP999 comp-3
That's a new one on me.....
The symbol P can be specified only as a continuous string of Ps in the leftmost or rightmost digit positions within a PICTURE character-string
Is there a reason for the 'P'?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Fri Apr 16, 2010 8:07 am    Post subject:
Reply with quote

NOW you tell us the picture is VP999, not V999. Do you know what the P symbol does? If not, look up the P symbol in the COBOL Language Reference manual and you will find that 0.025 is the expected result in a VP999 field instead of 0.102 in a V999 field.

As I said earlier, you need to post the exact code you are using or the answers you get will not reflect your problem -- just as what happened when you didn't post the exact code above.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Apr 16, 2010 8:39 am    Post subject:
Reply with quote

Robert Sample wrote:
Language Reference manual and you will find that 0.025 is the expected result in a VP999 field instead of 0.102 in a V999 field.
I just didn't see that:
The symbol P specifies a scaling position and implies an assumed decimal point (to the left of the Ps if the Ps are leftmost PICTURE characters; to the right of the Ps if the Ps are rightmost PICTURE characters). The assumed decimal point symbol V is redundant as either the leftmost or rightmost character within such a PICTURE description.
It seems that the VP is the same a V, what am I missing?
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: Fri Apr 16, 2010 8:56 am    Post subject:
Reply with quote

Hello,

Quote:
i am facing a problem in cobol when moving data from a varaible with picture caluse V9999 to a variable with picture clause V999 comp-3 and the problme is as below.
Quote:
i verified the variable WS-VAR2, its picture clause is pic VP999 comp-3.
How did the VP999 get into the code? If you did not code this, there must have been a reason. . .

Suggest you talk with your seniors and determine the "rules" for this process. That PICTURE is quite rare, so either you simply made a mistake when coding/typing this or someone else had a reason for this definition.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Fri Apr 16, 2010 6:03 pm    Post subject:
Reply with quote

CICS Guy wrote:

It seems that the VP is the same a V, what am I missing?

Further on in the manual it says:
"In certain operations that reference a data item whose PICTURE character-string contains the symbol P, the algebraic value of the data item is used rather than the actual character representation of the data item. This algebraic value assumes the decimal point in the prescribed location and zero in place of the digit position specified by the symbol P. The size of the value is the number of digit positions represented by the PICTURE character-string. These operations are any of the following:

* Any operation that requires a numeric sending operand

* A MOVE statement where the sending operand is numeric and its PICTURE character-string contains the symbol P "
Back to top
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Sat Apr 17, 2010 7:02 am    Post subject: Reply to: Problem with movind 99v99 to v999 field
Reply with quote

I am sorry if i have confused u guys....

Actually i didnt introduce the field WS-VAR2 in the programs. its an existing variable. I am just computing the value and moving the value to WS-VAR2.

The variable is declared as below.

05 WS-VAR2 pic v999 comp-3.
05 WS-VARA redefines WS-VAR1 pic vp999 comp-3.

After computation i am moving my value to WS-VAR2 only. That is the reason i said the picture clause is V999 in my first post. Later i have seen the redefines picture clause and i have informed the same in my second post.

I thought WS-VAR2 will hold .102 (actually i am moving .1025) and that should be displayed when i check in FILEAID. but in fileaid it shows .025
but my senior says it is .1025 only because of the redefines picture clause VP999 it will store the actual value. I really dont understand how come this happens?

Regards,
Sasikumar.K
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Apr 17, 2010 7:23 am    Post subject: Re: Reply to: Problem with movind 99v99 to v999 field
Reply with quote

sasikumar1984 wrote:
I thought WS-VAR2 will hold .102 (actually i am moving .1025) and that should be displayed when i check in FILEAID. but in fileaid it shows .025
but my senior says it is .1025 only because of the redefines picture clause VP999 it will store the actual value. I really dont understand how come this happens?
Robert, since you seem to have the big box available, how about a slightly modified test of your last proof?
Inquiring minds want to know....grin....
Code:
       77  WS-VAR1 PIC 99V99 VALUE  10.25 .
       77  WS-VAR2 PIC V999 COMP-3.
       77  WS-VAR2A PIC VP999 COMP-3.
       77  WS-VAR3 PIC V9999 VALUE  .0000 .
       77  WS-EDIT PIC +9(4).9(4).


       PROCEDURE DIVISION.
           COMPUTE WS-VAR3 = WS-VAR1 * .01 .
           MOVE WS-VAR3                TO  WS-VAR2.
           MOVE WS-VAR1                TO  WS-EDIT.
           DISPLAY 'WS-VAR1 ' WS-EDIT.
           MOVE WS-VAR2                TO  WS-EDIT.
           DISPLAY 'WS-VAR2 ' WS-EDIT.
           MOVE WS-VAR3                TO  WS-EDIT.
           DISPLAY 'WS-VAR3 ' WS-EDIT.

           COMPUTE WS-VAR3 = WS-VAR1 * .01 .
           MOVE WS-VAR3                TO  WS-VAR2A.
           MOVE WS-VAR1                TO  WS-EDIT.
           DISPLAY 'WS-VAR1 ' WS-EDIT.
           MOVE WS-VAR2A               TO  WS-EDIT.
           DISPLAY 'WS-VAR2 ' WS-EDIT.
           MOVE WS-VAR3                TO  WS-EDIT.
           DISPLAY 'WS-VAR3 ' WS-EDIT.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Sat Apr 17, 2010 7:50 am    Post subject:
Reply with quote

I cut and pasted your code, compiled and ran -- ask and you receive :
Code:
 WS-VAR1 +0010.2500
 WS-VAR2 +0000.1020
 WS-VAR3 +0000.1025
 WS-VAR1 +0010.2500
 WS-VAR2 +0000.0025
 WS-VAR3 +0000.1025
I think COBOL is using the P to generate the intermediate results, although I have not (yet) gone into the manuals to confirm this. icon_smile.gif
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Apr 17, 2010 7:57 am    Post subject:
Reply with quote

Thanks, the manual is somewhat confusing with regard to the abnormal use of the P symbol. A couple hours comparing the results of your test and the text of the manual might clear up my condusion.

Dang, to be back in the saddle again....grumble....
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Sat Apr 17, 2010 8:09 am    Post subject:
Reply with quote

Let's see ... 3 hours of meetings Tuesday, 6 hours Wednesday, 3 hours Thursday, 2 hours today -- while the normal work load continues to pile up. I think I've got saddle sores -- wanna trade? icon_biggrin.gif

Not to mention more meetings on Monday and Tuesday ... sigh

Anyway, as far as the P goes, from section 5.3.12.1.1 of the COBOL Language Reference manual:
Quote:
In certain operations that reference a data item whose PICTURE character-string contains the symbol P, the algebraic value of the data item is used rather than the actual character representation of the data item. This algebraic value assumes the decimal point in the prescribed location and zero in place of the digit position specified by the symbol P. The size of the value is the number of digit positions represented by the PICTURE character-string.
and 5.3.18.1.1:
Quote:
With some exceptions, numeric literals in a VALUE clause must have a value within the range of values indicated by the PICTURE clause for the item. For example, for PICTURE 99PPP, the literal must be zero or within the range 1000 through 99000. For PICTURE PPP99, the literal must be within the range 0.00000 through 0.00099.
So the VP999 will have values between 0.0000 and 0.0999 as the P must be a 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: Sat Apr 17, 2010 8:10 am    Post subject: Reply to: Problem with movind 99v99 to v999 field
Reply with quote

Hi Bill,

Here ya go . . .
WS-VAR1 +0010.2500
WS-VAR2 +0000.1020
WS-VAR3 +0000.1025
WS-VAR1 +0010.2500
WS-VAR2 +0000.0025
WS-VAR3 +0000.1025

d
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: Sat Apr 17, 2010 8:13 am    Post subject: Reply to: Problem with movind 99v99 to v999 field
Reply with quote

Oops.. . .

Was interrupted longer than i realized - should have refreshed before sending the reply icon_redface.gif

At least we got the same results. . .

d
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 Performing arithmetic on input field zh_lad DFSORT/ICETOOL 22 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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