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

Replacing Characters in a string by lower or upper case


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

New User


Joined: 08 Apr 2005
Posts: 23
Location: india

PostPosted: Thu Jun 08, 2006 12:38 pm
Reply with quote

Hi,
I have a name variable with any characters (for eg mr. subhash agarwal, mRs. sheila STAGE. etc.). I have to convert this string so that it shows correct format ( eg. Mr. Subhash Agarwal, Mrs. Sheila Stage.
please suggest the "inspect syntax" for this, also if there's an alternative.

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

Active User


Joined: 05 May 2006
Posts: 183
Location: Scotland

PostPosted: Thu Jun 08, 2006 2:45 pm
Reply with quote

Really need more information about your name fields
ie
field size
are the ONLY possibilities Mr and Mrs?
is there always a period after the Mr/Mrs?
does the Forename always start in the same position?
does the Surname always start in the same position
Is it possible that there are middle names, double names
anything else that you are not telling us?
Back to top
View user's profile Send private message
hernikiten

New User


Joined: 08 Apr 2005
Posts: 23
Location: india

PostPosted: Thu Jun 08, 2006 2:52 pm
Reply with quote

Good day IQ,

The positions might change depending upon length of first and middle name. Mr. and Mrs. are the only possibilities.

Thanks
Back to top
View user's profile Send private message
IQofaGerbil

Active User


Joined: 05 May 2006
Posts: 183
Location: Scotland

PostPosted: Fri Jun 09, 2006 4:34 pm
Reply with quote

I think I would use a combination of INSPECT and UNSTRING
along the following lines

first convert all of your name field to lower case
ie

INSPECT NAME-FIELD
CONVERTING
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' TO
'abcdefghijklmnopqrstuvwxyz'

Next split your field into three, I am assuming that there is always a space between title and firstname and firstname and surname and that there are no middle names.
thus set up three fileds to hold the data eg
01 TITLE.
03 TITLE1 Pic x
03 TITLEX Pic x(3)
FIRSTNAME (same as TITLE but you determine size)
SURNAME (same as TITLE but you determine size)
so
UNSTRING NAME-FIELD DELIMITED BY ALL SPACES INTO
TITLE
FIRSTNAME
SURNAME

now you have three fields all lower case so all you need to do now is set the first character in each to upper case eg

Move 'M' to TITLE1

INSPECT FIRSTNAME1
CONVERTING
”abcdefghijklmnopqrstuvwxyz “TO
”ABCDEFGHIJKLMNOPQRSTUVWXYZ “

INSPECT SURNAME1
CONVERTING
”abcdefghijklmnopqrstuvwxyz “TO
”ABCDEFGHIJKLMNOPQRSTUVWXYZ “


then you might want to STRING or MOVE the data back into the original format but I will leave that to you
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
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 COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top