Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: TO convert X(12) to 9(10)v9(02)
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    Post subject: Reply to: TO convert X(12) to 9(10)v9(02)
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    Post subject:
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    Post subject:
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    Post subject:
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: 276
Location: Bang,iflex

PostPosted: Wed May 28, 2008 10:56 am    Post subject:
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    Post subject:
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    Post subject: Reply to: TO convert X(12) to 9(10)v9(02)
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    Post subject:
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: 6967
Location: porcelain throne

PostPosted: Wed May 28, 2008 6:28 pm    Post subject:
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    Post subject:
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    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 Convert current to hex value gopurs DFSORT/ICETOOL 4 Wed Feb 15, 2017 5:40 am
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts convert PD to ZD ram_vizag DFSORT/ICETOOL 5 Sat Nov 05, 2016 3:06 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us