TechTalk: Translating a File to Uppercase

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Translating a File to Uppercase

From: Mark Wheeler To: All

I need to translate the lowercase characters in a physical file to uppercase characters. I would prefer to do this within CL. I am conversant with the translation that occurs within the Copy To PC Document (CPYTOPCD) and Copy From PC Document (CPYFRMPCD) commands and I think that I could use these commands and the table QSYS/QSYSTRNTBL to accomplish my goal. Yet, I would prefer a CL command that would perform the translation without moving the data to a shared folder. Does one exist? REXX has a translate function; should I pursue it? Where does one look in the IBM documentation to have tables (object *TBL) explained? I don't want to write an RPG or COBOL program to do this if it can be avoided. Any thoughts?

From: Ernie Malaga To: Mark Wheeler

I'd stay away from REXX in this case. REXX doesn't recognize external file definitions-it treats the entire record as a single variable. If the record contains packed decimal or binary fields, there's the chance of having a combination of numbers look like a lowercase letter, which REXX would then dutifully convert to uppercase, producing all sorts of decimal data errors later.

For example, the lowercase letter 'a' is X'81', which can appear in a packed decimal field. Suppose you have a (5 0) decimal field which contains the number 2810. This number occupies 3 bytes: X'02', X'81' and X'0F'. The middle byte looks like an 'a', and thus would be converted to an uppercase 'A', which is X'C1'. Your decimal field would then contain 2C10, which is an invalid decimal number. The next time you read this file, you'd get a decimal data error.

I suspect the same thing could happen if you use CPYTOPCD and CPYFRMPCD, but I really don't know. Try it out on a test file before you make the switch.

I don't know how you can avoid using RPG or COBOL. CL can only read records- there's no write operation. If there were, you could use the Receive File (RCVF) command to read a record and then use a call to QDCXLATE to translate lowercase to uppercase (using translation table QSYSTRNTBL) on all alphanumeric fields, followed by a write operation. Since there is no write operation, this avenue is out.

I'd advise you to use RPG or COBOL. The right tool for the right job, as it's been pointed out time after time on this BBS. RPG, for example, has the XLATE op code; I'm sure there's something you can use in COBOL.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: