Finding smallest value for a field in a file
Moderators: Frank Yaeger, Moderator Group
Finding smallest value for a field in a file
Hi,
I have two input files
Input file1 like:
course name-------start date----- end date
course1-------------20110101----20111212
course2-------------20110501----20110512
course3-------------20091109----20111212
course4-------------20110508----20110815
Input file2:
student-----------------------date
student1--------------------20110101
student2--------------------20040101
student3--------------------20091109
student4--------------------20100101
student5--------------------20030101
My requirement is first i need to find the smallest value of the start date from the input file1 (in this case 20091109), then i need to select the records from input file2 which has the date greater than or equal to the smallest values found from the input file1-start date, and write in to the output file
So output file :
student1--------------------20110101
student3--------------------20091109
student4--------------------20100101
Can we do this without writing any cobol program...
Thanks in advance...
I have two input files
Input file1 like:
course name-------start date----- end date
course1-------------20110101----20111212
course2-------------20110501----20110512
course3-------------20091109----20111212
course4-------------20110508----20110815
Input file2:
student-----------------------date
student1--------------------20110101
student2--------------------20040101
student3--------------------20091109
student4--------------------20100101
student5--------------------20030101
My requirement is first i need to find the smallest value of the start date from the input file1 (in this case 20091109), then i need to select the records from input file2 which has the date greater than or equal to the smallest values found from the input file1-start date, and write in to the output file
So output file :
student1--------------------20110101
student3--------------------20091109
student4--------------------20100101
Can we do this without writing any cobol program...
Thanks in advance...
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
You can use a DFSORT job like the following to do what you asked for:
Code: Select all
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
COURSE1-------------20110101----20111212
COURSE2-------------20110501----20110512
COURSE3-------------20091109----20111212
COURSE4-------------20110508----20110815
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
BUILD=(80X),
TRAILER1=('TARG,''',MIN=(21,8,ZD,TO=ZD,LENGTH=8),'''')
/*
//S2 EXEC PGM=SORT
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SYSOUT DD SYSOUT=*
//SORTIN DD *
STUDENT1--------------------20110101
STUDENT2--------------------20040101
STUDENT3--------------------20091109
STUDENT4--------------------20100101
STUDENT5--------------------20030101
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INCLUDE COND=(29,8,CH,GE,TARG)
/*
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
Thanks Frank for the reply
My inputfile2 format has changed
like
Input file2:
student-----------------------date
student1--------------------2011-01-01
student2--------------------2004-01-01
student3--------------------2009-11-09
student4--------------------2010-01-01
student5--------------------2003-01-01
Inputfile1 is same
output is same as mentioned in the previous post.
Can you please help me in this how to solve
My inputfile2 format has changed
like
Input file2:
student-----------------------date
student1--------------------2011-01-01
student2--------------------2004-01-01
student3--------------------2009-11-09
student4--------------------2010-01-01
student5--------------------2003-01-01
Inputfile1 is same
output is same as mentioned in the previous post.
Can you please help me in this how to solve
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
That's a simple change to the previous DFSORT job (you'll learn more if you try to figure these things out yourself):
Code: Select all
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
COURSE1-------------20110101----20111212
COURSE2-------------20110501----20110512
COURSE3-------------20091109----20111212
COURSE4-------------20110508----20110815
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
BUILD=(80X),
TRAILER1=('TARG,''',MIN=(21,8,ZD,EDIT=(TTTT-TT-TT)),'''')
/*
//S2 EXEC PGM=SORT
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SYSOUT DD SYSOUT=*
//SORTIN DD *
STUDENT1--------------------2011-01-01
STUDENT2--------------------2004-01-01
STUDENT3--------------------2009-11-09
STUDENT4--------------------2010-01-01
STUDENT5--------------------2003-01-01
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INCLUDE COND=(29,8,CH,GE,TARG)
/*
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
Thanks Frank for the quick response:
When i ran the job it is giving an error as
SYSIN :
OPTION COPY
INCLUDE COND=(61,8,CH,GE,TARG)
*
WER268A INCLUDE STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
date filed in the inputfile2 is PIC X(10)
date field in input file1 (start date is) PIC X(8)
I am new to this programming language, can you please help me from where i can get these material so that it will be very helpful.
Thanks
When i ran the job it is giving an error as
SYSIN :
OPTION COPY
INCLUDE COND=(61,8,CH,GE,TARG)
*
WER268A INCLUDE STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
date filed in the inputfile2 is PIC X(10)
date field in input file1 (start date is) PIC X(8)
I am new to this programming language, can you please help me from where i can get these material so that it will be very helpful.
Thanks
- dbzTHEdinosauer
- Moderator
- Posts: 981
- Joined: Mon Oct 02, 2006 8:31 pm
After executing the first step
with
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
BUILD=(3000X),
TRAILER1=('TARG,''',MIN=(22,8,ZD,EDIT=(TTTT-TT-TT)),'''')
output file has the minimum date as
TARG,'2002-01-26'
when i use the sort in the next step
OPTION COPY
INCLUDE COND=(61,10,CH,GE,TARG)
Then i am getting the error as
SYSIN :
OPTION COPY
INCLUDE COND=(61,10,CH,GE,TARG)
*
WER268A INCLUDE STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
Thanks
with
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
BUILD=(3000X),
TRAILER1=('TARG,''',MIN=(22,8,ZD,EDIT=(TTTT-TT-TT)),'''')
output file has the minimum date as
TARG,'2002-01-26'
when i use the sort in the next step
OPTION COPY
INCLUDE COND=(61,10,CH,GE,TARG)
Then i am getting the error as
SYSIN :
OPTION COPY
INCLUDE COND=(61,10,CH,GE,TARG)
*
WER268A INCLUDE STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
Thanks
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
The job I gave you works fine with DFSORT. But you changed:
to
which is incorrect. I don't know if fixing that will allow your job to run with Syncsort, but it is certainly necessary. You might want to check your complete job against my complete job to see if you messed up anything else.
At any rate, I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
Code: Select all
BUILD=(80X),
Code: Select all
BUILD=(3000X),
At any rate, I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
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