|
|
| Author |
Message |
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 158 Location: Chennai
|
|
|
|
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 |
|
 |
References
|
Posted: Fri Mar 28, 2008 4:09 pm Post subject: Re: Lower Case to upper Case |
 |
|
|
 |
Gnanas SNG
Senior Member
Joined: 06 Sep 2007 Posts: 415 Location: India
|
|
|
|
What about this?
| Code: |
| FUNCTION UPPER-CASE--(--argument-1--) |
|
|
| Back to top |
|
 |
Bill O'Boyle
Active User
Joined: 14 Jan 2008 Posts: 293 Location: Orlando, FL, USA
|
|
|
|
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 |
|
 |
Devzee
Senior Member
Joined: 20 Jan 2007 Posts: 709 Location: Hollywood
|
|
|
|
| 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 |
|
 |
Richa Jain
New User
Joined: 18 Mar 2008 Posts: 33 Location: Chennai
|
|
|
|
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 |
|
 |
Bill O'Boyle
Active User
Joined: 14 Jan 2008 Posts: 293 Location: Orlando, FL, USA
|
|
|
|
| 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 |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 7920 Location: 221 B Baker St
|
|
|
|
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 |
|
 |
|
|