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
 
How to move COMP-3 var to Alphanum variable?

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

New User


Joined: 11 Aug 2005
Posts: 85
Location: England

PostPosted: Fri Feb 23, 2007 6:25 pm    Post subject: How to move COMP-3 var to Alphanum variable?
Reply with quote

Hi ,

INPUT file :
01 WS-VAR-A PIC s9(9)v(99) COMP-3.
OUTPUT file :
02 WS-VAR-B PIC 9,999,999.99.

I need necessary cobol code to move
WS-VAR-A TO WS-VAR-B

Any suggestions are welcome.
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Feb 23, 2007 6:31 pm    Post subject:
Reply with quote

move WS-VAR-A TO WS-VAR-B
truncation might occur.....
Back to top
View user's profile Send private message
leo_sangha

New User


Joined: 11 Aug 2005
Posts: 85
Location: England

PostPosted: Fri Feb 23, 2007 6:39 pm    Post subject: Re: How to move COMP-3 var to Alphanum variable?
Reply with quote

the pic clause of WS-VAR-B is NOT Pic 9999999.99.

it is PIC 9,999,999.99.

Something like 9(,Comma)999(,Comma)999.99

Please correct me if i am missing something.
Back to top
View user's profile Send private message
leo_sangha

New User


Joined: 11 Aug 2005
Posts: 85
Location: England

PostPosted: Fri Feb 23, 2007 7:06 pm    Post subject: Re: How to move COMP-3 var to Alphanum variable?
Reply with quote

it worked thanks ...
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Feb 23, 2007 9:42 pm    Post subject:
Reply with quote

Hello,

It will work until the value in A is ten million or greater. The tens of millions and hundreds of millions will not fit into B. B is defined to handle a value up to nine million, nine hundred ninety-nine thousand, nine hundred ninety-nine point 99 - 10million and higher will fail.

In COBOL, 9(9)v99 specifies 11 total positions with an implied 2 decimals.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat Feb 24, 2007 12:30 am    Post subject: Re: How to move COMP-3 var to Alphanum variable?
Reply with quote

leo_sangha wrote:
the pic clause of WS-VAR-B is NOT Pic 9999999.99.

it is PIC 9,999,999.99.

Something like 9(,Comma)999(,Comma)999.99

Please correct me if i am missing something.
And what is your point? The move works into a numeric edit field, it is no longer numeric, now it is display.
Back to top
View user's profile Send private message
sunilm

New User


Joined: 18 Aug 2006
Posts: 3
Location: Pune

PostPosted: Tue Mar 06, 2007 6:05 pm    Post subject: Moving Comp-3 to Numeric
Reply with quote

I have to move the WS-AMT PIC S9(16)V99 COMP-3 to
WS-AMT-B PIC S9(14).99
I moved the value and written in the output file then I view the file the Amounts are not displayed properly.
for EX.the value -2983444.45 is displayed as 299L}}} like this.

Can anyone please help in this regards.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 965
Location: Richmond, Virginia

PostPosted: Tue Mar 06, 2007 6:31 pm    Post subject:
Reply with quote

You don't want both "S" (internal sign) and "." (explicit decimal point) in the same picture. Is your field internal or external?

You also would want the number of target field digits to be not less than the source field's. Since your source has a sign ("S"), you should have an explicit sign position int he target - e.g., either + or -.
Back to top
View user's profile Send private message
sunilm

New User


Joined: 18 Aug 2006
Posts: 3
Location: Pune

PostPosted: Tue Mar 06, 2007 6:37 pm    Post subject:
Reply with quote

I want the sign and decimal point in the output file.It does not matter internal or External.I want all the numbers in the input feild to the Target field including sign and decimal point
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Mar 06, 2007 9:37 pm    Post subject:
Reply with quote

Hello,

You do not want the S in the output. If you want to see the sign, you need to include a minus-sign '-' in the output definition. Do you want the output to be -123.77 or 123.77-? You may have the minus sign on either side. You also need to account for all of the digits in the output definition - your definition will not handle all of the digits in the "sending" field. Do you want the result padded with zeros?

Please post a few amounts (up to the maximum number of digits) and how you want the output and we will give you the output definition that will do what you want.

It does matter if it is "internal or External". Internal is for the computer and external is for the eyes.
Back to top
View user's profile Send private message
sunilm

New User


Joined: 18 Aug 2006
Posts: 3
Location: Pune

PostPosted: Wed Mar 07, 2007 10:25 am    Post subject:
Reply with quote

Millions of Thanks to Phil and Dick,Its worked,I was not aware of external and internal your answer gave the clear Picture..........

Hope to get this type of immediate response in the future...

Regards
Sunilm
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Mar 07, 2007 8:22 pm    Post subject:
Reply with quote

You're welcome, Sunilm.

Hopefully, you will icon_smile.gif
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 Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm

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