IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Selecting the Minimum Value


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kumarmf2004

New User


Joined: 25 Oct 2006
Posts: 4

PostPosted: Fri Dec 09, 2011 12:58 pm
Reply with quote

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
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Fri Dec 09, 2011 1:30 pm
Reply with quote

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:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Fri Dec 09, 2011 7:45 pm
Reply with quote

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:

Use [URL] BBCode for External Links


Surely
SORT FIELDS=(1,7,ZD,A,15,4,ZD,A,9,2,ZD,A,12,2,ZD,A)
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Dec 09, 2011 8:11 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Dec 09, 2011 9:56 pm
Reply with quote

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             
//*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Selecting the max value from a file. DFSORT/ICETOOL 3
No new posts Selecting multiple constant records DB2 3
No new posts ADRDSSU BY(REFDT... not selecting cor... IBM Tools 3
No new posts Selecting a row from multiple tables! DB2 2
This topic is locked: you cannot edit posts or make replies. Selecting two copybooks of different ... COBOL Programming 8
Search our Forums:

Back to Top