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

SORT on DATE(previous days record)


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Fri Mar 26, 2010 5:21 pm
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
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Fri Mar 26, 2010 5:39 pm
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
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Fri Mar 26, 2010 5:57 pm
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 4
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 SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top