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

Sorting the file base on the date range


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Select-mf

New User


Joined: 11 May 2007
Posts: 42
Location: bangalore

PostPosted: Sat Mar 14, 2009 3:21 am
Reply with quote

Hi,

My requirement is to sort file based on the date range, I am using Syncsort in my shop. The date is defined as yyyymmdd in my input file.

I want in my output file, only the records with the date range falling between 19980801 to 20041231.

How can I achieve this using Syncsort in JCL?

Thanks.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sat Mar 14, 2009 4:15 am
Reply with quote

Hello,

Use INCLUDE for values between the lo/hi values. Or with OMIT to exclude. Either will work unless i misunderstand something.

The sort doesn't need to know they are dates, just that you want to work with values between those given.
Back to top
View user's profile Send private message
Select-mf

New User


Joined: 11 May 2007
Posts: 42
Location: bangalore

PostPosted: Sun Mar 15, 2009 10:11 am
Reply with quote

Hi,

Ok...so you mean to say date is just like any other field. But I do not know how to give the range in sort card using include/omit.

Can anybody please give me an example, so that I can try on my system?

Thanks.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sun Mar 15, 2009 10:43 am
Reply with quote

Hello,

Quote:
so you mean to say date is just like any other field
In your posted example, yes it is just like anyother field.

This would be a good time to become more familiar with the forum SEARCH (which searches only topics within the forum).

There are several examples of include or omit in the forum.

If you are actually going to sort the file, you will need to include the actual sort control statements.

To process the records you want (records between 19980801 and 20041231) you would use something like:
Code:
(s,8,CH,GT,C'19980800',AND,s,8,CH,LT,C'20041232')
Note that i've used non-dates to set the ends of the range. This will not matter as the process is merely looking at values not actual dates.
Back to top
View user's profile Send private message
Select-mf

New User


Joined: 11 May 2007
Posts: 42
Location: bangalore

PostPosted: Mon Mar 16, 2009 8:40 am
Reply with quote

Hi,

I tried the below sort card in my JCL but I got an error in spool as below -

Code:
SYSIN :                                                       
   SORT FIELDS=COPY                                           
   INCLUDE COND=(113,8,CH,GT,19980801,AND,113,8,CH,LT,99999999)
                             *                                 
WER253A  INCLUDE/OMIT FORMATS INCOMPATIBLE
"Code"d
The date field starts at 113th position in my input file.

Thanks.
Back to top
View user's profile Send private message
Select-mf

New User


Joined: 11 May 2007
Posts: 42
Location: bangalore

PostPosted: Mon Mar 16, 2009 8:43 am
Reply with quote

Hi,

The error (*) is showing just below the date(19980801) in spool, while pasting it on the above reply it vent below Include.

Thanks.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Mon Mar 16, 2009 8:53 am
Reply with quote

Hi,

see Dick's example again, the date should be like this when using CH,

Code:
C'19980800'



Gerry
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Mar 16, 2009 9:18 am
Reply with quote

Hello,

As Gerry mentions, character fields need quotes.

Also, please note that your sort control has been "Code"d for readability. Also note that using the "Code" tag preserves alignment. Use the Preview to see your post the way it will appear to the forum and when you are satisfied, Submit.
Back to top
View user's profile Send private message
Select-mf

New User


Joined: 11 May 2007
Posts: 42
Location: bangalore

PostPosted: Mon Mar 16, 2009 11:39 am
Reply with quote

Hi,

Thanks, its working. I will put the code tag going forward.

Thanks again to both of you.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Mar 16, 2009 11:54 am
Reply with quote

You're welcome - thanks for letting us know it is working icon_smile.gif

d
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Binary File format getting change whi... All Other Mainframe Topics 5
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top