Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
Hi There.
You can change the layout of a record both before and after it is sorted using the INREC and OUTREC keywords. You simply specify the fields to be included in the new record.
INREC reformats the record layout before it is passed through the sort, while OUTREC will reformat the record layout after the record has been sorted.
Here's some examples:
SORT FIELDS=(1,10,CH,A)
INREC=(1,10,CH,50,4,PD,40,4,PD)
SORT FIELDS=(1,10,CH,A)
OUTREC=(1,10,50,4,40,4)
Both examples will reformat the record so that it consists of the first 10 bytes of the input record, followed by the 4 bytes starting at position 50, followed by the 4 bytes starting at position 40.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Code:
OUTREC FIELDS=(1:25,10)
This OUTREC statement writes output records with input positions 25-34 in output positions 1-10.
Quote:
means there is no difference betn inrec and out rec.
inrec for before pass it to sort and outrec for after sort..
INREC and OUTREC can both reformat records in the same way and are often interchangeable. However, if you need SORT to see the reformatted records, you would use INREC. For example:
Here we're adding a sequence number to each record so we can sort on it. INREC works for this because it add the sequence numbers before the records are sorted. OUTREC would not work for this because it would add the sequence numbers after the records are sorted.
Quote:
Here's some examples:
SORT FIELDS=(1,10,CH,A)
INREC=(1,10,CH,50,4,PD,40,4,PD)
SORT FIELDS=(1,10,CH,A)
OUTREC=(1,10,50,4,40,4)
Both examples will reformat the record so that it consists of the first 10 bytes of the input record, followed by the 4 bytes starting at position 50, followed by the 4 bytes starting at position 40.
Lots of errors here. INREC= and OUTREC= are invalid. It should be:
Code:
INREC FIELDS=(...)
and
OUTREC FIELDS=(...)
The CH in the first INREC statement is invalid. It should be 1,10,50,... rather than 1,10,CH,50,... CH is not allowed (or needed).
The explanation for what the OUTREC statement does is correct. But the INREC statement works differently because of the PD fields. 50,4,PD indicates input positions 50-53 has a PD field to be converted using the M0 edit mask. Likewise, 40,4,PD indicates input positions 40-43 has a PD field to be converted using the M0 edit mask. The results of the INREC statement and the OUTREC statement would be very different.