Change Case in RPG – UPPER to lower using XLATE vs. SQL

  • Home
  • /
  • Blog
  • /
  • Change Case in RPG – UPPER to lower using XLATE vs. SQL

April 15, 2017

Changing SENTENCE CASE didnt used to be something that the grey haired AS400 and iSERIES programmers ever worried about. Back in the pre-internet days, most data entry was in UPPERCASE, plugged into giant green on black terminals by people wearing 1970’s flares and thick glass spectacles. But now it’s a new age of Internet connectivity, webservices and UPPER to lower using XLATE %BIF’s in modern RPG.

Why do we care about sentence CASE checking so much?

Simply put – in programmig terms the word “Muffin” is not the same as the work “muffin” which is also different to “MuFfiN”. You see? So, changing an input string (for example parameter sent in from a webservices request) to the same CASE as the database makes comparing  you range of exciting tasty “muffins” much easier.

Changing sentence case is easy with RPG

dcl-c lowerCase ('abcdefghijklmnopqrstuvwxyz');

dcl-s inputString varchar(200);
dcl-s outputString varchar(200);

 inputString = 'Convert from lowerCase to upperCase';
 outputString = %xlate(lowercase:uppercase:inputString);
 dsply outputString; 

 outputString = %xlate(uppercase:lowercase:inputString);
 dsply outputString; 

Changing sentence case is easier with SQL RPG

But it’s even easier with RPG and SQL because you dont even need the XLATE variables and this will let you catch all the special characters for that language:

dcl-s inputString varchar(200);
dcl-s outputString varchar(200);
CharField = 'hello db2 summit!';
EXEC SQL SET :outputString = UPPER(:inputString);

I will leave the syntax for the lower to your imagination 😉


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Start your
7-day free trial

Take This Course with ALL ACCESS

Unlock your Learning Potential with instant access to every course and all new courses as they are released.
 [ For Serious Software Developers only ]

IBM i Training For Technology Experts


Successfully Work Remote 

 $ 129.00  $59.00

By adding new skills in information technology, employers will be confident that you have the necessary skills and tools needed to successfully work remotely


Snug CBD

 20% Discount

I have partnered with SNUG CBD givING you Organic CBD
20% discount code "NL20"