Let us take an example and see, how we can delete fields with FILEDS or BUILD
The SORT, SUM and OUTREC statements are as follows:
SORT FIELDS=(106,4,CH,A) => It sorts records based on fields given SUM FIELDS=(162,4,BI,166,4,BI) ==> It sums the fields. and add it to second field
OUTREC FIELDS=(106,4,162,4,166,4) ==> Actual output recors
So, in the OUTREC statement after writing OUTREC give one space and write either FIELDS or BUILD
So, in the output record, You will get only selected fields. This way you are deleting all the un-wanted fields in your Output.
How Binary Data Handled by DFSORT Internally
Suppose you use this SORTOUT DD statement for your output data set:
//SORTOUT DD DSN=MY.OUTPUT,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(CYL,(5,5))
DFSORT automatically sets the LRECL of your new output data set (MY.OUTPUT) to the reformatted output record length, so LRECL=12 would be set in this case. You do not need to specify the LRECL on your SORTOUT DD statement, because DFSORT will set it appropriately for you.
If your SORTOUT data set already has an LRECL value (OLD data set), or you choose to specify an LRECL value on the SORTOUT DD statement, that value overrides the value DFSORT would set for the LRECL. This can result, intentionally or unintentionally, in padding or truncating your output records if the calculated length of the reformatted record does not match your specified LRECL.
In general, it is best to let DFSORT set the RECFM, LRECL and BLKSIZE for your NEW SORTOUT data sets, unless you have a particular reason to override these values. For OLD SORTOUT data sets, ensure that the existing RECFM, LRECL and BLKSIZE values are appropriate for the control statements you use.