Convert from lower case to Upper case in COBOL.

All sort of Mainframes Interview Questions.
Post Reply
Ankit Gautam
New Member
Posts: 5
Joined: Tue Jul 29, 2014 12:29 pm

Convert from lower case to Upper case in COBOL.

Post by Ankit Gautam »

Hi,

Can we convert from lower case to Upper case in COBOL?

I was not sure and I said yes.

Then the interviewer said, well, then how do you code a COBOL program to do this?
  1. Without using any Functions?
  2. And with using built-in functions or Intrinsic functions?
I have searched on it but this question sounds tough. Can someone please share his experience on this.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Convert from lower case to Upper case in COBOL.

Post by William Collins »

To do it without a function, you can look at INSPECT ... CONVERTING ...
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Convert from lower case to Upper case in COBOL.

Post by Robert Sample »

I have searched on it but this question sounds tough
Where did you search? The Enterprise COBOL Language Reference manual provides a chapter with every intrinsic function and how to use it, so I wouldn't think it would be too tough to look up FUNCTION UPPER-CASE. The link to the various COBOL releases is http://www-01.ibm.com/support/docview.w ... wg27036733 so you can start learning.
Ankit Gautam
New Member
Posts: 5
Joined: Tue Jul 29, 2014 12:29 pm

Re: Convert from lower case to Upper case in COBOL.

Post by Ankit Gautam »

Thanks for the answers. I even find a link stating the use of FUCNTION UPPER-CASE in an interesting way:
UPPER-CASE & LOWER-CASE FUNCTIONS:

If you want to compare two fields and you are not sure of what case the fields contain, you can look at the upper case version of both fields or the lower case version of both fields so that you are comparing like configurations.

IF FUNCTION UPPER-CASE(FLD1) = FUNCTION UPPER-CASE(FLD2)
> PERFORM B-300-MATCH-ROUT.

IF FUNCTION LOWER-CASE(FLD1) = FUNCTION LOWER-CASE(FLD2)
PERFORM B-300-MATCH-ROUT.

If you are concerned that a user might enter data incorrectly at the screen, you can covert it using this function.

MOVE FUNCTION UPPER-CASE(STATE-IN) TO STATE-FOR-FILE.

LENGTH FUNCTION:

The length function gets the length of non-numeric fields so that you can find out the length of the field.

COMPUTE LEN1 = FUNCTION LENGTH(FLD-IN).
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Interview Questions.”