Reformatting Records Using OUTREC – Part 2

 

We will explore few more common uses of OUTREC with examples below

1 . Inserting Zeros, Spaces and Character strings to your output 

You can insert blanks before, between, or after fields. You can use X or 1X to specify a single blank. You can use nX to specify n blanks.To insert 10 blanks, write 10X before the first field. To insert 5 blanks, write 5X between the two fields.

   SORT FIELDS=(1,5,CH,A)
   OUTREC BUILD=(20X,1,5,10X,6,4)

This sort card will insert spaces in first 20 bytes , then the fields 1 to 5 from the input file is moved to 21 thru 25 , 26 thru 36 will have blanks and then input file fields from position 6 to 10 is moved to output file positions 37 to 41

 

Inserting Zeros is similar to space but in place on X use Z .You can use Z or 1Z to specify a single binary zero. You can use nZ to specify n binary zeros.

   SORT FIELDS=(1,5,CH,A)
   OUTREC BUILD=(1,5,4Z,6,4)

This sort card will insert 4 binary zeroes between the first and second fields of your output file.

 

To insert a character string to your output include C ‘ your string   as part of your OUTREC , you can include any EBCDIC character between single quotes. To include a single apostrophe in the string, you must specify it as two single apostrophes example, to includes then word “Tom’s” you need to specify  C’Tom”s’

 SORT FIELDS=(1,5,CH,A)
 OUTREC BUILD=(C'Run Date:',1,10,C'|',C'Run Time:',11,4)

If you input file record is ‘2015/04/0415:30′ the output will be “Run Date:2015/04/04|Run Time:13:30″ .

 

2 .Translating uppercase to lowercase & EBCDIC to ASCII

To perform case conversion you can include the TRAN keyword in your OUTREC, to convert  from upper case to lower case use TRAN=UTOL (Upper to Lower) and for Lower case to upper use TRAN=LTOU (Lower to Upper) .

Input 

KAREN 166353

JOHN    433324

TOM      666534

OUTREC FIELDS=(1,1,2,4,TRAN=UTOL)

Output

Karen  166353

John    433324

Tom     666534

Notice that here we have mentioned the Upper to Lower case conversion for only positions 2 to 5 and the 1st byes is copied as such.

 Other TRAN options available

  • TRAN=ETOA translates EBCDIC characters  to the equivalent ASCII characters.
  • TRAN=ATOE translates ASCII characters to the equivalent EBCDIC characters.
  • TRAN=HEX translates binary values in a field to their equivalent EBCDIC
  • TRAN=BIT translates binary values in a field to their equivalent EBCDIC
 More in part 3..

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Mainframe Wiki © 2015 Frontier Theme