In RPGIV, is there a test for uppercase values?

I am attempting to determine how much of an issue we have with a certain file and the data that is in the file.  Specifically, I need to determine how many RECORDS in the file have FIELDS that meet the criteria of having all their alpha data in uppercase.  For example, if your name is Jack P. SMITH you would NOT be counted, but if your name was JACK P. SMITH you WOULD be counted.  I want to ignore spaces and non alpha characters, simply testing all characters for uppercase and if they are, then tally that record.
Any thoughts?  
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MurpheyApplication ConsultantCommented:
The deference between a Upper and a lower case character is Bit 1  (That's the second bit from the left)
All uppercase characters is this bit set to 1  and for lower case this value is 0, So you can do a TESTB operation, but the problem is that numbers 0-9 have also the uppercast bit set (and also some other characters like {,}, and \ .
So the second option is to use the Xlate opcode.

Translate everything within a variable to uppercase and compare it with the original field, if they are the same, the original field contains uppercase only.

D up              C                   'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
D lo              C                   'abcdefghijklmnopqrstuvwxyz'
   UpperField = %XLATE(lo:up:MyField);

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wendelinaAuthor Commented:
That is a good idea.  In the interim, I already set up a program (in very little time!) that I took the field in question and did a SCAN operation 26 times setting 26 different indicators and testing each one to see if the field contained ANY lowercase characters - if not then it must be all uppercase.  But, your solution is probably more efficient.  
thank you!!
Minor variation on Murph's solution -- if the SQL Dev Kit is available. The SQL UPPER() function can be handy.


     Drc               S              4
     C/exec sql set :rc  = case when UPPER(:pTstVar)=:pTstVar
     c+                         then '*AOK'
     c+                         else '*NOK'
     c+                         end

Open in new window

MurpheyApplication ConsultantCommented:

a variation on Tom's idea, just use SQL to count your result like:

            select count(NAME) from CUSTOMER where NAME = binary upper(NAME)

This will return the number of names that is the same in upper as in stored format.
If you mean that by "determine how many RECORDS in the file have FIELDS that meet the criteria of having all their alpha data in uppercase"

(No AS/400 at home so tested on MySQL but I think this will work, otherwise I will put the right syntax here first thing in the morning)

Murph -- Yeah, I might've presented the fuller SQL solution but you'd already given the correct RPG one. And the question _was_ asked for RPG.

If SQL is used all the way through, the system catalog could be queried for tables and those tables could be queried for CHARACTER columns and those columns could be queried for UPPER()...

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Operating Systems

From novice to tech pro — start learning today.