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

TO convert X(12) to 9(10)v9(02)


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

New User


Joined: 07 Feb 2007
Posts: 27
Location: chennai

PostPosted: Tue May 27, 2008 4:30 pm
Reply with quote

i have a value in input file in X(12) pic clause as 0000000005.5f whcih has to be converted to 5.56...how can we convert it to numeric value..can we move it to 9(10)v9(02).is it possible?
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Tue May 27, 2008 5:06 pm
Reply with quote

Try NUMVAL Function. It is used to convert Alphanumeric values to Numeric, provided you have Numeric value in your Alphanumeric Variables.

Have a look HERE
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue May 27, 2008 5:24 pm
Reply with quote

Redefine your x(13) field as 9(10).9(2) then just do a move.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue May 27, 2008 8:24 pm
Reply with quote

Arun,

You say the field is PIC X(12), but you show "0000000005.5f" (13 pos). Are you sure the value is not "00000000055F", or is the PIC X(13) ?

The correct ans depends on correct I/P.
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Wed May 28, 2008 9:27 am
Reply with quote

Using REDEFINES is a good method.
However, you have to make sure that the X(12) variable is not having any data that cant be processed as a numeric data in the 9(10)v9(02) variable.
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Wed May 28, 2008 10:56 am
Reply with quote

Hi,


the_gautam wrote:
Using REDEFINES is a good method.
However, you have to make sure that the X(12) variable is not having any data that cant be processed as a numeric data in the 9(10)v9(02) variable.


Is REDEFINES is a perfect convertor from one data type to another data type??. It just reallocates the memory for the new variable.
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Wed May 28, 2008 11:22 am
Reply with quote

I never said that REDEFINES is the perfect converter from one data type to another data type.
What i told was for his requirement. I also added that he should be careful about the data.
Back to top
View user's profile Send private message
jckraheja

New User


Joined: 19 May 2008
Posts: 13
Location: Pune

PostPosted: Wed May 28, 2008 6:01 pm
Reply with quote

05 AlphaField-1 pic x(13) value '0000000005.56'
05 Numeric-fld redefines AlphaField-1 pic 9(11)V9(02) --- if input data doesn't contain any sign

COMPUTE Numeric-fld = NUMVAL(AlphaField-1)

This might solve yr problem....
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed May 28, 2008 6:23 pm
Reply with quote

Well Arun, while we're waiting for an ans, I'll assume the field VAL has to be 00000000055F, since S9(10).9(02) is an invalid PIC. Given that:

MOVE PIC-X-FLD TO NUM-FLD(1:)

will work if NUM-FLD = PIC S9(10)V9(02).

Redefines is the better approach, if you can use it.

Whether you use a move or redefines, test the field for numerics before attempting arith.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed May 28, 2008 6:28 pm
Reply with quote

jckraheja,

user has indicated that he has a overprint sign.

why redefine the x-type with the numeric?

why not define a new variable <S9(11)V99>, with sign?
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu May 29, 2008 6:02 pm
Reply with quote

Has arunmozhicholan left the building?
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 Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
No new posts Convert HEX to Numeric DB2 3
Search our Forums:

Back to Top