Changing the Record Format of a File

Files can either have fixed- or variable-length record formats. You can change the record format of a file with the COPYFILE command and the RECFM option. For example, the following command would convert the file, DATA FILE A1, to fixed-length 130-character records:
copyfile data file a (recfm f lrecl 130
If you want to keep the original file intact, you can specify an output file ID, for example:
copyfile data file a fixdata file a (recfm f lrecl 130
The file, FIXDATA FILE A, contains the converted records.

If the records in a file being copied are variable-length, each output record is padded with blanks to the specified record length. If any records are longer than the record length, they are truncated.

When you convert files from fixed-length records to variable-length records, you can specify the COPYFILE command with TRUNC option to ensure that all trailing blanks are truncated:
copyfile data file a (recfm v trunc

If you specify the COPYFILE command with LRECL option and RECFM V, the LRECL option is ignored and the output record length is taken from the longest record in the input file.

When you convert a file from variable-length to fixed-length records, you may also specify a fill character to be used for padding instead of a blank. For example, suppose SHORT RECS is a variable-length file with its longest existing record being of length, L. If you wish to pad each record in SHORT RECS with asterisks to make each record in the file of length L, you would enter the following command:
copyfile short recs a (recfm f fill *
Note: If SHORT RECS was already a fixed-length file, it would not be altered.

Similarly, when you are converting back to variable-length, a file that was padded with a character other than a blank, you must specify the FILL option to indicate the pad character, so that character is truncated.