Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Able to move value from field of S9(17) COMP-3 to PIC S9(7)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Able to move value from field of S9(17) COMP-3 to PIC S9(7)
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: 8189
Location: East Dubuque, Illinois, USA

PostPosted: Thu Apr 07, 2011 3:30 pm    Post subject:
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    Post subject: Reply to: Able to move value from field of S9(17) COMP-3 to
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Thu Apr 07, 2011 4:25 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Thu Apr 07, 2011 9:26 pm    Post subject:
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: 8189
Location: East Dubuque, Illinois, USA

PostPosted: Thu Apr 07, 2011 10:37 pm    Post subject:
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    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 CONDITIONAL USING COMP-2 WITH PROBLEMS. JOSUEGENTIL COBOL Programming 7 Wed Nov 08, 2017 11:13 pm
No new posts how can i move s9(9) to s9(9) usage comp HARENDRA CHOUDHARY COBOL Programming 3 Mon Nov 06, 2017 12:10 am
No new posts Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm
This topic is locked: you cannot edit posts or make replies. Incrementing current time field by 30... arunsoods DFSORT/ICETOOL 11 Thu Oct 26, 2017 3:22 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us