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
 

 

Extracts records matching with todays date using sort

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

Active User


Joined: 18 Jun 2007
Posts: 210
Location: Cochin/Kerala/India

PostPosted: Tue Jan 29, 2008 6:30 pm    Post subject: Extracts records matching with todays date using sort
Reply with quote

My file has dates in the format mm/dd/yyyy, and I want to extract the records with dates matching with the current date. How we can do this using sort?

Bipin Peter
Back to top
View user's profile Send private message

krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Tue Jan 29, 2008 7:00 pm    Post subject:
Reply with quote

Look at the topic "Only include records with today's date " in Smart DFSORT Tricks at
http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 210
Location: Cochin/Kerala/India

PostPosted: Tue Jan 29, 2008 7:06 pm    Post subject:
Reply with quote

i checked that but it dont have the format of mm/dd/yyyy
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Jan 29, 2008 10:01 pm    Post subject: Reply to: Extracts records matching with todays date using s
Reply with quote

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICEMAN                             
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                       
01/29/2008                                             
01/30/2008                                             
01/31/2008                                             
02/01/2008                                             
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                       
  SORT FIELDS=COPY                                     
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:DATE1(/))),     
         IFTHEN=(WHEN=INIT,OVERLAY=(91:86,5,85,1,81,4))
  OUTFIL INCLUDE=(01,10,CH,EQ,91,10,CH),               
  BUILD=(01,80)                                       
//*                                                   
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 193
Location: india

PostPosted: Wed Jan 30, 2008 9:12 am    Post subject: Reply to: Extracts records matching with todays date using s
Reply with quote

Hi,
You can also try out with the below mentioned JCL

Code:
//VZM1CKKN JOB (3GAHF3,R),                                   
//         'RAJAT TEST',CLASS=X,MSGCLASS=Y,NOTIFY=&SYSUID   
//S1    EXEC  PGM=ICETOOL                                   
//TOOLMSG DD SYSOUT=*                                       
//DFSMSG  DD SYSOUT=*                                       
//T1      DD DSN=&&TEMP1,                                   
//           DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA   
//CON     DD *                                               
01/29/2008                                                   
01/30/2008                                                   
01/31/2008                                                   
02/01/2008                                                   
/*                                                           
//OUT  DD SYSOUT=*                                           
//TOOLIN DD *                                               
   COPY FROM(CON) TO(T1) USING(CTL1)                         
   COPY FROM(T1) TO(OUT) USING(CTL2)                         
/*                                                           
//CTL1CNTL DD *                       
  OPTION COPY                         
  OUTREC FIELDS=(7,4,5:C'/',1,2,3,3) 
/*                                   
//CTL2CNTL DD *                       
  OPTION COPY                         
  INCLUDE COND=(1,10,CH,EQ,DATE1(/)) 
/*                                   
 
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 193
Location: india

PostPosted: Wed Jan 30, 2008 9:15 am    Post subject:
Reply with quote

But i think the JCL posted by Skolusu is more effective. icon_smile.gif
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 210
Location: Cochin/Kerala/India

PostPosted: Wed Jan 30, 2008 10:14 am    Post subject:
Reply with quote

Thanx Skolusu,it's working fine
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Jan 30, 2008 10:04 pm    Post subject:
Reply with quote

Here's a really cool way to do it with DFSORT using System Symbols:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD *
* Create symbol for 'mm/dd/yyyy'
Cur_Date,S'&MON./&DAY./&YR4'
/*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INCLUDE COND=(1,10,CH,EQ,Cur_Date)
/*
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 193
Location: india

PostPosted: Thu Jan 31, 2008 7:41 am    Post subject: Reply to: Extracts records matching with todays date using s
Reply with quote

hello Frank,

I tried the above JCL posted by you and i am getting the following error

ICE270I 0 PROCESSING SYMNAMES STATEMENTS
DATE,S'&MON./&DAY./&YR4'
$
ICE276A 0 RESERVED WORD - NOT ALLOWED FOR SYMBOL
ICE279A 0 ONE OR MORE ERRORS ENCOUNTERED DURING SYMNAMES PROCESSING
ICE052I 3 END OF DFSORT
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jan 31, 2008 9:55 pm    Post subject:
Reply with quote

You used DATE in uppercase which is a reserved word. I used Date in mixed case which is NOT a reserved word. If you want to use an uppercase symbol name, use something like CUR_DATE instead of DATE.
I changed my example to avoid confusion.
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 193
Location: india

PostPosted: Fri Feb 01, 2008 10:42 am    Post subject:
Reply with quote

i am using the follwing JCl

Code:
//S1    EXEC  PGM=ICEMAN               
//SYSOUT    DD  SYSOUT=*               
//SYMNAMES DD *                         
CUR_DATE,S'&MON./&DAY./&YR4'           
/*                                     
//SORTIN   DD *                         
07/17/2006                             
05/01/2009                             
03/03/2007                             
12/26/2005                             
/*                                     
//SORTOUT  DD SYSOUT=*                 
//SYSIN    DD    *                     
  OPTION COPY                           
  INCLUDE COND=(1,10,CH,EQ,CUR_DATE)   
/*                                     


And I am getting the following Error:

Code:
PROCESSING SYMNAMES STATEMENTS                           
 CUR_DATE,S'&MON./&DAY./&YR4'                             
          $                                               
SYMBOL, VALUE OR SYNTAX IS INVALID                       
ONE OR MORE ERRORS ENCOUNTERED DURING SYMNAMES PROCESSING
END OF DFSORT     



Please let me know where I am wrong
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 193
Location: india

PostPosted: Fri Feb 01, 2008 11:42 am    Post subject:
Reply with quote

I even tried using
Code:
Cur_Date,C'&MON./&DAY./&YR4'


instead of using
Code:
Cur_Date,S'&MON./&DAY./&YR4'


and changed input date to todays date in mm/dd/yyyy format. In this case the JOB was not abending but I was not getting the output i.e. todays date.
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 193
Location: india

PostPosted: Fri Feb 01, 2008 11:46 am    Post subject:
Reply with quote

And also please let me know how we are getting the current date in this case. i mean how the value of current date will be mapped to CUR_DATE
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Feb 01, 2008 10:22 pm    Post subject:
Reply with quote

You need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 in order to use DFSORT's S constants in SYMNAMES. The error message indicates you don't have that PTF which has been available since April, 2006. Ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/

Quote:
And also please let me know how we are getting the current date in this case. i mean how the value of current date will be mapped to CUR_DATE


Cur_Date,S'&MON./&DAY./&YR4'

S'string' allows you to use system constants to construct a DFSORT symbol constant.
&MON is the system symbol for the 2-digit month (e.g. 02 for February).
&DAY is the system symbol for the 2-digit day (e.g. 01 today).
&YR4 is the system symbol for the 4-digit year (2008).
the dot means concatenation.

So the resulting constant is mm concatenated with / concatenated with dd concatenated with / concatenated with yyyy = mm/dd/yyyy
Back to top
View user's profile Send private message
rajatbagga

Active User


Joined: 11 Mar 2007
Posts: 193
Location: india

PostPosted: Sat Feb 02, 2008 11:03 am    Post subject: Reply to: Extracts records matching with todays date using s
Reply with quote

Thank you very much for the information frank.
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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
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 Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am


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