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
 

 

Need to convert non-numeric to non-numeric

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Need to convert non-numeric to non-numeric
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: 2181
Location: @my desk

PostPosted: Thu Nov 23, 2006 3:07 pm    Post subject: Re: Need to convert non-numeric to non-numeric
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    Post subject:
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    Post subject:
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: 2181
Location: @my desk

PostPosted: Fri Nov 24, 2006 11:22 am    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Fri Nov 24, 2006 2:31 pm    Post subject:
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    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 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
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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