OUTREC Data Translation


The OUTREC statement can perform data translation, which involves converting characters from one character set to another. This is commonly used for translating characters like converting uppercase to lowercase, EBCDIC to ASCII, and more.

Syntax -

//SYSIN DD *
  OUTREC FIELDS=(starting_pos_of_field1,
	    field1_length,
		TRAN=option,…)
/*
starting_pos_of_field1Specifies the starting byte of the numeric field in the record.
field1_lengthSpecifies the length of the numeric field.
TRAN=OptionSpecifies the translation type.
The available options are -
  • TRAN=UTOL translates uppercase letter (A-Z) in the field to the equivalent lowercase letter (a-z).
  • TRAN=LTOU translates lowercase letters (a-z) in a field to the equivalent uppercase letters (A-Z).
  • TRAN=ETOA translates EBCDIC characters in a field to the equivalent ASCII characters.
  • TRAN=ATOE translates ASCII characters in a field to the equivalent EBCDIC characters.
  • TRAN=ALTSEQ translates characters in a field to other characters as specified by an ALTSEQ statement.
  • TRAN=HEX translates binary values in a field to their equivalent EBCDIC hexadecimal values ('0'-'F'). 2 output characters are produced for each input byte.
  • TRAN=BIT translates binary values in a field to their equivalent EBCDIC bit values ('0' or '1'). 8 output characters are produced for each input byte.
  • TRAN=UNHEX translates EBCDIC hexadecimal values ('0'-'F') in a field to their equivalent binary values. An output byte is produced for each 2 input characters.
  • TRAN=UNBIT translates EBCDIC bit values ('0' or '1') in a field to their equivalent binary values. An output byte is produced for each 8 input characters.

Examples -


Scenario1 - Translating Lowercase to Uppercase.

//SYSIN   DD  *
  SORT FIELDS=COPY
  OUTREC FIELDS=(1,20,TRAN=LTOU)
/*

Translates the first 20 characters of each record from lowercase letters are translated to uppercase.

Scenario2 - Translating Uppercase to Lowercase.

//SYSIN   DD  *
  SORT FIELDS=COPY
  OUTREC FIELDS=(1,20,TRAN=UTOL)
/*

Translates the first 20 characters of each record from uppercase letters are translated to lowercase.