MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How can we do this using Sort..?
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
somuk
Beginner


Joined: 04 Feb 2003
Posts: 113
Topics: 37

PostPosted: Thu Nov 20, 2003 9:36 am    Post subject: How can we do this using Sort..? Reply with quote

Hi,
I have a job that runs every business day and creates a new generation of a GDG(the GDG base has been created with limit 180 and we are not allowed to change this).
The first field in this file is the current date(ie; the date when the new generation is created.Format is YYYYMMDD)
Now my requirement is to automate a monthly job that runs on 1st of every month (Before the daily job runs.ie the current generation will be created on the last business day of the previous month).The input for this monthly job are the files that were created in the previous month.Since we can't predict the number files that will get created each month it's not possible to hardcode the generations(ie:0,-1,-2 ...etc).So by specifying the GDG base as the input file(this will take all the 180 generations) how can we extract only the required records for the monthly job.? To be more specific if I'm running my monthly job on 1st of Dec 2003
I have to capture all the records from the respective files that were created on the month of November 2003.

Appreciate any help on this..
_________________
Regds,
Somu
Back to top
View user's profile Send private message Yahoo Messenger
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Thu Nov 20, 2003 10:02 am    Post subject: Reply with quote

Quote:
The first field in this file is the current date(ie; the date when the new generation is created.Format is YYYYMMDD)


So, this means, in a given generation of a GDG, the first 8-bytes in ALL records will be the date field? If yes, then you can have INCLUDE/OMIT logic (using DFSORT) to filter out the records depending on the month.

For example, if the above assumption is true, then for the input as GDG base, you can have the SYSIN as,
Code:

//SYSIN    DD *
 OPTION COPY
 INCLUDE COND=(1,4,CH,EQ,C'2003',&,
                           5,2,CH,EQ,C'11')
/*


Or, is something else the requirement?
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Thu Nov 20, 2003 10:07 am    Post subject: Reply with quote

Cogito-Ergo-Sum,

Somu needs to automate the job every month , so he just cannot keep changing the include cond every month. We need to generate the include cond dynamically every time the job runs. I will post the solution in a few mins

Thanks

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
taltyman
JCL Forum Moderator
JCL Forum Moderator


Joined: 02 Dec 2002
Posts: 310
Topics: 8
Location: Texas

PostPosted: Thu Nov 20, 2003 10:33 am    Post subject: Reply with quote

It's not uncommon to have daily, monthly,yearly or whatever gdgs that rollup to a higher level to prevent your problem. See if they'll let you use a daily and monthly set of gdgs. On the 1st of every month copy all your daily gdgs to a monthly gdg and then wipeout your daily gdg and start over again on daily gdg 1.
You job then simply calls for the monthly gdg. There can be several variations on how to do this. Set your monthly gdg limit to 6 and you'll still have the same data retention as 180 dailies gives you.
Back to top
View user's profile Send private message
somuk
Beginner


Joined: 04 Feb 2003
Posts: 113
Topics: 37

PostPosted: Thu Nov 20, 2003 10:36 am    Post subject: Reply with quote

Hi Taltyman,
Thanks .. We have suggested this solution to the client .. But it's not acceptable for them.. Rolling Eyes
_________________
Regds,
Somu
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Thu Nov 20, 2003 10:59 am    Post subject: Reply with quote

Somu,

The following DFSORT/ICETOOL JCL will give you the desired results.If you have syncsort at your shop then change the pgm name to synctool.

I am posting 2 versions of the same job. If you don't have the latest version of DFSORT or syncsort use solution2.

Solution1: A brief description of the solution. The objective of this job is to create a dynamic control card for the copy process. We use the date parm (DATE1(YYYYMMDD)) on the inrec fields and using a change on outrec fields we will manipulate the year. This change command will only come into effect only when the month is january. In that case we need to subtract 1 year from the current year.so we coded a change command to decrement the year by 1.Similary we use another change command to decrement the month by 1. Once we have decremented the year and month we generate a include cond as follows.

Code:

 INCLUDE COND=(1,6,CH,EQ,C'200310')


Now using this as a control card we copy all the records from the gdg generations.


Code:

//STEP0100 EXEC PGM=ICETOOL     
//TOOLMSG  DD SYSOUT=*         
//DFSMSG   DD SYSOUT=*         
//NULL     DD *                 
DUMMY RECORD                   
//IN       DD DSN=YOUR GDG BASE,
//            DISP=SHR
//OUT      DD DSN=YOUR LAST MONTH RECORDS,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//TOOLIN   DD *                 
  COPY FROM(NULL)       USING(CTL1)   
  COPY FROM(IN) TO(OUT) USING(CTL2)
//CTL1CNTL DD *                                     
  INREC FIELDS=(DATE1,80:X)                           
  OUTREC FIELDS=(1,2,3,4,CHANGE=(2,                   
                       C'0101',C'00',C'0201',C'01', 
                       C'0301',C'02',C'0401',C'03', 
                       C'0501',C'04',C'0601',C'05', 
                       C'0701',C'06',C'0801',C'07', 
                       C'0901',C'08',C'1001',C'09', 
                       C'1101',C'10',C'1201',C'11', 
                       C'1301',C'12',C'1401',C'13', 
                       C'1501',C'14',C'1601',C'15', 
                       C'1701',C'16',C'1801',C'17', 
                       C'1901',C'18',C'2001',C'19', 
                       C'2101',C'20',C'2201',C'21', 
                       C'2301',C'22',C'2401',C'23', 
                       C'2501',C'24',C'2601',C'25', 
                       C'2701',C'26',C'2801',C'27', 
                       C'2901',C'28',C'3001',C'29', 
                       C'3101',C'30',C'3201',C'31', 
                       C'3301',C'32',C'3401',C'33', 
                       C'3501',C'34',C'3601',C'35', 
                       C'3701',C'36',C'3801',C'37', 
                       C'3901',C'38',C'4001',C'39', 
                       C'4101',C'40',C'4201',C'41', 
                       C'4301',C'42',C'4401',C'43', 
                       C'4501',C'44',C'4601',C'45', 
                       C'4701',C'46',C'4801',C'47', 
                       C'4901',C'48',C'5001',C'49', 
                       C'5101',C'50',C'5201',C'51', 
                       C'5301',C'52',C'5401',C'53', 
                       C'5501',C'54',C'5601',C'55', 
                       C'5701',C'56',C'5801',C'57', 
                       C'5901',C'58',C'6001',C'59', 
                       C'6101',C'60',C'6201',C'61', 
                       C'6301',C'62',C'6401',C'63', 
                       C'6501',C'64',C'6601',C'65', 
                       C'6701',C'66',C'6801',C'67', 
                       C'6901',C'68',C'7001',C'69', 
                       C'7101',C'70',C'7201',C'71', 
                       C'7301',C'72',C'7401',C'73',             
                       C'7501',C'74',C'7601',C'75',             
                       C'7701',C'76',C'7801',C'77',             
                       C'7901',C'78',C'8001',C'79',             
                       C'8101',C'80',C'8201',C'81',             
                       C'8301',C'82',C'8401',C'83',             
                       C'8501',C'84',C'8601',C'85',             
                       C'8701',C'86',C'8801',C'87',             
                       C'8901',C'88',C'9001',C'89',             
                       C'9101',C'90',C'9201',C'91',             
                       C'9301',C'92',C'9401',C'93',             
                       C'9501',C'94',C'9601',C'95',             
                       C'9701',C'96',C'9801',C'97',             
                       C'9901',C'98',C'0001',C'99'),             
                       NOMATCH=(3,2),                           
            5,2,CHANGE=(2,                                       
                       C'01',C'12',                             
                       C'02',C'01',                             
                       C'03',C'02',                             
                       C'04',C'03',                             
                       C'05',C'04',                             
                       C'06',C'05',                             
                       C'07',C'06',                             
                       C'08',C'07',                             
                       C'09',C'08',                             
                       C'10',C'09',                             
                       C'11',C'10',                             
                       C'12',C'11'),                             
                       NOMATCH=(5,2))                           
  OUTFIL FNAMES=CTL2CNTL,                                         
  OUTREC=(C' INCLUDE COND=(1,6,CH,EQ,C',X'7D',1,6,X'7D',C')',80:X)
//CTL2CNTL DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//*


Solution2:
If the previous solution gives you an error on DATE1 parm, then you have a older version of the sort product. In that case use the following solution. This solution is also similar to the solution1 except that we need to use the reporting features to get the current date.

Code:

//STEP0100 EXEC PGM=ICETOOL                         
//TOOLMSG  DD SYSOUT=*                               
//DFSMSG   DD SYSOUT=*                               
//NULL     DD *
//DATE     DD DSN=&D,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//IN       DD DSN=YOUR GDG BASE,
//            DISP=SHR
//OUT      DD DSN=YOUR LAST MONTH RECORDS,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//TOOLIN   DD *                 
  COPY FROM(NULL)        USING(CTL1)   
  COPY FROM(DATE)        USING(CTL2)   
  COPY FROM(IN) TO(OUT)  USING(CTL3)
//CTL1CNTL DD *                             
  OUTFIL FNAMES=DATE,HEADER1=(DATE=(MD4/))   
//CTL2CNTL DD *                                     
  INREC FIELDS=(8,4,2,2,80:X)                       
  OUTREC FIELDS=(1,2,3,4,CHANGE=(2,                 
                       C'0101',C'00',C'0201',C'01',
                       C'0301',C'02',C'0401',C'03',
                       C'0501',C'04',C'0601',C'05',
                       C'0701',C'06',C'0801',C'07',
                       C'0901',C'08',C'1001',C'09',
                       C'1101',C'10',C'1201',C'11',
                       C'1301',C'12',C'1401',C'13',
                       C'1501',C'14',C'1601',C'15',
                       C'1701',C'16',C'1801',C'17',
                       C'1901',C'18',C'2001',C'19',
                       C'2101',C'20',C'2201',C'21',
                       C'2301',C'22',C'2401',C'23',
                       C'2501',C'24',C'2601',C'25',
                       C'2701',C'26',C'2801',C'27',
                       C'2901',C'28',C'3001',C'29',
                       C'3101',C'30',C'3201',C'31',
                       C'3301',C'32',C'3401',C'33',
                       C'3501',C'34',C'3601',C'35',
                       C'3701',C'36',C'3801',C'37',
                       C'3901',C'38',C'4001',C'39',
                       C'4101',C'40',C'4201',C'41',
                       C'4301',C'42',C'4401',C'43',
                       C'4501',C'44',C'4601',C'45',
                       C'4701',C'46',C'4801',C'47',
                       C'4901',C'48',C'5001',C'49',
                       C'5101',C'50',C'5201',C'51',
                       C'5301',C'52',C'5401',C'53',
                       C'5501',C'54',C'5601',C'55',
                       C'5701',C'56',C'5801',C'57',
                       C'5901',C'58',C'6001',C'59',
                       C'6101',C'60',C'6201',C'61',
                       C'6301',C'62',C'6401',C'63',
                       C'6501',C'64',C'6601',C'65',
                       C'6701',C'66',C'6801',C'67',
                       C'6901',C'68',C'7001',C'69',
                       C'7101',C'70',C'7201',C'71',   
                       C'7301',C'72',C'7401',C'73',               
                       C'7501',C'74',C'7601',C'75',               
                       C'7701',C'76',C'7801',C'77',               
                       C'7901',C'78',C'8001',C'79',               
                       C'8101',C'80',C'8201',C'81',               
                       C'8301',C'82',C'8401',C'83',               
                       C'8501',C'84',C'8601',C'85',               
                       C'8701',C'86',C'8801',C'87',               
                       C'8901',C'88',C'9001',C'89',               
                       C'9101',C'90',C'9201',C'91',               
                       C'9301',C'92',C'9401',C'93',               
                       C'9501',C'94',C'9601',C'95',               
                       C'9701',C'96',C'9801',C'97',               
                       C'9901',C'98',C'0001',C'99'),               
                       NOMATCH=(3,2),                             
            5,2,CHANGE=(2,                                         
                       C'01',C'12',                               
                       C'02',C'01',                               
                       C'03',C'02',                               
                       C'04',C'03',                               
                       C'05',C'04',                               
                       C'06',C'05',                               
                       C'07',C'06',                               
                       C'08',C'07',                               
                       C'09',C'08',                               
                       C'10',C'09',                               
                       C'11',C'10',                               
                       C'12',C'11'),                               
                       NOMATCH=(5,2))                             
  OUTFIL FNAMES=CTL3CNTL,                                           
  OUTREC=(C' INCLUDE COND=(1,6,CH,EQ,C',X'7D',1,6,X'7D',C')',80:X) 
//CTL3CNTL DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE),RECFM=FB
//*


If your shop has syncsort at your shop then change the dd statement for NULL ddname as follows.
Code:

//NULL     DD DUMMY,DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Nov 20, 2003 11:16 am    Post subject: Reply with quote

Here's an easier way to do this with DFSORT:

Code:

//S1   EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
DUMMY
/*
//S1 DD DSN=&&S1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//S2 DD DSN=&&S2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
* Create C'yyyymm' constant for current date
  INREC FIELDS=(DATE2)
* Create DFSORT symbol for previous month as:
*  LAST_MON,+aaaabb
*
* If mm is not 01, set bb = mm - 1
  OUTFIL FNAMES=S1,
    INCLUDE=(5,2,CH,NE,C'01'),
    OUTREC=(C'LAST_MON,+',
      1,4,                            yyyy
      5,2,ZD,SUB,+1,TO=ZD,LENGTH=2,   mm - 1
      80:X)
* If mm is 01, set aaaa = yyyy - 1 and set bb = 12
  OUTFIL FNAMES=S2,
    SAVE,
    OUTREC=(C'LAST_MON,+',
      1,4,ZD,SUB,+1,TO=ZD,LENGTH=4,   yyyy - 1
      C'12',                          12
      80:X)
/*
//S2   EXEC  PGM=ICEMAN
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//         DD DSN=&&S2,DISP=(OLD,PASS)
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN    DD    *
  OPTION COPY
* Use LAST_MON symbol in INCLUDE statement
  INCLUDE COND=(1,6,ZD,EQ,LAST_MON)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Thu Nov 20, 2003 11:35 am    Post subject: Reply with quote

Somu,

Here is another solution. This solution uses the horizontal math functions to generate the dynamic control cards.The following DFSORT/ICETOOL JCL will give you the desired results.

A brief explanation of the JOb. We use the DATE1 parm to get the current date in the form of YYYYMMDD. Taking this record we create 2 temp files. If the month is 1 then we create C1 and for all others we create C2.

If the current month is January (01), then we subtract 1 from the year using horizontal math function.we hardcode a value of 12 for this case.

If the month is any thing other than january (01) we just subtract 1 from the month part.

So at any given time we will either create C1 or C2 depending on the month.

We now concatenate these 2 temp datasets (one would empty) and copy the last month records.


Code:

//STEP0100 EXEC PGM=ICETOOL                             
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//NULL     DD *                                         
DUMMY RECORD                                             
//C1       DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//C2       DD DSN=&C2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//IN       DD DSN=YOUR GDG BASE,
//            DISP=SHR
//OUT      DD DSN=YOUR LAST MONTH RECORDS,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//TOOLIN   DD *                                             
  COPY FROM(NULL) USING(CTL1)                               
  COPY FROM(IN) TO(OUT) USING(CTL2)                         
//CTL1CNTL DD *                                             
  INREC FIELDS=(DATE1,80:X)                                 
  OUTFIL FNAMES=C1,INCLUDE=(5,2,CH,EQ,C'01'),               
  OUTREC=(C' INCLUDE COND=(1,6,CH,EQ,C',X'7D',               
          +1,SUB,1,4,ZD,EDIT=(TTTT),C'12',X'7D',C')',80:X)   
  OUTFIL FNAMES=C2,SAVE,                                     
  OUTREC=(C' INCLUDE COND=(1,6,CH,EQ,C',X'7D',1,4,           
          +1,SUB,5,2,ZD,EDIT=(TT),X'7D',C')',80:X)           
//CTL2CNTL DD DSN=&C1,DISP=OLD,VOL=REF=*.C1                 
//         DD DSN=&C2,DISP=OLD,VOL=REF=*.C2                 
//*


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Thu Nov 20, 2003 11:38 am    Post subject: Reply with quote

Frank,

Once again you beat me in posting the solution Sad . I did not hit refresh before posting the latest solution.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Nov 20, 2003 11:40 am    Post subject: Reply with quote

Kolusu,

Looks like we came up with two different variations of the same idea (great minds "sink" in the same channels) Smile
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
taltyman
JCL Forum Moderator
JCL Forum Moderator


Joined: 02 Dec 2002
Posts: 310
Topics: 8
Location: Texas

PostPosted: Thu Nov 20, 2003 11:42 am    Post subject: Reply with quote

So the GDG input DD would still be the gdg base? Surely not, why not at least limit it to the last 31 gdgs which would be the most for any month.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Thu Nov 20, 2003 11:44 am    Post subject: Reply with quote

Frank,

I had the topic open and I just posted the solution after thinking about it .I just did not hit refresh and posted the solution. When I hit submit button then only ,I noticed that you posted your solution. As Always Master(Frank) Rules !!

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Thu Nov 20, 2003 11:47 am    Post subject: Reply with quote

Taltyman,

That is a good idea. somu just needs to make sure that the gdg creation job does not run twice a day

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
taltyman
JCL Forum Moderator
JCL Forum Moderator


Joined: 02 Dec 2002
Posts: 310
Topics: 8
Location: Texas

PostPosted: Thu Nov 20, 2003 11:50 am    Post subject: Reply with quote

Another way would be to parse the results of a listcat on the gdg base and build a list of gdg dsnames that were created in the previous month. Use that to construct the jcl needed and submit the job.
It just seems a waste to be to read every record in a file to check a date when that field should have the same value in every record in that gdg. Unless my IEYEBALL scan of the posted solutions is wrong. Also unless these are huge files then who cares.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Thu Nov 20, 2003 12:07 pm    Post subject: Reply with quote

Taltyman,

There is only one problem using listcat info. The creation date of listcat info will be in Julian format. for ex: 2003.322.

Now we need to get an internal table of julian date for the first of every month i.e

2003.001 - January
2003.032 - Feb..
...
....


Now we need to validate the creation dates with 2 boundaries. One with last month's first date and another with current month's first date.

I am not an expert in rexx, but I am very much interested to know if we can generate the internal table with julian date.

The other option is to convert all the GDG creation julian dates to gregorian date and take the GDG gen name.

But I still may have a problem. Let us think of this scenario.

The gdg creation job runs at 11 pm every day. On the 31st of october, this job kicked off at 11 pm and for some reason completed at 1 am . Now the creation date for this gdg would be the 1st of nov. But this file actually contains the data of october.So if we parse the listcat info we would definitely skip this gen which is not correct.

May be I am thinking too much into this

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group