MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Condition based totals on trailer record

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
APLOSDC
Beginner


Joined: 04 May 2006
Posts: 4
Topics: 2

PostPosted: Sun Aug 12, 2007 6:49 am    Post subject: Condition based totals on trailer record Reply with quote

Hi,

I have an input file whose format is:

Tx Date (8 bytes) - all the records will have the same date
Tx Code (1 byte) - the possible values can be 'C' or 'D'
Tx Amount (14 byte ZD filed with no decimals)

I want a summary record created from the above file which should contain:

Tx Date (from input file)
Total number of records in the input file
Sum of all tx amounts of records with tx code 'C'
Sum of all tx amounts of records with tx code 'D'

Can the above be accomplished in a single step?

Many Thanks.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sun Aug 12, 2007 10:49 am    Post subject: Reply with quote

Here's a DFSORT job that will do what you asked for. You didn't show what you wanted the output record to look like so I took a guess. You can edit the fields of the output record as appropriate.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
08122007C00000000020001
08122007D00000000030001
08122007C00000000025002
08122007D00000000045002
08122007D00000000152349
08122007D00000000005218
08122007C00000000102349
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=80,
   IFTHEN=(WHEN=(9,1,CH,EQ,C'C'),OVERLAY=(24:14C'0')),
   IFTHEN=(WHEN=(9,1,CH,EQ,C'D'),OVERLAY=(24:10,14,10:14C'0'))
  OUTFIL REMOVECC,NODETAIL,
    TRAILER1=(1,8,                      DATE
       COUNT=(M11,LENGTH=10),           COUNT
       TOT=(10,14,ZD,M11,LENGTH=14),    TOTAL OF C AMOUNTS
       TOT=(24,14,ZD,M11,LENGTH=14))    TOTAL OF D AMOUNTS
/*


SORTOUT would have:

Code:

0812200700000000070000000014735200000000232570 

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
APLOSDC
Beginner


Joined: 04 May 2006
Posts: 4
Topics: 2

PostPosted: Mon Aug 13, 2007 2:21 am    Post subject: Reply with quote

Frank,

Many thanks for this. I did the requisite formatting and it worked. A very ingenious application of overlay.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group