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

How to move COMP-3 var to Alphanum variable?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 3156
Location: Tucson AZ

PostPosted: Fri Feb 23, 2007 6:31 pm
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
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
Reply with quote

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

Moderator Emeritus


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

PostPosted: Fri Feb 23, 2007 9:42 pm
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: 3156
Location: Tucson AZ

PostPosted: Sat Feb 24, 2007 12:30 am
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
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

Senior Member


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

PostPosted: Tue Mar 06, 2007 6:31 pm
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
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

Moderator Emeritus


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

PostPosted: Tue Mar 06, 2007 9:37 pm
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
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

Moderator Emeritus


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

PostPosted: Wed Mar 07, 2007 8:22 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Creating CSV file from Variable recs ... DFSORT/ICETOOL 11
No new posts Evaluate variable to execute a jcl step JCL & VSAM 3
No new posts Inserting variable length into output... JCL & VSAM 2
No new posts Setting CA7 user variable from data s... CA Products 7
Search our Forums:

Back to Top