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

Date Comparison in SORT


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Tue Aug 19, 2014 1:21 pm
Reply with quote

Hi,

I have a file as below.

Code:
XXXXXXXXXX08/18/2014
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX08/18/2014


I want to pick only those records where date in position 11 is 1 day prior to today's date (19th Aug 2014).

My sysin card is as below.

Code:
INREC FIELDS=(01:01,10,
                         11:17,4,
                         12:C'-',
                         13:11,2,
                         15:C'-' ,
                         16:14,2)
INCLUDE COND=(11,10,CH,LT,&DATE1(-)-1)
OUTREC FIELDS=(1:1,20)


This is selecting all the records from I/P. Where am I doing wrong?

Thanks in advance.

Code'd
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: Tue Aug 19, 2014 1:42 pm
Reply with quote

Not the problem but...

You can code INREC and INCLUDE/OMIT COND in any order you like. It does not matter. SORT is going to execute them in the order it wants, which is always INCLUDE/OMIT COND first, then INREC.

Why LT if you want equal to?
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Tue Aug 19, 2014 1:52 pm
Reply with quote

Thanks Bill,

Yes that was a mistake, I corrected it and now I am getting ZERO records in the O/P.

So Bill, it means I have to do it in two seperate steps?
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: Tue Aug 19, 2014 2:38 pm
Reply with quote

Can you paste the sysout of what you are running now, please? In the Code tags.
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Tue Aug 19, 2014 3:25 pm
Reply with quote

Code:

SYSIN :
SORT FIELDS=COPY
INREC FIELDS=(01:01,50,
51:57,4,
55:C'-',
56:51,2,
58:C'-',
59:54,2,
61:61,27,
88:88,254)
INCLUDE COND=(51,10,CH,EQ,&DATE1(-)-1)
OUTREC FIELDS=(1:1,341)
WER276B SYSDIAG= 1322303, 8023953, 8023953, 10501125
WER164B 8,864K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,
WER164B 0 BYTES RESERVE REQUESTED, 2,256K BYTES USED
WER146B 32K BYTES OF EMERGENCY SPACE ALLOCATED
WER108I SORTIN : RECFM=FB ; LRECL= 341; BLKSIZE= 27962
WER257I INREC RECORD LENGTH = 341
WER237I OUTREC RECORD LENGTH = 341
WER110I SORTOUT : RECFM=FB ; LRECL= 341; BLKSIZE= 27962
WER410B 7,836K BYTES OF VIRTUAL STORAGE AVAILABLE ABOVE THE 16MEG LINE,
WER410B 0 BYTES RESERVE REQUESTED, 2,112K BYTES USED
WER055I INSERT 0, DELETE 100
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
WER416B SORTIN : EXCP'S=1,UNIT=3390,DEV=B3CA,CHP=(1838587898B8D8F8,2),VOL=MI
WER416B SORTOUT : EXCP'S=0,UNIT=3390,DEV=B1B0,CHP=(1838587898B8D8F8,2),VOL=MI
WER416B TOTAL OF 1 EXCP'S ISSUED FOR COPYING
WER054I RCD IN 100, OUT 0
WER169I RELEASE 1.3 BATCH 0506 TPF LEVEL 2.1
WER052I END SYNCSORT - IUUSDW12,JS002,PS030,DIAG=AC00,73C6,8000,004C,E4FE,48CB
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: Tue Aug 19, 2014 4:17 pm
Reply with quote

INCLUDE/OMIT COND operates before INREC. Did the implications of that sink in?

You need to consult your SyncSORT (as it turns out) documentation to see if you can get a date format in INCLUDE/OMIT COND which matches your data format.

If not, I'd suggest a simple small step to set up the date in the format you need, as a SORT symbol, using SYMNAMES and then use that symbol by name in your INCLUDE COND=.

Read the piece about FIELDS. Don't use FIELDS on INREC, OUTREC or OUTREC on OUTFIL.

You don't need the OUTREC anyway. The "FIELDS" on your INREC (which is not needed because it does not do what you think/want) would be better OVERLAY just for the data you want changed (and don't you want to change it back afterwards?).
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Wed Aug 20, 2014 1:52 pm
Reply with quote

@ pshongal: I'm not sure what version of Syncsort you have. See if this works for you:

Code:
//STEP01   EXEC PGM=SORT                               
//SORTIN   DD *                                       
XXXXXXXXXX08/19/2014                                   
XXXXXXXXXX                                             
XXXXXXXXXX                                             
XXXXXXXXXX08/19/2014                                   
//SORTOUT  DD SYSOUT=*                                 
//SYSOUT   DD SYSOUT=*                                 
//SYSIN    DD *                                       
   OPTION  COPY                                       
   INREC   IFTHEN=(WHEN=INIT,OVERLAY=(21:DATE(MD4/)-1))
   OUTFIL  INCLUDE=(11,10,CH,EQ,21,10,CH),BUILD=(1,20)

Output
Code:
****** ***************************** Top of Data *
000001 XXXXXXXXXX08/19/2014                       
000002 XXXXXXXXXX08/19/2014                       
****** **************************** Bottom of Data
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: Wed Aug 20, 2014 2:54 pm
Reply with quote

Yes, it'll work. However, every record is processed (due to need of OUTFIL INCLUDE=) and every record is extended to include a constant value. The more records on the file, the more noticeable the effects of this. To go this route I'd try to INCLUDE COND= at least something (like the YYYY value).

If not directly available in that format for INCLUDE COND=, set up a sort symbol on SYMNAMES. Generate in one small step, use (along with SYMNOUNT) in the second step, on the INCLUDE COND=.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Wed Aug 20, 2014 3:26 pm
Reply with quote

Hi Bill,
Yes. I tried directly using the date function in INCLUDE COND as below, but it was giving syntax error:
Code:
INCLUDE COND=(11,10,CH,EQ,DATE(MD4/)-1)

That's why I switched to the other method.

Quote:
set up a sort symbol on SYMNAMES. Generate in one small step, use (along with SYMNOUNT) in the second step, on the INCLUDE COND=.

Is this what you are suggesting:
Code:
//STEP01   EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DUMMY,DCB=(RECFM=F,LRECL=80)               
//SORTOUT  DD DSN=HLQ.MLQ.SYMNAMES,DISP=SHR               
//SYSIN    DD *                                           
  OPTION COPY                                             
  OUTFIL REMOVECC,                                       
         HEADER1=(C'MYDATE,''',9:DATE(MD4/)-1,C'''',80:X)
/*                                                       
//STEP02   EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SYMNAMES DD DSN=HLQ.MLQ.SYMNAMES,DISP=SHR               
//SORTIN   DD *                                           
XXXXXXXXXX08/19/2014                                     
XXXXXXXXXX                                               
XXXXXXXXXX                                               
XXXXXXXXXX08/19/2014                                     
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                           
  OPTION   COPY                                           
  INCLUDE  COND=(11,10,CH,EQ,MYDATE)                     
/*                                                       
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: Wed Aug 20, 2014 3:44 pm
Reply with quote

Yep, like that. I'd just include the SYMNOUT DD in the second step as well, but not vital where there is only one symbol (the value it has can readily be worked out from the converted control cards - the SYMNOUT makes it explicit).
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Wed Aug 20, 2014 4:44 pm
Reply with quote

Thanks Bill. I have not much experience of using symbols. Mostly because at my site, if a SORT is doing more than 'sorting' they make me write a program for it. icon_smile.gif
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top