## Sorting - SORT INREC OUTREC SUM FIELDS

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Suganya
Member
Posts: 1
Joined: Fri Mar 28, 2008 2:34 pm
Location: Chennai

### Sorting - SORT INREC OUTREC SUM FIELDS

Hi,

Can you help me in understanding what the following sort card does ?

Code: Select all

``````//SYSIN DD *
SORT FIELDS=&#40;1,3,CH,A&#41;
INREC FIELDS=&#40;1,3,2Z,4,3&#41;
SUM FIELDS=&#40;4,5,ZD&#41;
OUTREC FIELDS=&#40;1&#58;1,3,4&#58;4,5,ZD,EDIT=&#40;II,IIT&#41;&#41;
/*
``````

Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:
It avoids a SUM overflow by reformatting the 3-byte ZD field in positions 4-6 into a 5-byte ZD field in positions 4-8. The INREC statement adds 2 binary zeros before the 3-byte ZD field to make it a 5-byte ZD field. It probably should be adding two character zeros (C'00' = X'F0F0') since it's a ZD field, but X'0000' will work since the zone is ignored. (Perhaps whoever created the job thought 2Z meant 2 ZD zeros instead of 2 binary zeros.)

More specifically:

INREC - Creates a record with the following fields:

1-3 - input positions 1-3
4-5 - binary zeros (X'0000')
6-8 - input positions 4-6

SORT - sorts on positions 1-3

SUM - for records which have the same value in positions 1-3, keeps one of the records and sums the values in positions 4-8 (e.g. X'0000F1F2F3).

OUTREC - Creates an output record with the following fields:

1-3 - input positions 1-3
4-9 - the ZD total in positions 4-8 edited to a displayable value of dd,ddd with leading zeros suppressed, e.g.

Code: Select all

``````12,345
3,456
789
``````
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Remya
Member
Posts: 2
Joined: Fri May 23, 2008 10:35 am
hi ,

i need to sort an input file. the sorted file should not contain the first two fields of the input file.

Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:
Remya,

Please start a new topic for this new question and provide more information. Show an example of the records in the input file (relevant fields only) and what you expect for the output records. Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input file. Give the starting position, length and format of each relevant field.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

# FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
• JCL Tutorial
Covers all important JCL concepts.
• Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3.
• DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming.
• SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples
• CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions

Other References
Mainframe Tools and others