How to Re-order fields Using BUILD in DFSORT

There are two ideas on re-ordering the fields in the output file using DFSORT BUILD option.

Search for Hot Linux Jobs -Apply Today
Linux is Hot IT Skill now a days

Option -1

It is you need to write a COBOL sort program. You need to code the fields how you want and write into output file. Click here to know sample COBOL sort program.

Option-2

It is you need to use DFSORT commands in JCL.

Write the fields how you need in OUREC statement. The fields always appear in the order in which you specify them in the OUTREC.

Explanation: 

SORT FIELDS=(106,4,CH,A) ==> Just sort the file based on fields specified.
SUM FIELDS=(162,4,BI,166,4,BI) ==> Sum up two fields and add to second field
OUTREC FIELDS=(106,4,166,4,162,4) or

OUTREC BUILD=(106,4,166,4,162,4)  ==> Here, you can write fields as you wish. So, you can easily do re-ordering with DFSORT without writing complex COBOL program logic.

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.