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
 

 

Regarding percent to value convertion

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

New User


Joined: 21 Aug 2008
Posts: 92
Location: hyd

PostPosted: Thu Dec 12, 2013 1:52 pm    Post subject: Regarding percent to value convertion
Reply with quote

Hi,

I have a value in pic x(5)(percent value ex: 13.33) which come as input from cics and should be update into the table with pic S9(1)V9(5) comp-3

I should divide the 13.33 by 100 and update value into table.
first i have to move the percent to s9(2)v99) and divided and updated in table

is the following works?????? pleas suggest i cant test roght now the code....
Code:

01 ws-percent       pic x(05) value 13.33.----this i'll get from cics which is declared as x(05) in the map.
01 WS-BUS-COMMISSION.                                         
   05 WS-BUS-HUNDRED         PIC 9(03)  VALUE 100.             
   05 WS-BUS-COMM-PERCENT    PIC S9(2)V99 USAGE COMP-3.       
   05 WS-BUS-PERCENT-VALUE   PIC S9(1)V9(5) USAGE COMP-3.     

MOVE WS-PERCENT    TO WS-BUS-COMM-PERCENT
DIVIDE  WS-HUNDRED INTO    WS-BUS-COMM-PERCENT
                   GIVING  WS-BUS-PERCENT-VALUE



PLEASE SUGGEST WHETHER THE ABOVE IS CORRECT???
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Dec 12, 2013 2:58 pm    Post subject:
Reply with quote

Suggest you to try it when you find time and post your findings or problems or error you had got

Hint : Your code wont work as you expect
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Dec 12, 2013 3:35 pm    Post subject:
Reply with quote

Also

Can WS-PERCENT hold value like 1.333 or .1333?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1714
Location: UK

PostPosted: Thu Dec 12, 2013 3:56 pm    Post subject: Reply to: Regarding percent to value convertion
Reply with quote

Quote:
PLEASE SUGGEST WHETHER THE ABOVE IS CORRECT???

Why the CAPITALS? Very rude.

Why post in DB2 when it is a COBOL query that you have?

Why don't you get a COBOL compiler to run on your private machine then you could try such things at home.
Back to top
View user's profile Send private message
ram_vizag

New User


Joined: 21 Aug 2008
Posts: 92
Location: hyd

PostPosted: Thu Dec 12, 2013 5:06 pm    Post subject:
Reply with quote

Pandora-Box wrote:
Also

Can WS-PERCENT hold value like 1.333 or .1333?



yes it can hold the value....i'm tryuing but not getting exactly need not divide here for this conversion simple have to declate the destination variable as to get populated as( 0.1234)
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Dec 12, 2013 5:51 pm    Post subject:
Reply with quote

What you need to do is something like below

Move x(5) to 9(5) without '.'
Reverse x(5)
Based on position of '.' in reverse of x(5) you need to divide by 10^(position -1)
so if x(5) has .1333
You need to store 01333 in 9(5) and divide by 10^4 ( 4 is becasue reverse of x(5) 3331. '.' in 5th position)
Divide the above result by 100
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Thu Dec 12, 2013 6:34 pm    Post subject:
Reply with quote

No DB2 involved!

and google COBOL Intrinsic FUNCTION NUMVAL()
Back to top
View user's profile Send private message
ram_vizag

New User


Joined: 21 Aug 2008
Posts: 92
Location: hyd

PostPosted: Sun Dec 15, 2013 12:48 am    Post subject:
Reply with quote

Pandora-Box wrote:
What you need to do is something like below

Move x(5) to 9(5) without '.'
Reverse x(5)
Based on position of '.' in reverse of x(5) you need to divide by 10^(position -1)
so if x(5) has .1333
You need to store 01333 in 9(5) and divide by 10^4 ( 4 is becasue reverse of x(5) 3331. '.' in 5th position)
Divide the above result by 100


thanks Pandora,

i Have redefined the x(05) ---12.34 and conveterd to 99.99 and further converted,calculated to 9.99999====from this data type can i move to s9(3) comp-3 which is db2 field...currently i cant test...pls let me know...whether my idea is correct???
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Sun Dec 15, 2013 1:07 am    Post subject:
Reply with quote

If you ultimately need 9.9999

why convett to 99.99
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sun Dec 15, 2013 1:47 am    Post subject: Reply to: Regarding percent to value convertion
Reply with quote

Introduced with COBOL/370 (some 18-20 years ago) and unofficially defined as "Deditting", it allows the movement of an edited field-value (redefined as PIC 99.99) to a PIC 9 unedited field, such as PIC 99V99.

Once you move it to the unedited field, then you can restart from scratch.

Prior to COBOL/370, this type of data-movement was not allowed.

HTH....
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 TIMESTAMP convertion from UTC to EST/... mallik4u DB2 2 Mon Jun 02, 2014 1:13 pm
No new posts convertion of load to cobol source code Robert Sample COBOL Programming 5 Thu Mar 10, 2011 1:23 pm
No new posts Quotation Convertion in Sort ashwinreddy JCL & VSAM 6 Mon Jun 28, 2010 1:24 am
No new posts String convertion mihir.kumar COBOL Programming 4 Tue Oct 27, 2009 11:22 am
No new posts Convertion decimal integer to char delago DB2 1 Wed Sep 16, 2009 9:04 pm


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