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

Lower Case to upper Case


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

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Fri Mar 28, 2008 4:09 pm
Reply with quote

Hi guys,
I want to know how to convert a value which we get through the input file from lower case to upper case
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Mar 28, 2008 4:23 pm
Reply with quote

What about this?
Code:
FUNCTION UPPER-CASE--(--argument-1--)
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: Sat Mar 29, 2008 2:47 am
Reply with quote

You can stay "in-line" with the following INSPECT (with literals and no reference modification) and avoid the "BALR" using FUNCTION UPPER-CASE. Instead, this generates a single "TR" instruction -

Code:

            03  WS-STRING               PIC X(06) VALUE X'818283848586'.
       *
            INSPECT WS-STRING           CONVERTING X'81828384858687888991
       -                                            '9293949596979899A2A3
       -                                            'A4A5A6A7A8A9'       
                                        TO 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

Regards,

Bill
Back to top
View user's profile Send private message
Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Sat Mar 29, 2008 6:02 am
Reply with quote

If you are changing the full record in a file - it's easy to do it in Sort and feed it to your cobol program without changing your existing COBOL program.
Back to top
View user's profile Send private message
Richa Jain

New User


Joined: 18 Mar 2008
Posts: 35
Location: Gurgaon

PostPosted: Sat Mar 29, 2008 12:26 pm
Reply with quote

If your input string contains only characters, then u can go with this..

Code:

WORKING-STORAGE SECTION.
01 WS-STRING             PIC X(10).           
01 WS-ALPHABTS.                                               
   05 LOWER-CASE PIC X(26) VALUE 'abcdefghijklmnopqrstuvwxyz'.
   05 UPPER-CASE PIC X(26) VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
.
.
.
PROCEDURE DIVISION.

     MOVE IP-STRING TO WS-STRING
     INSPECT WS-STRING                             
       CONVERTING LOWER-CASE TO UPPER-CASE
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: Sat Mar 29, 2008 4:20 pm
Reply with quote

Richa Jain wrote:
If your input string contains only characters, then u can go with this..

Code:

WORKING-STORAGE SECTION.
01 WS-STRING             PIC X(10).           
01 WS-ALPHABTS.                                               
   05 LOWER-CASE PIC X(26) VALUE 'abcdefghijklmnopqrstuvwxyz'.
   05 UPPER-CASE PIC X(26) VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
.
.
.
PROCEDURE DIVISION.

     MOVE IP-STRING TO WS-STRING
     INSPECT WS-STRING                             
       CONVERTING LOWER-CASE TO UPPER-CASE

This will cause the compiler to generate a BALR (Call) to a COBOL run-time routine.

You might as well use the FUNCTION UPPER-CASE as it is the same level of overhead.

Also, someone could easily set upper-case on in the source and automatically convert the lower-case letters in the VALUE clause of LOWER-CASE to upper-case by accidentally hitting the SPACE bar.

Using hex-notation (X'00') will prevent this.

Bill
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: Sat Mar 29, 2008 7:31 pm
Reply with quote

Hello,

If the data to be converted to upper case is an entire record (rather than some particular field), the record must not contain any packed-decimal or binary data. These would most likely cause invalid data conversions.
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 COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Zunit Test case editor error Testing & Performance 4
No new posts usage of CASE in WHERE clause DB2 10
No new posts COBOL -DB2 SQL code to have GROUP BY ... DB2 21
No new posts RFE: DB2 support for mixed case names. DB2 0
Search our Forums:

Back to Top