|
View previous topic :: View next topic
|
| Author |
Message |
pshongal
New User
Joined: 14 Jun 2012 Posts: 98 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
pshongal
New User
Joined: 14 Jun 2012 Posts: 98 Location: India
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Can you paste the sysout of what you are running now, please? In the Code tags. |
|
| Back to top |
|
 |
pshongal
New User
Joined: 14 Jun 2012 Posts: 98 Location: India
|
|
|
|
| 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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
@ 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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| 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 |
|
 |
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
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.  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|