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
 

 

Date Comparison in SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
pshongal

New User


Joined: 14 Jun 2012
Posts: 70
Location: India

PostPosted: Tue Aug 19, 2014 1:21 pm    Post subject: Date Comparison in SORT
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Aug 19, 2014 1:42 pm    Post subject: Reply to: Date Comparison in SORT
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: 70
Location: India

PostPosted: Tue Aug 19, 2014 1:52 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Aug 19, 2014 2:38 pm    Post subject: Reply to: Date Comparison in SORT
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: 70
Location: India

PostPosted: Tue Aug 19, 2014 3:25 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Aug 19, 2014 4:17 pm    Post subject: Reply to: Date Comparison in SORT
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Wed Aug 20, 2014 1:52 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Aug 20, 2014 2:54 pm    Post subject: Reply to: Date Comparison in SORT
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Wed Aug 20, 2014 3:26 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Aug 20, 2014 3:44 pm    Post subject: Reply to: Date Comparison in SORT
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: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Wed Aug 20, 2014 4:44 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts CICS NEW SIT PARAMETERS CICS BEHAVIOR... Kyle Carroll CICS 0 Fri Nov 04, 2016 11:55 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm


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