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 

Sort based on day

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
amzad
Beginner


Joined: 01 Feb 2004
Posts: 5
Topics: 2

PostPosted: Sun Feb 01, 2004 5:36 pm    Post subject: Sort based on day Reply with quote

Hi All,

Need Help in sort.

I have input file say for example AAAA and the jcl,

Code:

//STEP0400  EXEC  PGM=SORT                 
//SORTIN    DD  DSN=XXXX.TEST.BKUP, 
//          DISP=SHR                                 
//SORTOF01  DD  DSN=XXXX.TEST.FILE1,     
//          DISP=(,CATLG,DELETE),                     
//          SPACE=(CYL,(05,10),RLSE),                 
//          DCB=(DSORG=PS,RECFM=FB,LRECL=04)       
//SORTOF02  DD  DSN=XXXX.TEST.FILE2,     
//          DISP=(,CATLG,DELETE),                     
//          SPACE=(CYL,(05,10),RLSE),                 
//          DCB=(DSORG=PS,RECFM=FB,LRECL=04)       
//SORTOF03  DD  DSN=XXXX.TEST.FILE3,     
//          DISP=(,CATLG,DELETE),                     
//          SPACE=(CYL,(05,10),RLSE),                 
//          DCB=(DSORG=PS,RECFM=FB,LRECL=04)       
//SYSIN  DD *
 SORT FIELDS=COPY,EQUALS
 OUTFIL  FILES=01,     
        INCLUDE=(01,04,CH,EQ,C'AAAA')
 OUTFIL  FILES=02,     
        INCLUDE=(01,04,CH,EQ,C'AAAA')
 OUTFIL  FILES=03,     
        INCLUDE=(01,04,CH,EQ,C'AAAA')
/*


My requirement is to create each file each day not all three files(i.e.) When I run job on tuseday,it should create only XXXX.TEST.FILE1 leaving other 2 files empty.When I run the job on Wednesday,it should create only XXXX.TEST.FILE2 and on Thrusday,it should create only XXX.TEST.FILE3.

Using above jcl,I cannot acomplish the given requirement. Is there any way to achieve the same?.

FYI : I have to revised the above Jcl and I cannot go for separate JCL's.

Ur coments and suggestions are most welcome.

amjad Sad
Back to top
View user's profile Send private message
amzad
Beginner


Joined: 01 Feb 2004
Posts: 5
Topics: 2

PostPosted: Sun Feb 01, 2004 11:05 pm    Post subject: Reply with quote

Hi All,


AAAA is not the input file but the data in the input file.

Sorry for the inconvienence.!!!

amjad
Back to top
View user's profile Send private message
shiv_swami
Beginner


Joined: 29 Nov 2003
Posts: 68
Topics: 14

PostPosted: Mon Feb 02, 2004 2:38 am    Post subject: Reply with quote

Hi Amzad,

You could write an EZT program or Cobol program to genrate the JCL along Control parameters for the day.
COB program would be writing the o/p JCL to Internal reader.There are plenty of posts for Internal reader usage in the forum,just Search them.
Use WS-CURRENT-DAY in creating the filename as well as include clause.
Check following post
http://www.mvsforums.com/helpboards/viewtopic.php?t=1089

Code:

ACCEPT WS-CURRENT-DAY FROM DAY-OF-WEEK

EVALUDATE WS-CURRENT-DAY 

When '1'
INCLUDE=(01,04,CH,EQ,C'MON')   ==> MOVE TO O/P FILE
OUTFIL  FILES=01,            ==> MOVE TO O/P FILE
//SORTOF01  DD  DSN=XXXX.TEST.MON,     ==> MOVE TO O/P FILE

WHEN '2'
INCLUDE=(01,04,CH,EQ,C'TUE')   ==> MOVE TO O/P FILE
OUTFIL  FILES=02,            ==> MOVE TO O/P FILE
//SORTOF01  DD  DSN=XXXX.TEST.TUE,     ==> MOVE TO O/P FILE

_________________
Regards,
Shivprakash
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Feb 02, 2004 6:17 am    Post subject: Reply with quote

Amjad,

I see that all your files are created based on the same criteria (1,4,ch,eq,AAAA). why not create just one file( with a generic name) and run the job only on tuesday, wednesday and thursday?

Btw sort products does not have any built-in functions to determine day of the week. You can use db2 to determine the date and in next step run a sort to determine which file needs to be created. We use the DAYOFWEEK function which returns an integer in the range of 1 to 7 that represents the day of the week where 1 is Sunday and 7 is Saturday.

A brief explanation of the job. The first step unloads a 1 record from db2 table with the week day number in binary format. since today is monday that number will be 2. now we take this 1 record file is input in step0200 and first convert the binary number into zoned decimal number.

Now we generate the dynamic control cards for writting out to the right file based on the day. since you wanted to create the files only on monday tuesday wednesday, we code a dummy file for the rest of the days. For doing that we use a change command to determine the file number. The output from this step would be as follows
Code:

  SORT FIELDS=COPY                     
  INCLUDE COND=(1,4,CH,EQ,C'AAAA')     
  OUTFIL FILES=01                       


Now we will use this a control card for the actual dataset creation step(step0300)

Code:

//STEP0100 EXEC PGM=IKJEFT01                                 
//SYSTSPRT DD  SYSOUT=*,DCB=BLKSIZE=121                     
//SYSPRINT DD  SYSOUT=*                                     
//SYSTSIN  DD  *                                             
  DSN SYSTEM(XXXX)                                           
  RUN PROGRAM(DSNTIAUL) -                                   
      PLAN(DSNTIAUL)    -                                   
      PARMS('SQL')      -                                   
      LIB('DB2P.RUNLIB.LOAD')                               
//SYSREC00 DD DSN=&T1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)   
//SYSPUNCH DD DUMMY                                         
//SYSIN    DD  *                                             
 SELECT DAYOFWEEK(CURRENT DATE)
   FROM SYSIBM.SYSDUMMY1                                     
   ;                             
//*
//STEP0200  EXEC  PGM=SORT                                             
//SYSOUT    DD SYSOUT=*                                               
//SORTIN    DD DSN=&T1,DISP=OLD                                       
//SORTOUT   DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)             
//SYSIN     DD  *                                                     
  SORT FIELDS=COPY                                                     
  INREC FIELDS=(1,4,BI,EDIT=(TT))                                       
  OUTFIL OUTREC=(C' SORT FIELDS=COPY',/,                               
                 C' INCLUDE COND=(1,4,CH,EQ,C''AAAA''',C')',/,         
                 C' OUTFIL FILES=',15:1,2,CHANGE=(2,C'02',C'01',       
                                                    C'03',C'02',       
                                                    C'04',C'03'),       
                                                 NOMATCH=(C'04'),80:X) 
//*
//STEP0300  EXEC  PGM=SORT                 
//SYSOUT    DD SYSOUT=*
//SORTIN    DD DSN=YOUR INPUT FILE,
//             DISP=SHR
//SORTOF01  DD  DSN=XXXX.TEST.FILE1,     
//          DISP=(NEW,CATLG,DELETE),                     
//          SPACE=(CYL,(05,10),RLSE)
//SORTOF02  DD  DSN=XXXX.TEST.FILE2,     
//          DISP=(NEW,CATLG,DELETE),                     
//          SPACE=(CYL,(05,10),RLSE)                 
//SORTOF03  DD  DSN=XXXX.TEST.FILE3,     
//          DISP=(NEW,CATLG,DELETE),                     
//          SPACE=(CYL,(05,10),RLSE)                 
//SORTOF04  DD DUMMY
//SYSIN     DD DSN=&C1,DISP=OLD             
//*



Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
amzad
Beginner


Joined: 01 Feb 2004
Posts: 5
Topics: 2

PostPosted: Sun Feb 08, 2004 12:16 pm    Post subject: Reply with quote

Hi Kolusu and Shiva,

Thanks for your valuable suggestions. I can neither go for DB2 nor eztrieve but to modify the JCL.We console the customer to send the input files so as to identify specific file to process on that specific day.

Thanks for all your help.

regds,
Amjad
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
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