View previous topic :: View next topic
|
Author |
Message |
janmejay Warnings : 1 New User
Joined: 22 Jun 2007 Posts: 85 Location: bangalore
|
|
|
|
Hello
I have reqmt like move only numeric part to a variable from a string
newyork405567
australia1234566
india908766
sri lanka8900000
so for first string it will extract only 405567 and moved to variable,same for other strings. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
And how did you do it? |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
How about checking each byte value against 0-9 and move if true else skip till end of field or space? Also observed that the subject line is contradicting what you want. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Will there be any numerics within the "text" part of the string? If so, are these to be extracted as well? If they exist and are not to be extracted then Rohit's solution would not work. Surely you can work out the logic to find the first and last digit so that you can then extract the numerics? As Peter Holland wrote - what have you tried? |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
Nic Clouston wrote: |
As Peter Holland wrote - what have you tried? |
"I tried posting here, as doing something myself might be putting to much stress on my grey cell - being alone is already bad enough!" |
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
Hi,
If there is not going to be any numeric in text part, then u can check at what instance of length you are getting first numeric and then use reference modification
Thanks ,
Chandan |
|
Back to top |
|
|
muralikrishnan_new
New User
Joined: 02 Jun 2013 Posts: 15 Location: India
|
|
|
|
Hi Jan,
Please try using the function NUMVAL-C.
Code: |
MOVE FUNCTION(NUMVAL-C(WS-STR)) TO WS-STR1.
|
Thanks,
Murali |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Murali
How is that going to drop the alpha characters? Numval-c works on numeric data with a possible currency sign and editing characters. |
|
Back to top |
|
|
|