View previous topic :: View next topic
|
Author |
Message |
arunmozhicholan
New User
Joined: 07 Feb 2007 Posts: 27 Location: chennai
|
|
|
|
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 |
|
|
yogeshwar_ade
Active User
Joined: 31 Aug 2006 Posts: 103 Location: INDIA
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Redefine your x(13) field as 9(10).9(2) then just do a move. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
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 |
|
|
vasanthkumarhb
Active User
Joined: 06 Sep 2007 Posts: 275 Location: Bang,iflex
|
|
|
|
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 |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 Location: Bangalore
|
|
|
|
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 |
|
|
jckraheja
New User
Joined: 19 May 2008 Posts: 13 Location: Pune
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Has arunmozhicholan left the building? |
|
Back to top |
|
|
|