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

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

Sorting - SORT INREC OUTREC SUM FIELDS

Post by Suganya » Mon Mar 31, 2008 11:12 am

Hi,

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

Code: Select all

//SYSIN DD *                                     
   SORT FIELDS=(1,3,CH,A)                        
   INREC FIELDS=(1,3,2Z,4,3)                     
   SUM FIELDS=(4,5,ZD)                           
   OUTREC FIELDS=(1:1,3,4:4,5,ZD,EDIT=(II,IIT))  
/*

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

Post by Frank Yaeger » Tue Apr 01, 2008 12:35 am

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

Post by Remya » Tue May 27, 2008 9:33 am

hi ,

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

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

Post by Frank Yaeger » Tue May 27, 2008 8:06 pm

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

Locked

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