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 

Date Dependant code in JCL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
Novice
Beginner


Joined: 27 Dec 2002
Posts: 46
Topics: 15

PostPosted: Mon Mar 06, 2006 10:39 am    Post subject: Date Dependant code in JCL Reply with quote

We have an interface to which we send our files at the end of the day processing (Our system runs on Flat file and no DB2 involved). Now we need to add 8 new fields to our interface file. Our scheduled implementation is July 5th. Where as the scheduled implementation of our interface is August 4th. This calls us for the following situation.

1) Make changes to our programs to generate these new 8 fields.
2) Suppress the 8 fields from the file and send the file in the old format to our partner interface.
3) Starting from August 4th, do not suppress the new fields and send the full file to our interface.

Our conventional approach: We put a lot of date dependant code in the programs to kick off the new fields starting from August 4th onwards. This code after August 4th becomes redundant and I personally feel causing lot of maintenance issues and bulkier code

My suggestion:
Since the number of programs which the file undergoes are more than 10 and these fields under go population and changes across these programs, I suggested not to put date dependant code in programs. Instead want to suppress the fields in the file using utilities like DFSORT.
My Idea is to
1) Generate the file with all the new 8 fields
2) Using DFSORT features of OUTREC, suppress the new fields
3) Using an IF and ELSE condition of JCL (where in I will compare the current date with AUGUST 4, 2006) I will either send the file with suppressed fields or the full file.

I am having problem with point 3 which I mentioned above. I am not so sure how to achieve this. Can this be achieved using any utilities like DFSORT (we are a DFSORT Shop) or Can we use Zeke? ( This I am not so sure what scheduler we use) if so how.
Any help is appreciated

Thanks
Novice
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Mar 06, 2006 11:03 am    Post subject: Reply with quote

Quote:

I am having problem with point 3 which I mentioned above. I am not so sure how to achieve this. Can this be achieved using any utilities like DFSORT (we are a DFSORT Shop) or Can we use Zeke? ( This I am not so sure what scheduler we use) if so how.
Any help is appreciated


Novice,

Step 3 is quite easy. We use symnames to dynamically create OUTREC FIELDS depending on the date and use that in the later step to either send the new files or not.

Try this job. I assumed that your file with 8 new fields length is 300 and without the new fields it is 200. So until august 3rd we only send 200 bytes and after that we send 300 bytes.

The first step determines the date using DATE1(YYYYMMDD) and using OUTFIL we create 2 output files(LTAUG04 and GTAUG04). But at any time you will write to 1 output file. And in the next Step we will either chop or retain the new fields.

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
DUMMY RECORD                                                       
//LTAUG04  DD DSN=&T1,DISP=(NEW,CATLG,DELETE),SPACE=(TRK,(1,1),RLSE)
//GTAUG04  DD DSN=&T2,DISP=(NEW,CATLG,DELETE),SPACE=(TRK,(1,1),RLSE)
//SYSIN DD *                                                       
  SORT FIELDS=COPY                                                 
  INREC FIELDS=(DATE1)                                             
  OUTFIL FNAMES=LTAUG04,INCLUDE=(1,8,CH,LT,C'20060804'),           
  OUTREC=(C'NEWFIELDS,1,200',80:X)                                   
  OUTFIL FNAMES=GTAUG04,SAVE,                                       
  OUTREC=(C'NEWFIELDS,1,300',80:X)                                   
/*                                                                 
//STEP0200 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*                                             
//SYMNAMES DD DSN=&T1,DISP=OLD                                     
//         DD DSN=&T2,DISP=OLD                                     
//SORTIN   DD DSN=YOUR INPUT FILE WITH NEW FIELDS,
//            DISP=SHR           
//SORTOUT  DD DSN=YOUR OUTPUT SENDING FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *                                                       
  SORT FIELDS=COPY                                                 
  OUTREC FIELDS=(NEWFIELDS)                                         
/*                                                                 


The output from step0100 will be as follows until August 3rd.
Code:

NEWFIELDS,1,200


The output from step0100 will be as follows after August 3rd.

Code:

NEWFIELDS,1,300


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
Novice
Beginner


Joined: 27 Dec 2002
Posts: 46
Topics: 15

PostPosted: Tue Mar 14, 2006 10:09 am    Post subject: Reply with quote

Kolusu,

Thanks for the solution. The same problem had a variation which popped up. The file which we generate has ONE Header record, ONE trailer record and multiple detail records( Detail record has two lay outs).
Header record is identified by 20th Byte as 0(packed decimal)
Trailer record is identified by 20th Byte as 9(packed decimal)
Detail record 1 is identified by 20th Byte as 1(packed decimal)
Detail record 2 is identified by 20th Byte as 2(packed decimal)


The new fields are to be added for Detail record 1 only and rest of the requirements are the same. During this entire operation the Order of the records should not be changed. I am just wondering how to handle this ?

Novice
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Mar 14, 2006 10:27 am    Post subject: Reply with quote

Novice,

You got a solution to your problem within 30 minutes and you never came back and told us if it worked or not. Now after a week you came back once again because you wanted a solution and if we provide the solution you would disappear again.

I guess expecting a feedback for the solutions posted here is too much to ask.

Quote:

The new fields are to be added for Detail record 1 only and rest of the requirements are the same. During this entire operation the Order of the records should not be changed. I am just wondering how to handle this ?


What values do you want the other records(header , trailer detail record 2) to have in the new fields? Spaces or low-values or ????

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


Joined: 27 Dec 2002
Posts: 46
Topics: 15

PostPosted: Tue Mar 14, 2006 12:05 pm    Post subject: Reply with quote

Kolusu,

Quote:
You got a solution to your problem within 30 minutes and you never came back and told us if it worked or not. Now after a week you came back once again because you wanted a solution and if we provide the solution you would disappear again.


I appreciate the quick response but I couldn't try the solution and hence I am not able to provide any feed back on the same. But when I started trying the solution today, I realized that file has different formats and turned to the Help again.

The other records should be intact as they were before.

Here is the file lay out expected (LRECL 250)
Code:

HEADERXXXXXXXXXXXXXXXXXX
DETAIL1XXXXXXXXXXX????????X
DETAIL2XXXXXXXXXXXXXXXXXX
DETAIL1YYYYYYYYYYYY?????????Y
DETAIL2YYYYYYYYYYYYYYYYYYYY
TRAILER

The question marks in Detail lay out 1 are the new fields added by reducing the filler at the end to keep the total LRECL as 250. So before August 4th, the file should be
Code:

HEADERXXXXXXXXXXXXXXXXXX
DETAIL1XXXXXXXXXXXXFILLER
DETAIL2XXXXXXXXXXXXXXXXXX
DETAIL1YYYYYYYYYYYYYYFILLER
DETAIL2YYYYYYYYYYYYYYYYYYYY
TRAILER

And after August 4th It should look like below
Code:

HEADERXXXXXXXXXXXXXXXXXX
DETAIL1XXXXXXXXXXX????????X
DETAIL2XXXXXXXXXXXXXXXXXX
DETAIL1YYYYYYYYYYYY?????????Y
DETAIL2YYYYYYYYYYYYYYYYYYYY
TRAILER

I hope I am clear in my requirements.

Here is what the approach which I could think off . Separate Header, Trailers into separate files. Generate a unique number for all the existing detail records. Take Detail1 and Detail 2 records into two separate files. Use the solution which you have mentioned earlier for DETAIL1 records. Bring the Detail1 records output and Detail 2 records together and sort them on Unique number and add header and trailer. Is there a better/simple solution than this approach ? Let me know

Novice
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Mar 14, 2006 12:46 pm    Post subject: Reply with quote

Novice ,

You did not answer my question about the default values for the filler. So I am assuming them as spaces.

I also assumed that you new fields start at pos 200 for a length of 50 bytes.

Quote:

Header record is identified by 20th Byte as 0(packed decimal)
Trailer record is identified by 20th Byte as 9(packed decimal)
Detail record 1 is identified by 20th Byte as 1(packed decimal)
Detail record 2 is identified by 20th Byte as 2(packed decimal)


We create dynamic CHANGE control cards to evaluate detail record 1 at position 20 for 1 which in hex is X'1c'. If the date is less than '20060804' i.e until august 3rd the change card will look this

Code:

  201:20,1,CHANGE=(50,X'1C',C' '),
                  NOMATCH=(201,50))


The output from step0100 will be as follows from August 3rd.

Code:

  201,50)


Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
DUMMY RECORD                                                       
//LTAUG04  DD DSN=&T1,DISP=(NEW,CATLG,DELETE),SPACE=(TRK,(1,1),RLSE)
//GTAUG04  DD DSN=&T2,DISP=(NEW,CATLG,DELETE),SPACE=(TRK,(1,1),RLSE)
//SYSIN DD *                                             
  SORT FIELDS=COPY                                       
  INREC FIELDS=(DATE1)                                   
  OUTFIL FNAMES=LTAUG04,INCLUDE=(1,8,CH,LT,C'20060804'), 
  OUTREC=(C'  201:20,1,CHANGE=(50,X',                     
          C'''',                                         
          C'1C',                                         
          C'''',                                         
          C',C',                                         
          C'''',                                         
          X,                                             
          C'''',                                         
          C'),',/,                                       
          18X,                                           
          C'NOMATCH=(201,50))',                           
          80:X)                                           
  OUTFIL FNAMES=GTAUG04,SAVE,                             
  OUTREC=(C'  201,50)',80:X)                             
/*
//STEP0200 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=YOUR INPUT FILE WITH NEW FIELDS,
//            DISP=SHR           
//SORTOUT  DD DSN=YOUR OUTPUT SENDING FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *                   
  SORT FIELDS=COPY                 
  OUTREC FIELDS=(01,200,           
//         DD DSN=&T1,DISP=OLD
//         DD DSN=&T2,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
Novice
Beginner


Joined: 27 Dec 2002
Posts: 46
Topics: 15

PostPosted: Tue Mar 14, 2006 1:44 pm    Post subject: Reply with quote

Kolusu,

Thanks and one quick clarification. You asked

Quote:

What values do you want the other records(header , trailer detail record 2) to have in the new fields? Spaces or low-values or ????


The record lay out of DETAIL 1 record is only changed by keeping the LRECL same and by adding new fields and reducing the filler at the end.

That's why I mentioned
Quote:

The other records should be intact as they were before.


I hope the solution is changing only DETAIL 1 records. Please confirm.

Also I do not understand the OUTREC card with Change syntax. I will try to look at the manual first and If i still have questions will get back to you as this syntax is some thing new for me.

Thanks
Novice
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Mar 14, 2006 2:01 pm    Post subject: Reply with quote

Novice,

Run the following job as is right now and see the output of step0200. Then you will understand how the job works.

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
DUMMY RECORD                                                       
//LTAUG04  DD DSN=&T1,DISP=(NEW,CATLG,DELETE),SPACE=(TRK,(1,1),RLSE)
//GTAUG04  DD DSN=&T2,DISP=(NEW,CATLG,DELETE),SPACE=(TRK,(1,1),RLSE)
//SYSIN DD *                                                       
  SORT FIELDS=COPY                                                 
  INREC FIELDS=(DATE1)                                             
  OUTFIL FNAMES=LTAUG04,INCLUDE=(1,8,CH,LT,C'20060315'),           
  OUTREC=(C'  41:20,1,CHANGE=(40,C',                               
          C'''',                                                   
          C'1',                                                     
          C'''',                                                   
          C',C',                                                   
          C'''',                                                   
          X,                                                       
          C'''',                                                   
          C'),',/,                                                 
          26X,                                                     
          C'NOMATCH=(41,40))',                                     
          80:X)                                                     
  OUTFIL FNAMES=GTAUG04,SAVE,                                       
  OUTREC=(C'  41,40)',80:X)                                         
/*                                                                 
//STEP0200 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=* 
//SORTIN   DD *                                                 
----+----1----+----2----+----3----+----4----+----5----+----6----
HEADERXXXXXXXXXXXXX0XXXX                00000000000000000000   
DETAIL1XXXXXXXXXXXX1XXXXXXXXX           MY NEW FIELDS - 1       
DETAIL2XXXXXXXXXXXX2XXXXX               OLD FIELDS RECORD - 1   
DETAIL1YYYYYYYYYYYY1XXXXXXXXX           MY NEW FIELDS - 2       
DETAIL2YYYYYYYYYYYY2YYYYYYY             OLD FIELDS RECORD - 2   
TRAILER            9                    9999999999999999999999 
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                 
  OUTREC FIELDS=(01,40,                                             
//         DD DSN=&T1,DISP=OLD                                     
//         DD DSN=&T2,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
Novice
Beginner


Joined: 27 Dec 2002
Posts: 46
Topics: 15

PostPosted: Tue Mar 14, 2006 3:24 pm    Post subject: Reply with quote

Thanks Kolusu. By chaging the date, I could see the difference in the way Detail record 1 is displayed

Novice
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Mar 14, 2006 3:27 pm    Post subject: Reply with quote

Quote:

Thanks Kolusu. By chaging the date, I could see the difference in the way Detail record 1 is displayed


So does that satisfy your requirements?

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


Joined: 27 Dec 2002
Posts: 46
Topics: 15

PostPosted: Wed Mar 15, 2006 9:47 am    Post subject: Reply with quote

Quote:

So does that satisfy your requirements?


Yes.

With reference you example say if my new fields begin at 225th position(you took them as 41st position in your example) and the length of new fields as 20 bytes, then if I chanhe the corresponding fields, does this suffice ? I tried the following example and I am getting same out put files with current date and tomorrow's date and wondering If I did any thing wrong ?

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
DUMMY RECORD                                                       
//LTAUG04  DD DSN=&T1,DISP=(NEW,CATLG,DELETE),SPACE=(TRK,(1,1),RLSE)
//GTAUG04  DD DSN=&T2,DISP=(NEW,CATLG,DELETE),SPACE=(TRK,(1,1),RLSE)
//SYSIN DD *                                                       
  SORT FIELDS=COPY                                                 
  INREC FIELDS=(DATE1)                                             
  OUTFIL FNAMES=LTAUG04,INCLUDE=(1,8,CH,LT,C'20060315'),           
  OUTREC=(C'  225:20,1,CHANGE=(26,C',                               
          C'''',                                                   
          C'1',                                                     
          C'''',                                                   
          C',C',                                                   
          C'''',                                                   
          X,                                                       
          C'''',                                                   
          C'),',/,                                                 
          26X,                                                     
          C'NOMATCH=(225,26))',                                     
          80:X)                                                     
  OUTFIL FNAMES=GTAUG04,SAVE,                                       
  OUTREC=(C'  225,26)',80:X)                                         
/*                                                                 
//STEP0200 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=* 
//SORTIN   DD DSN=MYINPUT                                                 
 
//SORTOUT  DD DSN=MYNEW OUTPUT                                             
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                 
  OUTREC FIELDS=(01,224,                                             
//         DD DSN=&T1,DISP=OLD                                     
//         DD DSN=&T2,DISP=OLD



Thanks again for your help

Novice
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Mar 15, 2006 10:08 am    Post subject: Reply with quote

Quote:

With reference you example say if my new fields begin at 225th position(you took them as 41st position in your example) and the length of new fields as 20 bytes, then if I chanhe the corresponding fields, does this suffice ?


Novice,

yes it would suffice. However you say the newfields is only 20 bytes but in your change card you mentioned 26. I guess one of them was typo

Quote:

I tried the following example and I am getting same out put files with current date and tomorrow's date and wondering If I did any thing wrong


The reason it did not work for you because you have packed decimal field at pos 20 instead of character field. The CHANGE parameter looks for character '1' and it is Not found it will just copy the contents as is. I just used a character field so that you can easily understand.

Change your step0100 control cards to the following. test it with todays date and tommorrow's date

Code:

//SYSIN DD *                                           
  SORT FIELDS=COPY                                     
  INREC FIELDS=(DATE1)                                 
  OUTFIL FNAMES=LTAUG04,INCLUDE=(1,8,CH,LT,C'20060316'),
  OUTREC=(C'  225:20,1,CHANGE=(26,X',                   
          C'''',                                       
          C'1C',                                       
          C'''',                                       
          C',C',                                       
          C'''',                                       
          X,                                           
          C'''',                                       
          C'),',/,                                     
          10X,                                         
          C'NOMATCH=(225,26))',                         
          80:X)                                         
  OUTFIL FNAMES=GTAUG04,SAVE,                           
  OUTREC=(C'  225,26)',80:X)                           
/*                                                     


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
Novice
Beginner


Joined: 27 Dec 2002
Posts: 46
Topics: 15

PostPosted: Thu Mar 16, 2006 11:56 am    Post subject: Reply with quote

Thanks Kolusu. It worked

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


Joined: 27 Dec 2002
Posts: 46
Topics: 15

PostPosted: Thu Mar 23, 2006 11:20 am    Post subject: Reply with quote

Hi Kolusu,

If the above instream sort statements are to be converted as a member of PDS, how I need to handle the DD DSN Statements of STEP0200 ?

Thanks
Novice
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Mar 23, 2006 12:29 pm    Post subject: Reply with quote

Quote:

If the above instream sort statements are to be converted as a member of PDS, how I need to handle the DD DSN Statements of STEP0200 ?


Novice,

Code:

//SYSIN    DD DSN=YOUR PDS(MEMBER),
//            DISP=SHR
//         DD DSN=&T1,DISP=OLD
//         DD DSN=&T2,DISP=OLD


if you decide to create step0100 output also a pds members then

step0100 should be as follows

Code:

//LTAUG04  DD DSN=YOUR PDS(LT MEM),DISP=SHR
//GTAUG04  DD DSN=YOUR PDS(GT MEM),DISP=SHR


and in step0200 the sysin would be
Code:

//SYSIN    DD DSN=YOUR PDS(MEMBER),
//            DISP=SHR
//         DD DSN=YOUR PDS(LT MEM),
//            DISP=SHR
//         DD DSN=YOUR PDS(GT MEM),
//            DISP=SHR


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
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) 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