Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
kumarmf2004

New User

Joined: 25 Oct 2006
Posts: 4

 Posted: Fri Dec 09, 2011 12:58 pm    Post subject: Selecting the Minimum Value Hi, I have a query regarding selecting the minimum value using dfsort Assume Invoice and Date are continuous fields Input Invoice Date 1111111 12/10/2011 1111111 12/12/2011 2222222 12/10/2011 2222222 12/13/2011 Output should be like 111111 12/10/2011 222222 12/10/2011 Kumarmf

vasanthz

Global Moderator

Joined: 28 Aug 2007
Posts: 1647
Location: The Good Place

Posted: Fri Dec 09, 2011 1:30 pm    Post subject:

This might work,
 Code: //JS010    EXEC PGM=SORT                                        //SORTIN   DD DISP=SHR,DSN=WELLS.SORTIN                        //SORTOUT  DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS) //SYSOUT   DD SYSOUT=*                                          //SYSIN DD *                                                      SORT FIELDS=(1,7,ZD,A,15,4,ZD,A,9,2,ZD,A,13,2,ZD,A)            /*                                                              //JS020    EXEC PGM=SORT                                        //SORTIN   DD DSN=&&T1,DISP=OLD                                  //SORTOUT  DD DISP=OLD,DSN=WELLS.SORTOUT                      //SYSOUT   DD SYSOUT=*                                          //SYSIN DD *                                                      SORT FIELDS=(1,7,ZD,A)                                          SUM FIELDS=NONE                                                /*

Stolen sentence:
 Quote: If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from: www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
Garry Carroll

Senior Member

Joined: 08 May 2006
Posts: 1053
Location: Dublin, Ireland / Edinburgh, Scotland

Posted: Fri Dec 09, 2011 7:45 pm    Post subject:

vasanthz wrote:
This might work,
 Code: //JS010    EXEC PGM=SORT                                        //SORTIN   DD DISP=SHR,DSN=WELLS.SORTIN                        //SORTOUT  DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS) //SYSOUT   DD SYSOUT=*                                          //SYSIN DD *                                                      SORT FIELDS=(1,7,ZD,A,15,4,ZD,A,9,2,ZD,A,13,2,ZD,A)            /*                                                              //JS020    EXEC PGM=SORT                                        //SORTIN   DD DSN=&&T1,DISP=OLD                                  //SORTOUT  DD DISP=OLD,DSN=WELLS.SORTOUT                      //SYSOUT   DD SYSOUT=*                                          //SYSIN DD *                                                      SORT FIELDS=(1,7,ZD,A)                                          SUM FIELDS=NONE                                                /*

Stolen sentence:
 Quote: If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from: www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html

Surely
SORT FIELDS=(1,7,ZD,A,15,4,ZD,A,9,2,ZD,A,12,2,ZD,A)
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7312

 Posted: Fri Dec 09, 2011 8:11 pm    Post subject: Reply to: Selecting the Minimum Value It's a bit higgledy-piggledy, as one might say. Although the data is shown seperated by one blank, the description says we should assume they are continuous, so I imagine the blank is not really there. 1,7 14,4, 8,2 and 11,2 I'd "assume". Output shows only six digits for the invoice... The second sort would need EQUALS. There is no need for anything to be ZD, they can all be CH - not expecting any signs, so no need to sort on signs. Of course, the TS has abandoned us, so we'll not know for sure.
Skolusu

Senior Member

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

Posted: Fri Dec 09, 2011 9:56 pm    Post subject: Reply to: Selecting the Minimum Value

Kumarmf2004,

Use the following DFSORT/ICETOOL JCL which will give you the desired results in 1 pass . EQUALS is a default option with SELECT.

 Code: //STEP0100 EXEC PGM=ICETOOL                              //TOOLMSG  DD SYSOUT=*                                  //DFSMSG   DD SYSOUT=*                                  //IN       DD *                      ----+----1----+----2----+----3----+----4-                    1111111 12/12/2011                                      1111111 12/10/2011                                      2222222 12/13/2011                                      2222222 12/10/2011                                      //OUT      DD SYSOUT=*                                  //TOOLIN   DD *                                            SELECT FROM(IN) TO(OUT) ON(01,7,CH) FIRST USING(CTL1) //CTL1CNTL DD *                                            SORT FIELDS=(01,7,CH,A,    \$ INVOICE-NUMBER                                 15,4,CH,A,    \$ INVOICE-YEAR                             09,2,CH,A,    \$ INVOICE-MONTH                           12,2,CH,A)    \$ INVOICE-DAY              //*
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Selecting a row from multiple tables! Vignesh Sid DB2 2 Thu Oct 26, 2017 6:09 pm Selecting two copybooks of different ... Vignesh Sid COBOL Programming 8 Tue Sep 05, 2017 7:28 pm CA-Endevor Admin - 3 years minimum vasanthz Mainframe Jobs 0 Tue Apr 04, 2017 5:36 am DB2 10.1 Share level locking and Sele... Mary Lewis DB2 1 Wed Apr 15, 2015 9:51 pm Selecting a redefined record layout i... mallik4u Compuware & Other Tools 1 Wed Oct 08, 2014 8:14 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us