SORT JCL - SORTING A VB FILE - INREC OUTREC PARSE BUILD
Moderators: Frank Yaeger, Moderator Group
-
- Member
- Posts: 11
- Joined: Tue Jun 06, 2006 2:12 pm
SORT JCL - SORTING A VB FILE - INREC OUTREC PARSE BUILD
Hi,
I want to sort a VB formatted file and remove the duplicates after summing up the amount. For e.g.. I have a file having 4 fields in it. Lets say Emp#, Empname, Account, Salary. The records are like:
36,sar,rte,456
45,amb,,698
36,sar,rte,400
45,amb,rte,600
I want to sort the above file so that my O/P looks like :
36,sar,rte,856
45,amb,,698
45,amb,rte,600
So, basically I want to get a sum of the amount fileds of the records that has the same value for all other fields.
It is easy for FB file but since my VB file does not have the same length for all the records, I am not able to do it . Please help.
Thanks,
Ambili.
I want to sort a VB formatted file and remove the duplicates after summing up the amount. For e.g.. I have a file having 4 fields in it. Lets say Emp#, Empname, Account, Salary. The records are like:
36,sar,rte,456
45,amb,,698
36,sar,rte,400
45,amb,rte,600
I want to sort the above file so that my O/P looks like :
36,sar,rte,856
45,amb,,698
45,amb,rte,600
So, basically I want to get a sum of the amount fileds of the records that has the same value for all other fields.
It is easy for FB file but since my VB file does not have the same length for all the records, I am not able to do it . Please help.
Thanks,
Ambili.
Variable length files
Hi ambilileela,
My suggestion is to use cobol program to create FB file and then use SORT to get result.
we can sort VB file by giving starting position as actual starting pos + 4 in sort card.
Following Link may be useful to you
Smart DFSORT Tricks
http://www.ibm.com/servers/storage/supp ... vs/tricks/
Thanks,
Krishna
My suggestion is to use cobol program to create FB file and then use SORT to get result.
we can sort VB file by giving starting position as actual starting pos + 4 in sort card.
Following Link may be useful to you
Smart DFSORT Tricks
http://www.ibm.com/servers/storage/supp ... vs/tricks/
Thanks,
Krishna
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
Actually, this is a comma separated value (CSV) file. It has fields with variable positions. It might also be a VB file but I'm guessing it's really an FB file.
You can use the following DFSORT job to do what you asked for. However, you'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's PARSE and SQZ functions. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:
www.ibm.com/servers/storage/support/sof ... /mvs/peug/
If the input file is actually VB, let me know and I'll show you how to change the job to handle that.
You can use the following DFSORT job to do what you asked for. However, you'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's PARSE and SQZ functions. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:
www.ibm.com/servers/storage/support/sof ... /mvs/peug/
If the input file is actually VB, let me know and I'll show you how to change the job to handle that.
Code: Select all
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
36,sar,rte,456
45,amb,,698
36,sar,rte,400
45,amb,rte,600
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=5),
%02=(ENDBEFR=C',',FIXLEN=5),
%03=(ENDBEFR=C',',FIXLEN=5),
%04=(FIXLEN=5)),
BUILD=(1:%01,C',',
7:%02,C',',
13:%03,C',',
19:%04,UFF,TO=ZD,LENGTH=5)
SORT FIELDS=(1,5,CH,A,7,5,CH,A,13,5,CH,A)
SUM FIELDS=(19,5,ZD)
OUTREC OVERLAY=(19:19,5,ZD,TO=FS,LENGTH=5,
1:1,23,SQZ=(SHIFT=LEFT))
/*
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
-
- Member
- Posts: 11
- Joined: Tue Jun 06, 2006 2:12 pm
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
This version of the DFSORT job will work for a VB file. Remember that you need the April, 2006 DFSORT PTF. The job won't work without it.
Code: Select all
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB)
//SORTOUT DD DSN=... output file (VB)
//SYSIN DD *
INREC PARSE=(%01=(ABSPOS=5,ENDBEFR=C',',FIXLEN=5),
%02=(ENDBEFR=C',',FIXLEN=5),
%03=(ENDBEFR=C',',FIXLEN=5),
%04=(FIXLEN=5)),
BUILD=(1,4,
5:%01,C',',
11:%02,C',',
17:%03,C',',
23:%04,UFF,TO=ZD,LENGTH=5)
SORT FIELDS=(5,5,CH,A,11,5,CH,A,17,5,CH,A)
SUM FIELDS=(23,5,ZD)
OUTREC OVERLAY=(23:23,5,ZD,TO=FS,LENGTH=5,
5:5,23,SQZ=(SHIFT=LEFT))
OUTFIL VLTRIM=C' '
/*
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