IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Able to move value from field of S9(17) COMP-3 to PIC S9(7)


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
donpaulose

New User


Joined: 19 Apr 2007
Posts: 3
Location: Pune, India

PostPosted: Thu Apr 07, 2011 3:23 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 07, 2011 3:30 pm
Reply with quote

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
View user's profile Send private message
donpaulose

New User


Joined: 19 Apr 2007
Posts: 3
Location: Pune, India

PostPosted: Thu Apr 07, 2011 3:33 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 07, 2011 4:25 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Apr 07, 2011 9:26 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 07, 2011 10:37 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
Search our Forums:

Back to Top