We can use INSPECT or UPPERCASE or LOWERCASE COBOL function to convert the case of alphanumeric, alphabetic, or national strings. Translation features of INREC, OUTREC and OUTFIL make it easy to change the case of characters in your fields.
INSPECT verb in COBOL is very useful and it is used to do the following functionalities
01 WS-CHAR-CASE. 05 WS-UPPER-CASE PIC X(26) VALUE "ABCD … Z" 05 WS-LOWER-CASE PIC X(26) VALUE ' abcd… z' INSPECT WR-IN-STRNG CONVERTING WW-LOWER-CASE to WS-UPPER-CASE
MOVE FUNCTION UPPER-CASE(STATE-IN) TO STATE-FOR-FILE.
MOVE FUNCTION LOWER-CASE(STATE-IN) TO STATE-FOR-FILE.
The UPPER() function accepts a string and returns a new string in which all characters in the original string are converted to uppercase.
UPPER(expression)
Expression must evaluate to a character string or a value that can be implicitly converted to a character string.
UPPER() function is useful for case-insensitive searches.
SELECT UPPER('This is Test') FROM sysibm.sysdummy1; RESULT - THIS IS TEST
Now let’s do this conversion using SORT JCL. Translation features of INREC, OUTREC and OUTFIL make it easy to change the case of characters in your fields.
The TRAN=LTOU operand can be used to change lower-case EBCDIC letters (a-z) to upper-case EBCDIC letters (A-Z) anywhere in a field. The TRAN=UTOL operand can be used to change upper-case EBCDIC letters to lower-case EBCDIC letters anywhere in a field.
Here’s how you could change lowercase letters to uppercase letters in a 50-byte character field starting at position 25 and in a 20-byte character field starting in position 200, in an FB data set with an LRECL of 500:
OUTREC OVERLAY=(25:25,50,TRAN=LTOU,250:250,20,TRAN=LTOU)
You can convert the case in the entire record. For example, here’s how you could change uppercase to lowercase in the records of an FB data set with an LRECL of 200:
OUTREC BUILD=(1,200,TRAN=UTOL)
And here’s how you could change uppercase to lowercase in the records of a VB data set with any LRECL:
OUTREC BUILD=(1,4,5,TRAN=UTOL)
Example
FIRST NAME LAST NAMEWILLIAM BAYLESS
RAUL CAUDILLO
JOKHI DINSHAW
ROBERT MURRAY
LORI RASMUSSEN
If you wanted to display these names with an initial uppercase letter and subsequent lower case letters, you could use the following OUTREC statement:
OUTREC FIELDS=(91,1,92,14,TRAN=UTOL,X,76,1,77,14,TRAN=UTOL)
ResultWilliam Bayless
Raul Caudillo
Jokhi Dinshaw
Robert Murray
Lori Rasmussen
A well-maintained product backlog is crucial for successful product development. It serves as a single…
Incremental value to the customer refers to the gradual delivery of small, functional parts of…
A Product Market refers to the group of potential customers who might be interested in…
The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…
The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…
Choosing the right Scrum Master Certification depends on your current experience and career goals. If…