IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DFSORT - Find the sum for the group


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pravinj

New User


Joined: 10 Jun 2008
Posts: 24
Location: india

PostPosted: Tue Feb 07, 2012 11:12 pm
Reply with quote

Hello... I have a requirement and I am seeing if we can do that through DFSORT option. I tried using SORT but wasn't able to arrive at the output.

Requirement is as follows,
Input file:

Code:
XXXX  02
YYYYY 01
ZZZZ 06
XXXX 01
ZZZZ 02


Expected output:
Code:
XXXX 02 03
YYYY 01 01
ZZZZ 06 08
XXXX 01 03
ZZZZ 02 08


Here from the requirement, you could see that the sum of a group is being listed at the end of each record. For XXXX, there are 2 records summing up to 03. The o/p to be written as XXXX 02 03 and XXXX 01 03.

Can you please let me know if it's possible and if so, share some samples or the code for the requirement.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Feb 07, 2012 11:31 pm
Reply with quote

pravinj,

Use the following DFSORT JCL which will give you the desired results. I assumed that your input is FB and LRECL=80

Code:

//STEP0100 EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                       
//INA      DD *                               
XXXX 02                                       
YYYY 01                                       
ZZZZ 06                                       
XXXX 01                                       
ZZZZ 02                                       
//INB      DD *                               
XXXX 02                                       
YYYY 01                                       
ZZZZ 06                                       
XXXX 01                                       
ZZZZ 02                                       
//SORTOUT  DD SYSOUT=*                       
//SYSIN    DD *                               
  JOINKEYS F1=INA,FIELDS=(1,4,A)             
  JOINKEYS F2=INB,FIELDS=(1,4,A)             
  JOIN UNPAIRED                               
  REFORMAT FIELDS=(F1:1,8,F2:6,2,F1:11,78)   
  SORT FIELDS=(81,8,CH,A)                     
  OUTREC BUILD=(1,80)                         
//*                                           
//JNF1CNTL DD *                               
  INREC OVERLAY=(81:SEQNUM,8,ZD)             
//*                                           
//JNF2CNTL DD *                               
  SUM FIELDS=(6,2,ZD)                         
//*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
Search our Forums:

Back to Top