View previous topic :: View next topic
|
Author |
Message |
donpaulose
New User
Joined: 19 Apr 2007 Posts: 3 Location: Pune, India
|
|
|
|
Hi All,
i had a requirment wherein i had to move value from value from field of S9(17) COMP-3 to PIC S9(7) . i have used the following method
define the field in ws as
TOT-CURR-BAL PIC S9(17) COMP-3.
TOT-CR-BAL PIC S9(7)V9(2)
01 WS-G-TOT-CURR-BAL PIC S9(9) VALUE ZEROES.
01 WS-G-TOT-CUR-BAL
REDEFINES WS-G-TOT-CURR-BAL.
03 WS-G-TOT-CR-BAL PIC S9(7)V9(2).
and moved the field as below
MOVE G-TOT-CURR-BAL
TO WS-G-TOT-CURR-BAL
MOVE WS-G-TOT-CR-BAL
TO output field.
its works fine if used as above |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
I don't see any question in here.
You are deliberately getting rid of the two digits after the decimal point in your original field, right? |
|
Back to top |
|
|
donpaulose
New User
Joined: 19 Apr 2007 Posts: 3 Location: Pune, India
|
|
|
|
i have to move the amount field 7 bytes along with 2 decimal places. so some values would get truncated if the input value is more than 9 bytes. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
And is there a question?
Or are you just showing us your code so that we can constructively comment on it?
Code: |
DIVIDE TOT-CURR-BAL BY 100 GIVING output field.
|
Would do it without your extra fields. If you want extra fields, I'd make them comp-3 as well, to be neat. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK, a joke can only go on so long. I'm just worried someone will copy my "idea".
What I'd really do is redefine the field (a filler, then the amount of digits I wanted with the implicit decimal place). Then just move it.
Why wouldn't I do the divide? Well, it is a horrible size, probably the compiler would have to do all sorts of tricky things (like calling routines) to do a calculation with such a number. I wonder why it is so big anyway. Even in Yen, that would be a huge value. More than the total GDP of the entire planet would be my guess (I'm not going to bother calculating). |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
have to move the amount field 7 bytes along with 2 decimal places. so some values would get truncated if the input value is more than 9 bytes. |
Yeah, so? You can't put 10 pounds of potatoes in a 5 pound sack, as Dolly Parton famously said. If you are going to move a 17-digit number to a 7-digit number, you have the possibility of losing 10 digits off the front of the number, and there's nothing you can do about it. |
|
Back to top |
|
|
|