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

How to convert upper to lower, lower to upper within a strin


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

New User


Joined: 05 Dec 2005
Posts: 79

PostPosted: Wed Jan 16, 2008 1:25 pm
Reply with quote

Hi,
I am having text like "sOftWarE'. I need to convert this to "SoFTwARe".
Upper cases to lower and lower cases to upper..
Is there any funtion avaible in cobol ?? If not, how to do it..
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Wed Jan 16, 2008 1:39 pm
Reply with quote

Prabhu,

Is this is a homework?
Back to top
View user's profile Send private message
Prabha
Warnings : 2

New User


Joined: 05 Dec 2005
Posts: 79

PostPosted: Wed Jan 16, 2008 2:56 pm
Reply with quote

no, we have requirement like this in our project..
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Wed Jan 16, 2008 3:10 pm
Reply with quote

Prabha wrote:
no, we have requirement like this in our project..


in 2 words: In-Credible!

;)
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jan 16, 2008 3:21 pm
Reply with quote

If your requirement is to change all upper to lower and all lower to upper
and
if your version of cobol does not have an upper or upper case command:

declare a 2 byte binary field. initialize to zero. move the alpha char to 2nd byte. IF the binary value of the 2 byte binary field > 169 subtract 64 from the 2 byte binary field. (will change upper to lower) if the value of the binary field is < 193 then add 64 (will change lower to upper).

this will only work for ebcdic. since ebcdic is not going to change, this will always work.

if you are using unicode, use the appropriate cobol command (upper/lower).


if you need to modify specific letters in specific words, I would use level 88s.
Back to top
View user's profile Send private message
k.junaid83

New User


Joined: 19 Apr 2006
Posts: 22
Location: bangalore

PostPosted: Wed Jan 16, 2008 4:11 pm
Reply with quote

Hi,
You can use the following approach for ur requirement.

01 WS-INPUT-STRING PIC X(08) VALUE 'sOftWarE'.
01 FIRST-CASE PIC X(52) VALUE
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.
01 SECOND-CASE PIC X(52) VALUE
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.

PROCEDURE DIVISION.

INSPECT WS-INPUT-STRING CONVERTING
FIRST-CASE BY SECOND-CASE.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Jan 16, 2008 6:07 pm
Reply with quote

This was just asked last week. Did you not search the forum or manual?
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 Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
No new posts Convert HEX to Numeric DB2 3
Search our Forums:

Back to Top