Finding smallest value for a field in a file

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
ickgeek23
Member
Posts: 17
Joined: Tue Sep 13, 2011 7:57 am

Finding smallest value for a field in a file

Post by ickgeek23 » Fri Sep 16, 2011 7:13 pm

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...
:)

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Sep 16, 2011 10:31 pm

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

ickgeek23
Member
Posts: 17
Joined: Tue Sep 13, 2011 7:57 am

Post by ickgeek23 » Tue Sep 20, 2011 6:49 pm

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

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Sep 20, 2011 9:54 pm

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

ickgeek23
Member
Posts: 17
Joined: Tue Sep 13, 2011 7:57 am

Post by ickgeek23 » Wed Sep 21, 2011 1:01 pm

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

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Wed Sep 21, 2011 1:50 pm

you need to check your SYNCSORT manuals, you are not using DFSORT.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

ickgeek23
Member
Posts: 17
Joined: Tue Sep 13, 2011 7:57 am

Post by ickgeek23 » Wed Sep 21, 2011 2:45 pm

I am using Syncsort

ickgeek23
Member
Posts: 17
Joined: Tue Sep 13, 2011 7:57 am

Post by ickgeek23 » Wed Sep 21, 2011 2:50 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

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Wed Sep 21, 2011 9:37 pm

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.
If your organization is licensed to use the product, all of the material is available free from Syncsort support.
Have a good one

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Wed Sep 21, 2011 10:21 pm

The job I gave you works fine with DFSORT. But you changed:

Code: Select all

    BUILD=(80X), 
to

Code: Select all

  BUILD=(3000X), 
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.
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

Post Reply

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



Other References
Mainframe Tools and others