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
 

 

SORT on DATE(previous days record)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
simmimahajan

New User


Joined: 27 Mar 2007
Posts: 30
Location: USA

PostPosted: Fri Mar 26, 2010 4:57 pm    Post subject: SORT on DATE(previous days record)
Reply with quote

SORT on DATE(previous days record).

I have a requirement where in my job (say JOB-B) would run daily (Monday through Friday) and is dependent on another job (say JOB-A)which would generate a daily file and this would be used by JOB-B. I want to pick up one day prior records. i.e. Monday (of JOB-B) should pick up friday's file version (of JOB-A), Tuesday should pick up Monday's file version etc. But the issue is Friday's job (JOB-A)may get delayed for some reason/or may be held and may get delayed
and may run on sat/sun/monday.


If I happen to use two sort cards like

1) To be used for Tuesday through Friday

SORT FIELDS=COPY
INCLUDE COND=(1,5,Y2T,EQ,Y'DATE3'-1)

and

2) Another to be used for Monday

SORT FIELDS=COPY
INCLUDE COND=(1,5,Y2T,EQ,Y'DATE3'-??)


The subtraction digit may be a problem. If it gets delayed by 1 day, I may have to use -2, if delayed by 2 days, I may have to use -3 and so on.So I need to know at run time what should be the subtraction digit and accordingly during scheduling I can pass the sortcard.


So,

1) Is there any way to trace / trap version # of job (JOB-A) when it is loaded in production?
2) If so, is there a way to pass parameter dynamically through DFSORT and use the job version (of JOB-A) when it is loaded in production. This might help as
even though Friday's version gets delayed and runs any time/day, if it runs with particular version, we can do job_version -1

Or another solution is

1) Let first version of job run and then generate a file with date in it and pass this date -1 to the sort everytime it runs next time. But I am unaware how can we pass such parameters?

OR
1) is there some better solution to this?
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Mar 26, 2010 5:21 pm    Post subject:
Reply with quote

Maybe I'm wrong here, but wouldn't a GDS solve the problem, or are we actually performing an include because it needs to be done.

And on Monday the run of JOB-B will read the 0 gen of the GDS created whenever by the feeder job.
Back to top
View user's profile Send private message
simmimahajan

New User


Joined: 27 Mar 2007
Posts: 30
Location: USA

PostPosted: Fri Mar 26, 2010 5:27 pm    Post subject: Reply to: SORT on DATE(previous days record)
Reply with quote

Hi Expat,

Thanks for the reply.

Yes, we actually need a INCLUDE condition, and GDS will not solve my issue as the input file is collection of historical data and we only need to choose records chanign for a particular day.
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 995
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Fri Mar 26, 2010 5:39 pm    Post subject:
Reply with quote

Would this approach be of use?

Use a GDG of run dates which is created by, say, the last step of your Job-A. This gives the date on which Job-A ran which is typically the Mon-Fri dates.The (-1) of the date GDG is always the last day that Job-A was run, even if it was delayed from Friday to Saturday or Sunday. In normal running Monday's (-1) would point to Friday.

Alternatively, if you only ever need to go back one day, have Job-A record its run-date in a non-GDG .

Garry.
Back to top
View user's profile Send private message
simmimahajan

New User


Joined: 27 Mar 2007
Posts: 30
Location: USA

PostPosted: Fri Mar 26, 2010 5:45 pm    Post subject: Reply to: SORT on DATE(previous days record)
Reply with quote

The input file is a flat file and is in sorted order and I want to retain the order of the file.
I will not be in a position to identify which records are recently added to the output file of JOB-A

Hence GDG won't really help. We need some crtieria through SORT or may be through REXX which can be then used in our JCL,whatever best can be used.
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 995
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Fri Mar 26, 2010 5:57 pm    Post subject:
Reply with quote

I'm not suggesting that your input file be GDG - my suggestion is that you have another file created that contains the date that Job-A was run. You can then use this file in a DFSORT step which dynamically generates the control cards in (new) STEP1 for the DFSORT step in STEP2 which processes your input file - or use SYMNAMES.

If you need to go back more than one day, then having that date file in a GDG would be useful.

Garry.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Mar 26, 2010 10:31 pm    Post subject: Reply to: SORT on DATE(previous days record)
Reply with quote

simmimahajan,

The simplest thing to do is to create the Job-B's INCLUDE card in JOB-A itself. So it will create the copy statement and the include cond validating the day of the week it is running

when job-a runs on tuesday thru saturday the subtraction day is set to 1 and on sunday it is set 2 and on monday it is set to 3.

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SYMNAMES DD *                                               
WDAY,S'&LWDAY'                                               
//SORTIN   DD *                                               
DUMMY RECORD                                                 
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                           
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(20:WDAY,25:C'1')),         
  IFTHEN=(WHEN=(20,3,CH,EQ,C'SUN'),OVERLAY=(25:C'2')),       
  IFTHEN=(WHEN=(20,3,CH,EQ,C'MON'),OVERLAY=(25:C'3'))         
  OUTFIL BUILD=(3:C'OPTION COPY',/,                           
                3:C'INCLUDE COND=(1,5,Y2T,EQ,Y''',C'DATE3''',
                    C'-',25,1,C')',80:X)                     
//*
Back to top
View user's profile Send private message
simmimahajan

New User


Joined: 27 Mar 2007
Posts: 30
Location: USA

PostPosted: Sat Mar 27, 2010 7:05 pm    Post subject: Reply to: SORT on DATE(previous days record)
Reply with quote

Hi All,

Thanks for your suggestions, I would work on these on Monday and get back to you with the solution chosen. I need to confirm on how many changes can we do to JOB -A as it falls under critical path processing, and minimum changes are expected to this process. Once again thanks, will surely respond you back to your suggestions.
Back to top
View user's profile Send private message
simmimahajan

New User


Joined: 27 Mar 2007
Posts: 30
Location: USA

PostPosted: Mon Mar 29, 2010 2:30 pm    Post subject: Reply to: SORT on DATE(previous days record)
Reply with quote

Hi All,

As promised, I am back with the solution devised for this problem. On giving a further thought to this problem and indepth discussion, we found that the schedule date/date when it is loaded on jobtrac can be trapped with some JOBTRAC parameters. Using the JOBTRAC parameter for (List of Symbolic Vars ) we now create a file (basically a parm file containing the desired date). We then use this file as input to SORT along with another file (our actual input file) and use JOINKEYS to get the desired output.

SORT
====

//SORT1 EXEC PGM=SORT
//SORTJNF1 DD DSN=FILE1,
// DISP=SHR
//SORTJNF2 DD DSN=FILE2,
// DISP=SHR
//SORTOUT DD DSN=OUTPUTFILE,
// DISP=(NEW,CATLG,DELETE),
// RECFM=VB,
// LRECL=900,
// SPACE=(CYL,(1,1),RLSE)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(1,5,A)
JOINKEYS FILES=F2,FIELDS=(20,5,A)
REFORMAT FIELDS=(F2:5,896)
OUTFIL FTOV,VLTRIM=C' '
SORT FIELDS=COPY

Thanks!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Mar 29, 2010 10:18 pm    Post subject:
Reply with quote

simmimahajan,

Woah. The latest example is no where near to what you described in your initial post. Wonder why people waste others time. Sigh
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm


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