Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Totalling the amount with certain condition through SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
maxsubrat

New User


Joined: 27 Feb 2008
Posts: 72
Location: india

PostPosted: Fri Mar 05, 2010 11:09 am    Post subject: Totalling the amount with certain condition through SORT
Reply with quote

Hi,
I want to SORT a file under some conditions:

I have some rows of records..
Records are 2 types .. one is header record and other is details record.

suppose i have 20 header records and 25 detail record.
for ex:
FIELD1 PIC X(1)
AMOUNT PIC S9(15) starts from 2nd position.

FIELD1 AMOUNT
H -100.00
D 200.00
H 50.00
D 10.00
D 05.00
so...on..

I want to total the AMOUNT field which has FIELD : H only..
Can someone tell me how to do that in SORT utility..
Thanks
SK
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Fri Mar 05, 2010 10:05 pm    Post subject: Reply to: Totalling the amount with certain condition throug
Reply with quote

maxsubrat,

Use the following DFSORT JCL

Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                     
H -100.00                                           
D 200.00                                             
H 50.00                                             
D 10.00                                             
D 05.00                                             
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                     
  SORT FIELDS=COPY                                   
  INCLUDE COND=(1,1,CH,EQ,C'H')                     
  OUTFIL REMOVECC,NODETAIL,                         
  TRAILER1=('TOTAL OF ALL H RECORDS: ',             
            TOT=(2,15,SFF,EDIT=(IIIIIIIIIIIIT.TT))) 
//*


the output from this job is

Code:

TOTAL OF ALL H RECORDS:            50.00
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us