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
 

 

SYNCSORT JCL based on date comarison in a single i/p.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri Jul 04, 2008 8:19 pm    Post subject: SYNCSORT JCL based on date comarison in a single i/p.
Reply with quote

Hi,

I am trying to right a SORT JCL for the below inputs & outputs but in vain

Sample input-1:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
1051270965 482 ODYJUL03U1    7/3/2008
1051270965 482 ODYJUL03U2    7/3/2008
1051270965 482 ODYJUL03U5    7/3/2008
1051270965 482 ODYJUL04U6    7/4/2008


Sample output-1:
Code:
1051270965 482 ODYJUL04U6    7/4/2008


Sample input-2:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
1051270965 482 ODYJUL03U1    7/3/2008
1051270965 482 ODYJUL03U2    7/3/2008
1051270965 482 ODYJUL03U5    7/3/2008
1051270965 482 ODYJUL04U6    7/4/2008
1051270965 482 ODYJUL04U6    7/4/2008


Sample output-2:
Code:
1051270965 482 ODYJUL04U6    7/4/2008
1051270965 482 ODYJUL04U6    7/4/2008


Rules:
- Selection of output is based on the date field, present in column 30 onwards.
- I need to select the records which are of "latest date", these dates come in the records itself.
- This latest date is not system date and not available by any other means (just present in inputs).

P.S.: Dates are of the form (MM/DD/CCYY)
Back to top
View user's profile Send private message

sid_aec

New User


Joined: 01 Jul 2008
Posts: 60
Location: Kolkata

PostPosted: Fri Jul 04, 2008 8:38 pm    Post subject:
Reply with quote

Can you explain about ur problem in bit more detail...Do you want a sort card which will pick up the records of latest dates every time or you have the luxury to change the sortcards everytime to sortout the records of your desired dates.

SiddharthaB
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 182
Location: hyderabad

PostPosted: Sat Jul 05, 2008 12:32 am    Post subject:
Reply with quote

Anuj D,
Please check the below code.

Code:

//PS020    EXEC PGM=SYNCTOOL                                           
//SYSOUT   DD  SYSOUT=*                                               
//TOOLMSG  DD  SYSOUT=*                                               
//DFSMSG   DD  SYSOUT=*                                               
//IN1      DD *                                                       
1051270965 482 ODYJUL03U1    7/3/2008                                 
1051270965 482 ODYJUL03U2    7/3/2008                                 
1051270965 482 ODYJUL03U5    7/3/2008                                 
1051270965 482 ODYJUL04U6    7/4/2008                                 
1051270965 482 ODYJUL04U6    7/4/2008                                 
//OUT      DD DSN=XXXX.TEST.OT,                                     
//            DISP=(NEW,CATLG,DELETE),                                 
//            UNIT=SCRPK,                                             
//            SPACE=(TRK,(1,1),RLSE)                                   
//OUT1     DD DSN=XXXX.TEST.O1,                                     
//            DISP=(NEW,CATLG,DELETE),                                 
//            UNIT=SCRPK,                                             
//            SPACE=(TRK,(1,1),RLSE)                                   
//TOOLIN    DD *                                                       
    SORT FROM(IN1) TO(OUT) USING(CTL1)                                 
    SORT FROM(OUT) TO(OUT1) USING(CTL2)                               
//CTL1CNTL  DD *                                                       
    SORT FIELDS=(34,4,CH,D,30,1,CH,D,32,1,CH,D)                       
    OUTREC FIELDS=(1,40,34,4,30,1,32,1)                               
//CTL2CNTL  DD *                                                       
    SORT FIELDS=COPY                                                   
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(50:SEQNUM,8,ZD,60:SEQNUM,8,ZD,       
               RESTART=(41,6),50,8,ZD,SUB,60,8,ZD))                   
     OUTFIL FNAMES=OUT1,BUILD=(1,40),INCLUDE=(82,1,CH,EQ,C'0')         



The OUT1 file will contain :

Code:

1051270965 482 ODYJUL04U6    7/4/2008
1051270965 482 ODYJUL04U6    7/4/2008


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

Site Director


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

PostPosted: Sat Jul 05, 2008 3:20 am    Post subject:
Reply with quote

Hello,

I suspect this will work for dates with a single-digit month and day but will fail for other dates (which is most dates). . .

Given that the data must be passed twice regardless, why not make two steps - one pass to select the latest date putting the data into a file and the second to select all records that match that date file?
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Sat Jul 05, 2008 1:09 pm    Post subject:
Reply with quote

Hi,
sid_aec wrote:
Do you want a sort card which will pick up the records of latest dates every time or you have the luxury to change the sortcards everytime to sortout the records of your desired dates.
I'm looking for a static SORT card just for now, however if you have some good idea about a "dynamic" SORT card, would appreciate if you share it with us.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Sat Jul 05, 2008 1:38 pm    Post subject:
Reply with quote

Hi Anuj,

Quote:
if you have some good idea about a "dynamic" SORT card, would appreciate if you share it with us.
As i mentioned before, a way (the only way i can think of if the date is completely based on the data) to do this dynamically is to pass the data selecting the highest date.

When the data is passed a "sort control record" containing the highest date is written and used by the actual copy step.

I do not believe you can get what you want passing the data only 1 time.

I would also not try to sort the file by date descending to get the highest date first - this would just waste resources - the greater the volume, the greater the waste icon_smile.gif So far, this hasn't been suggested, but i imagine it could be. . .
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Sat Jul 05, 2008 2:34 pm    Post subject:
Reply with quote

Hi,
sril.krishy wrote:
Please check the below code.
It's official off today, would let you know whether solution works for me or not on Monday, Thanks.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Sat Jul 05, 2008 2:43 pm    Post subject:
Reply with quote

Hi,
dick scherrer wrote:
I suspect this will work for dates with a single-digit month..
Yeah, this was one of the my questions when I was asked to write such a SORT, I'll again ask 'them' to provide me the dates in some standard formats.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Sat Jul 05, 2008 2:57 pm    Post subject:
Reply with quote

Hi Dick,
dick scherrer wrote:
I do not believe you can get what you want passing the data only 1 time.
I'm working on combinations, I try to use SYMNAMES but this is availbale in 1.3 release of SyncSort & my site is using 1.2.something version. But that would also need two passes.

And
Quote:
I would also not try to sort the file by date descending to get the highest date first - this would just waste resources - the greater the volume, the greater the waste icon_smile.gif So far, this hasn't been suggested, but i imagine it could be. . .
What difference would it make, as SORT would "process" all the records even if two passes..


P.S.: I kept this thread open for a longer time and didn't refresh, so couldn't check your replies that fast..
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Sat Jul 05, 2008 10:07 pm    Post subject:
Reply with quote

Hi Anuj,

Quote:
Yeah, this was one of the my questions when I was asked to write such a SORT, I'll again ask 'them' to provide me the dates in some standard formats.
The format shown may be the "standard format". If you're willing to write just a tiny bit of code, it is no problem to work with dates in that format. Assuming there is already code somewhere that already reads this file, it should not take 30 minutes to clone it, add an output file to hold the "date record", and pass the data selecting the most recent date. . .

Symnames will not remove a pass of the data - it would only let you use a "name" later in the code.
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 182
Location: hyderabad

PostPosted: Sat Jul 05, 2008 11:25 pm    Post subject: Reply to: SYNCSORT JCL based on date comarison in a single i
Reply with quote

Quote:
I do not believe you can get what you want passing the data only 1 time


Quote:
I would also not try to sort the file by date descending to get the highest date first


dick scherrer,
you are saying that we cant't get the desired o/p in a single step and also without descending order.

could you please post the jcl how can we do this without descending sort .Just curious to know.

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

Site Director


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

PostPosted: Sat Jul 05, 2008 11:30 pm    Post subject:
Reply with quote

Hello Krishy,

Quote:
you are saying that we cant't get the desired o/p in a single step and also without descending order.
We might get the result in a single "step", but not in a single pass of the data. It will take one pass to determine the most recent date and a second pass to select all of the records with that date.

Quote:
could you please post the jcl how can we do this without descending sort .Just curious to know.
Once the date is known, simply passing the file selecting the records for the "date" will not require any sorting of the file. If the output (records matching the select date) need to be in some particulr order, they could be "sort"ed rather than "copy"ed while creating the output file.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Sun Jul 06, 2008 12:04 am    Post subject:
Reply with quote

Hi Dick,

It's a "new" requirement & I thought to write a JCL for this instead of a COBOL code.

Quote:
it should not take 30 minutes to clone it
If this is kinda sarcastic, I liked it; someone is there who doesn't like my lieant behaviour about my work (perhaps).. icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Sun Jul 06, 2008 1:58 am    Post subject:
Reply with quote

Hi Anuj,

No not sarcastic - it is that trivial a bit of code. . .

Think about it:
2 fd's
2 opens/closes,
1 read
1 unstring
1 compare against the previous high date moving in "this" date if is is greater
1 write of the highest date after all records have been checked

That took less than 2 minutes - the code would not take much longer if entirely coded/typed by hand. And the program could mostly be cloned. . .
FWIW. . .

/SadnessOn
One thing i see today is what i call "the hammer syndrome". That is when one has a hammer and has learned to use it for more than simply pounding, there is a tendancy to want to use the hammer even when it is not appropriate (or indeed even wrong). I believe a requirement should be looked thru and some appropriate tool(s) be used - not just try to force the hammer to do the task.

Some solutions suggested (not this topic) take 3 or 5 passes of the data where 1 or at most 2 passes would be all that was needed. Worse, it might not be obvious to someone who had no clue and simply implemented something posted that successfully tested on a few records. If the total number of records is less than 100 it probably would never matter. When that process must handle 100million records, the "tuning" topics arrive. . . Or a new mainframe becomes necessary.

What makes it sad is that it is just not that difficult to deliver processes that run correctly and run well and are maintainable.
/SadnessOff
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Mon Jul 07, 2008 11:49 am    Post subject:
Reply with quote

Hi Krishy,
Anuj D. wrote:
would let you know whether solution works for me or not on Monday
SORT does work. Well, being lil picky but would like to listen the logic from the horses' mouth, if you don't mind.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Mon Jul 07, 2008 12:20 pm    Post subject:
Reply with quote

Hi Dick,

This work is not from my project I'm handling. They came to me with this requirement, they had quite a good constraint of time limits. My first thought about this prolem was to write a COBOL program but they asked if possible please work parally on SORT, because, today (July 07, IST) is their UAT (count the time since when I posted first). Well, I know this type of projects are not always there & this is not a nice example of a good management but when clinet needs one can't just deny (unless you want to loose your project).

That's all, and I try to help them, but I was facing lil problem in writing the SORT, so asked into the forum; so that if program is not possible at time some JCL could be handy; later it would be replaced with a program, hopefully this later would be pretty soon.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon Jul 07, 2008 7:45 pm    Post subject:
Reply with quote

Hi Anuj,

Tried to reply several hours ago, but was unable to post due to some kind of "technical difficulties" . . .

Quote:
when clinet needs one can't just deny
True, i would not recommend to "just deny". I do make sure the client gets what they require rather quickly. . . Given that they had a time constraint and given that the requirement was posted around 9 on Friday, using a bit of front-end cobol to detemine the selection date and doing the sort/copy with sort, the alternate process could have been running by noon on Friday.

FWIW. . .
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Jul 22, 2008 5:42 pm    Post subject:
Reply with quote

Hi Dick,

Have lost the track of this thread several days ago...
Quote:
True, i would not recommend to "just deny". I do make sure the client gets what they require rather quickly. . . Given that they had a time constraint and given that the requirement was posted around 9 on Friday, using a bit of front-end cobol to detemine the selection date and doing the sort/copy with sort, the alternate process could have been running by noon on Friday.
Agreed, but unless you are the owner of the project, you can't help..
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am


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