Hi,
I have an input file which is as below:
Denis 100892 POS 320000 20-02-2009
Ralph 100893 POT 860000 22-02-2009
Denis 100892 POS 500000 20-02-2009
Ralph 100893 POT 880000 22-02-2009
Ralph 100893 POT 340000 22-02-2009
John 100895 POR 560000 23-02-2009
Denis 100892 POS 600000 20-02-2009
The ouput file should have a header record with sum of the 4th field and its detailed records below. The condition is that 1st, 2nd 3rd and 5th field should be same .
Since 'John'has only one record the output file should have 2 records saying its the header and also the detailed.
Desired output
Denis 100892 POS 1420000 20-02-2009 Header
Denis 100892 POS 600000 20-02-2009
Denis 100892 POS 500000 20-02-2009
Denis 100892 POS 320000 20-02-2009
John 100895 POR 560000 23-02-2009 Header
John 100895 POR 560000 23-02-2009
Ralph 100893 POT 2080000 22-02-2009 Header
Ralph 100893 POT 880000 22-02-2009
Ralph 100893 POT 860000 22-02-2009
Ralph 100893 POT 340000 22-02-2009
Please help me out!!
JCL: Sum .. its urgent!!
Moderators: Frank Yaeger, DikDude, Moderator Group
JCL: Sum .. its urgent!!
Many Thanks!!
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
You can use a DFSORT/ICETOOL job like the following to do what you asked for.
OUT would have:
Code: Select all
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
Denis 100892 POS 320000 20-02-2009
Ralph 100893 POT 860000 22-02-2009
Denis 100892 POS 500000 20-02-2009
Ralph 100893 POT 880000 22-02-2009
Ralph 100893 POT 340000 22-02-2009
John 100895 POR 560000 23-02-2009
Denis 100892 POS 600000 20-02-2009
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
INREC BUILD=(1,17,X,18,17,80:X)
SORT FIELDS=(1,5,CH,A,7,6,CH,A,14,3,CH,A,26,10,CH,A)
OUTFIL FNAMES=T1,REMOVECC,
SECTIONS=(1,5,7,6,14,3,26,10,
TRAILER3=(1,17,18:TOT=(18,7,UFF,EDIT=(IIIIIIT)),
25,11,X,'Header'))
/*
//CTL2CNTL DD *
OPTION EQUALS
SORT FIELDS=(1,5,CH,A,7,6,CH,A,14,3,CH,A,26,10,CH,A,
18,7,UFF,D,37,1,CH,D)
/*
Code: Select all
Denis 100892 POS 1420000 20-02-2009 Header
Denis 100892 POS 600000 20-02-2009
Denis 100892 POS 500000 20-02-2009
Denis 100892 POS 320000 20-02-2009
John 100895 POR 560000 23-02-2009 Header
John 100895 POR 560000 23-02-2009
Ralph 100893 POT 2080000 22-02-2009 Header
Ralph 100893 POT 880000 22-02-2009
Ralph 100893 POT 860000 22-02-2009
Ralph 100893 POT 340000 22-02-2009
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
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
Here's the DFSORT/ICETOOL job for a VB input file:
Code: Select all
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file (VB)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=... output file (VB)
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
INREC BUILD=(1,4,5,17,X,22,17,46:X)
SORT FIELDS=(5,5,CH,A,11,6,CH,A,18,3,CH,A,30,10,CH,A)
OUTFIL FNAMES=T1,REMOVECC,
SECTIONS=(5,5,11,6,18,3,30,10,
TRAILER3=(1:5,17,18:TOT=(22,7,UFF,EDIT=(IIIIIIT)),
29,11,X,'Header'))
/*
//CTL2CNTL DD *
OPTION EQUALS
SORT FIELDS=(5,5,CH,A,11,6,CH,A,18,3,CH,A,30,10,CH,A,
22,7,UFF,D,41,1,CH,D)
/*
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
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
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
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page