View previous topic :: View next topic
|
Author |
Message |
ram_vizag
Active User
Joined: 21 Aug 2008 Posts: 112 Location: hyd
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Also
Can WS-PERCENT hold value like 1.333 or .1333? |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
ram_vizag
Active User
Joined: 21 Aug 2008 Posts: 112 Location: hyd
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
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 |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
No DB2 involved!
and google COBOL Intrinsic FUNCTION NUMVAL() |
|
Back to top |
|
|
ram_vizag
Active User
Joined: 21 Aug 2008 Posts: 112 Location: hyd
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
If you ultimately need 9.9999
why convett to 99.99 |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
|