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

How to replace a string all the capital letters


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

New User


Joined: 20 Apr 2012
Posts: 20
Location: chennai

PostPosted: Mon May 14, 2012 5:20 pm
Reply with quote

how to replace a string all the capital letters with capitals of the same ,and alll the small letters with default xxxx...
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 14, 2012 5:45 pm
Reply with quote

Have a look at INSPECT, or just do it yourself in a loop of your choice. Only specify lower-case for changing. Decide how to know what to change them to, given that presumably you are "masking" data, and it shouldn't be done so it can be readily "unmasked". You can get at random numbers in your program. Search the forum if you don't know about them.


Check at your site - perhaps there is already a tool?
Back to top
View user's profile Send private message
swarnasuneel

New User


Joined: 20 Apr 2012
Posts: 20
Location: chennai

PostPosted: Mon May 14, 2012 5:58 pm
Reply with quote

how to change Only LowerCase Only
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 14, 2012 6:05 pm
Reply with quote

Only secify lowercase Only to be changed.

If you were to replace "a" by "x", only "a" would be replaced. If you replaced "A" by "x", only "A" would be replaced.
Back to top
View user's profile Send private message
swarnasuneel

New User


Joined: 20 Apr 2012
Posts: 20
Location: chennai

PostPosted: Mon May 14, 2012 6:12 pm
Reply with quote

ALL the Alphabets Which are in Lower case Should Be replace ALL With All "XXXXXXXXXXX"
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 14, 2012 6:25 pm
Reply with quote

OK. And have you looked to see if INSPECT can do if for you?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon May 14, 2012 6:41 pm
Reply with quote

Introduced with COBOL/370, review FUNCTION UPPER-CASE, which will convert lower-case to upper-case.

I think this is what you're trying to accomplish? icon_question.gif
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon May 14, 2012 7:14 pm
Reply with quote

If by chance, you're still on OS/VS COBOL and you've chosen to use the EXAMINE (Ansi 68) or TRANSFORM (Ansi 74) Verb (both predecessors to INSPECT) in a CICS environment, you'll need to find another method.

Under the covers, EXAMINE/TRANSFORM issue an MVS GETMAIN but not an MVS FREEMAIN. If you invoke either of these Verbs too many times in a given region, the region will abend with an S80A (Virtual Storage Exhausted).

Just a heads-up....
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon May 14, 2012 8:19 pm
Reply with quote

Hello,

If i understand correctly, any/all lower-case values should be changed to an X.

So if the "input" was
Code:
AbcdEFghijKlmnoP
the "output" would be
Code:
AXXXEFXXXXKXXXXP

Is this correct? If not, please clarify with examples.
Back to top
View user's profile Send private message
swarnasuneel

New User


Joined: 20 Apr 2012
Posts: 20
Location: chennai

PostPosted: Mon May 14, 2012 8:45 pm
Reply with quote

yes, it correct can any provide a solution plss
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Mon May 14, 2012 9:02 pm
Reply with quote

swarnasuneel wrote:
yes, it correct can any provide a solution plss

As you count COBOL amongst your skills, you ought to easily be able to deduce how to use the INSPECT statement mentioned twice to you by Sr. Woodger.

ETA: And a third time whilst I was writing this.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 14, 2012 9:02 pm
Reply with quote

Look at INSPECT CONVERTING in the manual (link at the top of the page) or code your own loop-construct of choice, preferably avoiding reference-modification, specifying the lower-case letters and 26 X's (or one X if doing it yourself).
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon May 14, 2012 9:03 pm
Reply with quote

So, Dick's assessment is correct?

How are you going to distinguish a legitimate (unconverted) capital "X" from a converted lower-case letter, now represented as a capital "X"?

You need to reevaluate your idea or did this come from "Management"? icon_rolleyes.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon May 14, 2012 9:04 pm
Reply with quote

You've a solution lying there already in all these posts, start with some pseudo code at least.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon May 14, 2012 9:10 pm
Reply with quote

Hello,

As others have mentioned, look at INSPECT. It will do what you need.

At the top of the page is a link to "IBM Manuals". At the top of the list are manuals for COBOL.

In the COBOL Language Reference (Using the manual search (yellow flashlight/tubelight) search for INSPECT). From the results, notice the entry for INSPECT statement, 6.2.21

Click on this and Read about INSPECT. If you find something in the manual that is not clear, post what you found and your doubt. Someone will be able to clarify.

If you click on the COBOL Programming Guide and search for INSPECT, there is an example of what you want to do in that manual.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 14, 2012 9:26 pm
Reply with quote

It's a good point from Mr Bill, and you've changed your requirement since your initial posts.

Don't tell me it'll be fine the way you have it, unless you want to mess-up names like Raul-Xavier Quango and similar...

From your original, there was at least some point in keeping the uppercase unchanged (so you could, for instance, verify correct processing of mixed-case text). Now, why bother to keep anything original?
Back to top
View user's profile Send private message
dudenithy

New User


Joined: 02 Mar 2012
Posts: 48
Location: India

PostPosted: Thu Jul 26, 2012 12:16 pm
Reply with quote

As Bill suggested, we have FUNCTION for converting lower case to Upper case and vice versa through the commands UPPER-CASE and LOWER-CASE respectively.
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
Search our Forums:

Back to Top