View previous topic :: View next topic
|
Author |
Message |
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 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 |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
What about this?
Code: |
FUNCTION UPPER-CASE--(--argument-1--) |
|
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, 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
Active Member
Joined: 20 Jan 2007 Posts: 684 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: 35 Location: Gurgaon
|
|
|
|
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
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, 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
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|