View previous topic :: View next topic
|
Author |
Message |
Abi
New User
Joined: 27 Jul 2005 Posts: 35 Location: Chennai
|
|
|
|
I also have datas like
/188-160 4/
026 375 3/
028-625 7
how to convert these into numeric values.... |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
You can check if each character is numeric or not and move to output field. |
|
Back to top |
|
|
sankar_MF
New User
Joined: 19 Sep 2006 Posts: 29
|
|
|
|
Hi Abi,
The above conversion can be achieved by unstring and string the text. This is simple.
First unstring the Text
UNSTRING WS-VAR DELIMITED BY '/' OR '-' OR SPACE
INTO WS-STR1, WS-STR2,WS-STR3, WS-STR4.
Then string it by
STRING WS-STR1, WS-STR2, WS-STR3, WS-STR4 DELIMITED BY SPACES
INTO WS-VAR-ST.
The Converted string from the given string
WS-VAR =/188-160 4/ will be
WS-VAR-ST = 1881604 |
|
Back to top |
|
|
chandu321 Currently Banned New User
Joined: 27 Jun 2006 Posts: 8
|
|
|
|
I guess u can use Function NUMVAL-C |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Hi
Without knowing the exact position where the non-numeric character is coming how we will define the length of the target string in UNSTRING.we are also not sure about the no of target strings.So i think its better to scan each character.The solution is already given in another topic.Please refer to the below link
http://ibmmainframes.com/about15789.html
Thanks
Arun |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Sometimes you just have to byte the bullet and use some brute force methods....
Code: |
01 filler.
05 result-char.
10 num pic 9 occurs 11 times
indexed by in.
05 result-num redefines resulta
pic 9(10).
05 source.
10 char pic 9 occurs 11 times
indexed by ix.
set ix to 11.
set in to 11.
move zero to resultn.
move garbage to source.
perform 11 times
if char (ix) numeric
move char (ix) to num (in)
set ix down by 1
set in down by 1
else
set ix down by 1
end-if
end-perform.
111-222-333 00111222333
111/222/333 00111222333
111 222 333 00111222333
111-222/333 00111222333
/188-160 4/ 00001881604
026 375 3/ 00000263753
028-625 7 00000286257
garbage 00000000000 |
|
|
Back to top |
|
|
|