Thursday, July 29, 2010

Tip 5: Sort ALTSEQ code

ALTSEQ code is very useful to change a particular value to another value in a file using a sort card. This is most frequently used to convert low-values to spaces.

For example, if you just want to convert low-values to spaces without sorting on any field, sort card to be given is as below:

SORT FIELDS=COPY
ALTSEQ CODE=(0040)
OUTREC FIELDS=(1,100,TRAN=ALTSEQ)

Here all X'00' values in the file are replaced by X'40' hence ALTSEQ CODE=(0040)
and the file length is can be 100 or we want to OUTREC only the first 100 fields.

In case we need to convert nulls to spaces only for a particular field, suppose the first ten bytes and the file is of length 100 then we can use the below:

SORT FIELDS=COPY
ALTSEQ CODE=(0040)
OUTREC FIELDS=(1:1,10,TRAN=ALTSEQ,11:11,90)

We can also sort on any fields if needed.

No comments:

Post a Comment