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 Manipulation in Cobol

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

New User


Joined: 10 May 2010
Posts: 32
Location: Mumbai

PostPosted: Mon Mar 11, 2013 5:01 pm    Post subject: String Manipulation in Cobol
Reply with quote

Hello All ,

I am facing a trouble with string manipulation in cobol.
My requirement is as follows :

Input String : ABCD.T.H.O.D.N.345@q wert
Expected Output String : ABCD345@q wert

I need to remove the specific word in above case it is 'T.H.O.D.N.' from the string and continue with rest as it is without having any gaps or spaces in between.

Appreciate your suggestion in this regards.

Thanks,
Shweta.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Mon Mar 11, 2013 5:20 pm    Post subject: Re: String Manipulation in Cobol
Reply with quote

Code:
Input String : ABCD.T.H.O.D.N.345@q wert
Expected Output String :  ABCD345@q wert


Do you mean to remove ".T.H.O.D.N." instead, or is your output to be "ABCD.345@q wert"?

Edit, is the "substring" to be removed always the same? Always the same length? What is the source of it?
Back to top
View user's profile Send private message
Shweta12j

New User


Joined: 10 May 2010
Posts: 32
Location: Mumbai

PostPosted: Mon Mar 11, 2013 6:13 pm    Post subject: Reply to: String Manipulation in Cobol
Reply with quote

Hello Bill ,

Yes I want to remove this specific word from the input string and want an output as ABCD.345@q wert.

My input string is having a picture clause of X(50).
Source is an input from the User.

User can enter anything in this field which I am further using to query a database. But before that I need to manipulate the input field by removing specific words.

Regards,
Shweta.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 271
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Mon Mar 11, 2013 6:17 pm    Post subject:
Reply with quote

Quote:

But before that I need to manipulate the input field by removing specific words.


You need to elaborate more on this. What specific words/chars you want to remove..this will help you find a pattern in that and apply some logic to remove that.
Back to top
View user's profile Send private message
Shweta12j

New User


Joined: 10 May 2010
Posts: 32
Location: Mumbai

PostPosted: Mon Mar 11, 2013 6:24 pm    Post subject: Reply to: String Manipulation in Cobol
Reply with quote

sorry forgot to state one thing.

The words which are required to be removed would vary in length.

Below are few words which needs to be removed from the input String :
1 ) B.V.
2) BV
3)VAN
4)V.A.N

Regards,
Shweta.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10241
Location: italy

PostPosted: Mon Mar 11, 2013 6:53 pm    Post subject: Reply to: String Manipulation in Cobol
Reply with quote

Your terminology is a bit confused ...
the <words> posted are mixing up the word concept ...

until You define the word separator <char> You will not be able to deal with <words>

shall we be correct in assuming that the word seaparators will be the traditional ones ( punctuation signs, beginning of string, end of string ) ...
what about the underscore _ and the at sign @

and when eliminating a <word> what delimiter should be kept
NONE... the initial one or the ending one
( in a generalized approach they might be different )

using Your example slightly modified

not a problem for
Code:
Input  ==> ABCD.T.H.O.D.N.345@q wert
Output ==>ABCD345@q wert

( no delimiter kept)

but You should take into account the possibility of
Code:
Input  ==> ABCD.T.H.O.D.N@q wert
Output ==>ABCD@q wert

where the terminating delimiter MUST be kept


meditate a bit, meditate icon_cool.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10241
Location: italy

PostPosted: Mon Mar 11, 2013 7:19 pm    Post subject: Reply to: String Manipulation in Cobol
Reply with quote

hit enter too soon ...

and anyway You must make provision to drop the terminating separator for words at the beginning of a string
and the initial one for words at the end
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 Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am
No new posts RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 am
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm


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