Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to extract the records within date range

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
satyapn9

New User


Joined: 08 Oct 2010
Posts: 27
Location: India

PostPosted: Thu Feb 24, 2011 11:06 am    Post subject: How to extract the records within date range
Reply with quote

Can you please let me know how to extract the records within date range like (02/28/2011 to 12/01/2014).

Thanks,
Satya Prasad Nimmakayala.
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Feb 24, 2011 8:34 pm    Post subject:
Reply with quote

Hello,

You need to review some other similar topics and provide the necessary information. . .

Show a bit of sample input and the output you want from that input. Mentoin the recfm and lrecl of the files. Show the data potisions within the records you want to use for selecting data. If there are any rules (other than the date selection) post these.
Back to top
View user's profile Send private message
satyapn9

New User


Joined: 08 Oct 2010
Posts: 27
Location: India

PostPosted: Fri Feb 25, 2011 9:18 am    Post subject: Re: How to extract the records within date range
Reply with quote

Hi Scherrer,

Thank you for the update.

I have coded one sort card with INCLUDE and OMIT conditions and worked but; it was a bit lengthy;
So I wanted to know if we have any SORT Utility Function that could sort the file within the date ranges. It would be easier if we have a function like this to sort based on dates.

In my file -->each record contains the date values like "02/28/2011" from the position 20 to 29 ( with slashes).
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Feb 25, 2011 9:42 am    Post subject:
Reply with quote

Hello,

Quote:
I have coded one sort card with INCLUDE and OMIT conditions and worked but; it was a bit lengthy;
As you have not posted your "sort card", no one can offer any kind of improvement suggestion. . .

The most important part of getting help here is providing proper nformation. If you are unwilling/unable to do this, you will find your topics drag on and on - eventually being locked if they completely stall.

Quote:
It would be easier if we have a function like this to sort based on dates.
Suggest you submit a product enhancement request.
Back to top
View user's profile Send private message
satyapn9

New User


Joined: 08 Oct 2010
Posts: 27
Location: India

PostPosted: Fri Feb 25, 2011 6:50 pm    Post subject: Re: How to extract the records within date range
Reply with quote

Hi Dick Scherrer,

Sorry for not posting exact information you have asked me to post.

Below is the Sort job I've written and worked for the date range ( 02/28/2011 to 12/31/2011). But actually i want a generic function that could sort the given date range.

***************************************
Code:

//SORTIN   DD DISP=SHR,                                 
//            DSN=FITPRO.DZZ3850.CERTFUTR.G4811V00     
//SORTOUT  DD DSN=TEST.TST.DZZ3850.CERTFUTR.G4811.NEW, 
//            UNIT=(DISK,22),SPACE=(CYL,(200,200),RLSE),
//            DISP=(NEW,CATLG,DELETE)                 
//SYSIN   DD *                                         
          SORT FIELDS=(20,10,CH,A)                     
          INCLUDE COND=((1,03,CH,EQ,C'HMO'),AND,       
                        (20,02,CH,GE,C'02'),AND,       
                        (26,04,CH,GE,C'2011'),AND,     
                        (26,04,CH,LT,C'2012'))         
/*                                                     
//*                                                     
//STEP11   EXEC PGM=SORT                                                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD DISP=SHR,                                 
//            DSN=TEST.TST.DZZ3850.CERTFUTR.G4811.NEW   
//SORTOUT  DD DSN=TEST.TST.DZZ3850.CERTFUTR.G4811,     
//            UNIT=(DISK,22),SPACE=(CYL,(200,200),RLSE),
//            DISP=(NEW,CATLG,DELETE)                   
//SYSIN   DD *                                         
          SORT FIELDS=(20,10,CH,A)                     
          OMIT COND=((20,02,CH,EQ,C'02'),AND,           
                     (23,02,CH,LT,C'28'))               
/*                                                     
//*

************************************


In the above I have written two steps; one for INCLUDE and one for OMIT.

Is there any otherway that would simplify the code?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Feb 25, 2011 10:44 pm    Post subject:
Reply with quote

satyapn9,

Sorting a date in (mm/dd/ccyy) format as a character string is not going sort them date wise ascending. You need to sort on CCYY first followed by MM followed by DD.

Assuming your input lrecl is 80 and recfm=fb, the following DFSORT control cards will give you the desired results. We first overlay the date in CCYYMMDD format at the end of the every record and sort on that field. Using an include cond on OUTFIL we eliminate the unwanted records by checking the date in CCYYMMDD format.

Code:

//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=* 
//SORTIN   DD *     
----+----1----+----2----+----3----+----4             
PICK               02/28/2011     
DROP               02/27/2011     
DROP               12/02/2014     
PICK               12/01/2014                           
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                         
  INREC OVERLAY=(81:26,4,20,2,23,2)                     
  SORT FIELDS=(81,8,CH,A)                               
                                                       
  OUTFIL BUILD=(1,80),                                 
  INCLUDE=(81,8,ZD,GE,20110228,AND,81,8,ZD,LE,20141201)
//*
Back to top
View user's profile Send private message
satyapn9

New User


Joined: 08 Oct 2010
Posts: 27
Location: India

PostPosted: Mon Mar 21, 2011 3:36 pm    Post subject: How to extract the records within date range
Reply with quote

Hi Kolusu,

Thank you so much for your help. Ofcourse it is a delayed response from me.
It worked well and you are wonderful in giving the explanation.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us