DFSORT OUTREC Data Translation

DFSORT OUTREC: Inserting data DFSORT OUTREC: Data Conversion

Advertisements


OUTREC statement used to translate from one type to another type like uppercase to lowercase, EBCDIC to ASCII, and more.


Syntax:

OUTREC FIELDS=(starting position of field1, length of field1,TRAN=Option….. )

Let’s discuss in detail.


nameDescription
Starting position of field1Specifies field1starting position in the input file after sorting.
Length of feild1 Field1 physical length in input file.
TRAN=OptionSpecifies the translation type.

TRAN=UTOL translates uppercase letter (A-Z) in the field to the equivalentlowercase letter (a-z).

TRAN=LTOU translates lowercase letters (a-z) in a field to the equivalentuppercase letters (A-Z).

TRAN=ETOA translates EBCDIC characters in a field to the equivalent ASCIIcharacters.

TRAN=ATOE translates ASCII characters in a field to the equivalent EBCDICcharacters.

TRAN=ALTSEQ translates characters in a field to other characters as specifiedby an ALTSEQ statement.

TRAN=HEX translates binary values in a field to their equivalent EBCDIChexadecimal values ('0'-'F').

2 output characters are produced for each input byte.

TRAN=BIT translates binary values in a field to their equivalent EBCDIC bitvalues ('0' or '1').

8 output characters are produced for each input byte.

TRAN=UNHEX translates EBCDIC hexadecimal values ('0'-'F') in a field to theirequivalent binary values.

An output byte is produced for each 2 inputcharacters.

TRAN=UNBIT translates EBCDIC bit values ('0' or '1') in a field to theirequivalent binary values.

An output byte is produced for each 8 inputcharacters.


Example:

Convert all lower case characters to upper case from the input file.


Input File: MTHUSER.SORT.INPUT01 - FB file of 80 length

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
00001     student1           dept1          560                                 
00003     student3           dept2          520                                 
00004     student4           dept1          540                                 
00005     student5           dept2          500                                 
00002     student2           dept3          510                                 
******************************** Bottom of Data ********************************

Input Record Layout:

01 INPUT-REC.
  	05 STD-ID		PIC X(05).
	05 FILLER		PIC X(05).
	05 STD-NAME		PIC X(15).
	05 FILLER		PIC X(05).
	05 STD-DEPT	 	PIC X(10).
	05 FILLER		PIC X(05).
	05 STD-MARKS		PIC 9(03).    
	05 FILLER		PIC X(32).

Job:

000100 //Jobcard 
000400 //*                                                                     
000400 //**********************************************************************
000400 //*                                                                     
000400 //* SORT FOR OUTREC STATEMENT                                           
000400 //*                                                                     
000400 //**********************************************************************
000400 //STEP01   EXEC PGM=SORT                                                
000400 //SORTIN   DD DSN=MTHUSER.SORT.INPUT01,DISP=SHR                    
000400 //SORTOUT  DD SYSOUT=*                                                  
000400 //SYSOUT   DD SYSOUT=*                                                  
000400 //SYSIN    DD *                                                         
000400      SORT FIELDS=(1,5,CH,A)                                             
000400      OUTREC FIELDS=(1,10,11,22,TRAN=LTOU,33,40)                         
000400 /*                                                                      
000400 **************************** Bottom of Data ****************************

Output:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* TOP OF DATA **********************************
00001     STUDENT1           DEPT1          560                                 
00002     STUDENT2           DEPT3          510                                 
00003     STUDENT3           DEPT2          520                                 
00004     STUDENT4           DEPT1          540                                 
00005     STUDENT5           DEPT2          500                                 
******************************** BOTTOM OF DATA ********************************

Explaining Solution:

  1. OUTREC FIELDS=(1,10,..) copies 10 bytes from byte 1 from input file to output file as it is.
  2. OUTREC FIELDS=(..,11,22,TRAN=LTOU,..), LTOU applies from 11th byte to 22nd byte and all the lower case letters in between will convert to upper case.
  3. OUTREC FIELDS=(..,33,47) copies from 33rd to 80th byte will be copied from input file to output file as it is.

DFSORT OUTREC: Inserting data DFSORT OUTREC: Data Conversion

Advertisements