Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Lower Case to upper Case

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 83
Location: trichy

PostPosted: Fri Mar 28, 2008 4:09 pm    Post subject: Lower Case to upper Case
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
References
PostPosted: Fri Mar 28, 2008 4:09 pm    Post subject: Re: Lower Case to upper Case Reply with quote

Gnanas SNG

Senior Member


Joined: 06 Sep 2007
Posts: 414
Location: India

PostPosted: Fri Mar 28, 2008 4:23 pm    Post subject:
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

Active User


Joined: 14 Jan 2008
Posts: 211
Location: Orlando, FL, USA

PostPosted: Sat Mar 29, 2008 2:47 am    Post subject: Lower Case to upper Case
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

Senior Member


Joined: 20 Jan 2007
Posts: 714
Location: Hollywood

PostPosted: Sat Mar 29, 2008 6:02 am    Post subject:
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: 27
Location: Chennai

PostPosted: Sat Mar 29, 2008 12:26 pm    Post subject:
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

Active User


Joined: 14 Jan 2008
Posts: 211
Location: Orlando, FL, USA

PostPosted: Sat Mar 29, 2008 4:20 pm    Post subject:
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

Global Moderator


Joined: 23 Nov 2006
Posts: 6756
Location: 221 B Baker St

PostPosted: Sat Mar 29, 2008 7:31 pm    Post subject:
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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1