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
 

 

String in Cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 81
Location: bangalore

PostPosted: Sun Jun 26, 2016 11:28 am    Post subject: String in Cobol
Reply with quote

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

PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2425
Location: Netherlands, Amstelveen

PostPosted: Sun Jun 26, 2016 1:54 pm    Post subject:
Reply with quote

And how did you do it?
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1638
Location: NY,USA

PostPosted: Sun Jun 26, 2016 2:55 pm    Post subject:
Reply with quote

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

Global Moderator


Joined: 10 May 2007
Posts: 1727
Location: UK

PostPosted: Sun Jun 26, 2016 3:26 pm    Post subject:
Reply with quote

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

Active Member


Joined: 07 Feb 2009
Posts: 995
Location: Oostende, Belgium

PostPosted: Sun Jun 26, 2016 9:11 pm    Post subject:
Reply with quote

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
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Mon Jun 27, 2016 9:27 am    Post subject:
Reply with quote

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

New User


Joined: 02 Jun 2013
Posts: 11
Location: India

PostPosted: Mon Jun 27, 2016 3:17 pm    Post subject: Reply to: String in Cobol
Reply with quote

Hi Jan,
Please try using the function NUMVAL-C.
Code:

            MOVE FUNCTION(NUMVAL-C(WS-STR)) TO WS-STR1.
         


Thanks,
Murali
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1727
Location: UK

PostPosted: Mon Jun 27, 2016 9:23 pm    Post subject:
Reply with quote

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
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 Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am


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