In DFSORT you can convert letters in a field from lowercase to uppercase or uppercase to lowercase using the TRAN= parameter: TRAN=LTOU (lower to upper) and TRAN=UTOL (upper to lower). You specify the field by position and length in INREC or OUTREC FIELDS=. Only the letters a–z and A–Z are affected; digits, spaces, and other characters stay the same. Using INREC means the sort and INCLUDE/OMIT see the converted value; using OUTREC means only the final output has the new case. This page explains LTOU and UTOL in detail, when to use each, and how to apply them to specific fields or the whole record.
LTOU converts each lowercase letter (a–z) in the specified field to its uppercase equivalent (A–Z). Any character that is not a lowercase letter is left unchanged. So "smith" becomes "SMITH", "O'Brien" becomes "O&BRIEN", and "Room 101" becomes "ROOM 101". This is useful when you need a consistent uppercase key for sorting (so that "Smith" and "smith" sort together) or when the downstream system or report expects uppercase (e.g. mainframe reports that traditionally use uppercase).
1OUTREC FIELDS=(1,20,TRAN=LTOU,21,60)
This converts the first 20 bytes to uppercase and copies bytes 21–80 unchanged. If the first 20 bytes contained "John Smith", the output would have "JOHN SMITH".
UTOL converts each uppercase letter (A–Z) to its lowercase equivalent (a–z). All other characters are unchanged. So "SMITH" becomes "smith", and "ID: AB12" becomes "id: ab12". Use UTOL when the receiving system expects lowercase—for example, many Unix or Windows applications, or when building email addresses or web content. On the mainframe, data is often stored in uppercase; converting to lowercase in OUTREC before sending a file off the platform is a common use.
1OUTREC FIELDS=(1,40,TRAN=UTOL,41,40)
The first 40 bytes are converted to lowercase; bytes 41–80 are copied as-is. So a record that had "CUSTOMER NAME" in the first 13 bytes would have "customer name" in the output.
LTOU and UTOL are letter-only conversions. The following are unchanged:
So you can safely apply LTOU or UTOL to fields that contain mixed content (names, addresses, IDs with letters and numbers) without corrupting the non-letter characters. If you need to change specific non-letter characters (e.g. replace one character with another), use FINDREP or a custom ALTSEQ table instead.
If you sort by a name or key field that has mixed case, the sort order depends on the collating sequence: uppercase and lowercase may not sort together. To get a consistent order, convert the field to one case in INREC and then sort on that converted field. The sort then sees only uppercase (or only lowercase), so "Smith", "SMITH", and "smith" all sort as the same key.
12INREC FIELDS=(1,4,5,30,TRAN=LTOU,35,46) SORT FIELDS=(5,30,CH,A)
Here the 26-byte field at 5–30 is uppercased in INREC. The SORT FIELDS= then sorts by that 30-byte field in ascending character order. Every record's name is in uppercase when the sort runs, so the order is consistent. The same idea applies to INCLUDE/OMIT: if you want to keep only records where the name equals "SMITH", uppercasing in INREC lets you compare against C'SMITH' and match regardless of how the name was stored.
When the sort order and filtering are correct with the original data and you only want the written file to have a different case, use OUTREC. For example, you sort by a numeric ID and only need the name field in lowercase in the output for a Unix application. The sort key is the ID; the name is just part of the output layout. In that case, OUTREC FIELDS=(..., name_start, name_len, TRAN=UTOL, ...) is enough.
You can uppercase one field and lowercase another in the same INREC or OUTREC. List each field with its own (start, length, TRAN=...).
1OUTREC FIELDS=(1,8,9,30,TRAN=LTOU,39,20,TRAN=UTOL,59,22)
Bytes 1–8 are copied, 9–38 are uppercased, 39–58 are lowercased, 59–80 are copied. So you might have an ID, an uppercase name, a lowercase description, and more data—all in one pass.
Imagine you have a line of letters. Some are big (uppercase) and some are small (lowercase). "Lower to upper" means we make every small letter big: a→A, b→B, and so on. "Upper to lower" means we make every big letter small: A→a, B→b. Numbers and spaces we don't touch. So "abc 123" with lower-to-upper becomes "ABC 123". We can do this to the whole line or just part of it. If we do it before the sort (INREC), the sort sees the new letters; if we do it only when writing the file (OUTREC), the sort still saw the old letters.
1. What does TRAN=LTOU do in DFSORT?
2. What does TRAN=UTOL do?
3. Do LTOU and UTOL affect digits and spaces?
4. When should you use INREC vs OUTREC for LTOU/UTOL?
5. Can you convert one field to uppercase and another to lowercase in the same step?