Sumup of the fields in sort

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
Cruise

Sumup of the fields in sort

Post by Cruise » Fri Apr 21, 2006 8:05 pm

hi,
please let me know...
in sort sumup will the truncatation will happen???

i have input file which contains 10 fields with 10 records.
i want the the output file with summed up the five amount fileds and control on five fields. when ever any change in the first five fields i wnat the sum for alll the similar records.
when it is summing up is there any truncation will happen in the oputput file or not.


bye,
Cruise.

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

Post by Frank Yaeger » Fri Apr 21, 2006 10:19 pm

Let me explain by example. When you use DFSORT statements like this:

Code: Select all

  SORT FIELDS=(6,3,CH,A)
  SUM FIELDS=(1,5,ZD)
for input records like this:

Code: Select all

12345AAA
35218AAA
71234AAA
the first two records will be summed, but since the third record would cause the sum to overflow (that is, be greater than the 5 digits allowed for it), you will get an overflow message and the third record will be kept as is. So your output will be:

Code: Select all

4756CAAA    
71234AAA    
You can use OVFLO=RC0, OVFLO=RC4 or OVFLO=RC16 to control what happens when you get an overflow. Overflow does not cause the values to be truncated, but it does cause values not to be summed.

You can avoid an overflow by using INREC to add zeros in front of the field to increase it's length.

If that doesn't answer your question, then please provide more details about what you want to know, preferably with examples.
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

Cruise

Sumup of the fields in sort

Post by Cruise » Mon Apr 24, 2006 6:01 pm

Hi Frank,
Thanks for the reply.

i have one more doubt.
let me explain my problem with example.

i have input file with
SSN X(9)
AMOUNT S9(9) COMP-3

i want output file with sumup of the amount for the same SSN. and i want the all the records sum in one file.
so please tell me how to give the sort card


INREC = ????
SORT FIELDS = (1,9,CH,A)
SUM FIELDS=(10,5,PD)

regards,

Cruise

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

Post by Frank Yaeger » Mon Apr 24, 2006 9:34 pm

Those are the correct control statements if your sum won't exceed 9 digits. If you're worried about your sum exceeding 9 digits, you can use these controls statements to add 2 extra digits of zeros at the start of the sum field to extend it from 5 bytes (max of 9 digits) to 6 bytes (max of 11 digits):

Code: Select all

   INREC FIELDS=(1,9,10:X'00',11:10,5)
   SORT FIELDS=(1,9,CH,A) 
   SUM FIELDS=(10,6,PD) 
If you need even more digits, extend the PD values with more X'00' bytes in front.
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

Cruise

Sumup of the fields in sort

Post by Cruise » Tue Apr 25, 2006 7:06 pm

Hi Frank,

Thank you very much..


Regards,
Cruise.

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 25, 2006 8:40 pm

Glad I could help.
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

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Jan 25, 2016 11:10 pm

<< Content deleted By Admin >>

Post Reply

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