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

Need to convert non-numeric to non-numeric


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

New User


Joined: 27 Jul 2005
Posts: 35
Location: Chennai

PostPosted: Thu Nov 23, 2006 2:17 pm
Reply with quote

I also have datas like

/188-160 4/
026 375 3/
028-625 7


how to convert these into numeric values....
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Nov 23, 2006 3:07 pm
Reply with quote

You can check if each character is numeric or not and move to output field.
Back to top
View user's profile Send private message
sankar_MF

New User


Joined: 19 Sep 2006
Posts: 29

PostPosted: Fri Nov 24, 2006 10:28 am
Reply with quote

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
View user's profile Send private message
chandu321
Currently Banned

New User


Joined: 27 Jun 2006
Posts: 8

PostPosted: Fri Nov 24, 2006 11:01 am
Reply with quote

I guess u can use Function NUMVAL-C
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Nov 24, 2006 11:22 am
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Nov 24, 2006 2:31 pm
Reply with quote

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
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 Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
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
Search our Forums:

Back to Top