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 updation

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


Joined: 20 Aug 2005
Posts: 11
Topics: 1
Location: chennai

PostPosted: Tue Feb 23, 2010 4:22 am    Post subject: Date updation Reply with quote

Hi,

I need to copy a file by updating the header and trailer records of that file at position 33. Position 33 has the date in mm-dd-yyyy format and output file should reflect current date + 1 month in that position for header and trailer.

I read about various options with DFSORT (DATE1, DATENS etc), but none of them seem to give me the format that I need.

Please help.

Thanks,
Saro
_________________
Saro

Nothing is great unless God.
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 Feb 23, 2010 11:10 am    Post subject: Reply with quote

saro,

You haven't provided any other details like LRECL & RECFM of the input and output files.

I assumed that your input is LRECL=80 and RECFM=FB. Sort products do not have mechanism to add months to the current date. If you are ok with adding 30 days then the following DFSORT JCL will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                     
HDR                                                 
A                                                   
B                                                   
C                                                   
D                                                   
TRL                                                 
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                     
  SORT FIELDS=COPY                                   
  INREC IFOUTLEN=80,                                 
  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),       
  IFTHEN=(WHEN=(81,8,ZD,EQ,1),                       
  OVERLAY=(89:DATE1+30,33:93,2,C'-',95,2,C'-',89,4))
//*


The output from this job is

Code:

HDR                             03-25-2010   
A                                             
B                                             
C                                             
D                                             
TRL                                           

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


Joined: 20 Aug 2005
Posts: 11
Topics: 1
Location: chennai

PostPosted: Wed Feb 24, 2010 2:34 am    Post subject: Reply with quote

Thanks Kolusu. I am sorry, i did not provide many details.
I used something similar to your solution to get the output.

Basically my file is a VB file and header and trailer are of 512 length.
header position 17,4 has HEDR
position 33,10 has mm-dd-yyyy

Trailer position 17,4 has TRLR
position 33,10 has mm-dd-yyyy

Following sort card worked.
Code:

INREC IFTHEN=(WHEN=(21,4,CH,EQ,C'HEDR',OR,21,4,CH,EQ,C'TRLR'),
                       OVERLAY=(37:DATE1(-)+30))
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(21,4,CH,EQ,C'HEDR',OR,21,4,CH,EQ,C'TRLR'),
                       BUILD=(1,36,42,5,C'-',37,4,47:47))

This would add 30 days to the current date and replace the date as required.
_________________
Saro

Nothing is great unless God.
Back to top
View user's profile Send private message
Deepthi
Beginner


Joined: 20 Aug 2005
Posts: 27
Topics: 6
Location: MN

PostPosted: Thu Feb 25, 2010 6:26 am    Post subject: Reply with quote

Hi,

I have a similar requirement. I run a job once in a month.
I need the month in the header to be changed to the next month value everytime I run the job. When I run the job in December, the year as well should change to next year value along with the month.
DD part of MM-DD-YYYY should not change.

I designed the following sort card considering the same criteria mentioned above. But wanted to know if there was any further simplication that can be done.

Code:

OUTREC IFTHEN=(WHEN=((21,4,CH,EQ,C'HEDR',OR,21,4,CH,EQ,C'TRLR'), AND,
                                     (37,2,CH,EQ,NE,C'12')),
                       BUILD=(1,36,37,2,CHANGE=(2,C'01',C'02',C'02',C'03',C'03',C'04',
                                                                     C'04',C'05',C'05',C'06',C'06',C'07',
                                                                     C'07', C'08',C'08',C'09',C'09',C'10',
                                                                     C'10',C'11',C'11',C'12'),39:39)),
             IFTHEN=(WHEN=((21,4,CH,EQ,C'HEDR',OR,21,4,CH,EQ,C'TRLR'), AND,
                                     (37,2,CH,EQ,EQ,C'12')),
                       BUILD=(1,36,'01',39,4,43,4,ZD,ADD,+1,M11,LENGTH=4,47:47))

_________________
Thanks,
Deepthi.

Our lives begin to end the day we become silent about things that matter.
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 Feb 25, 2010 12:38 pm    Post subject: Reply with quote

Deepthi,

You really don't have to use the CHANGE command for changing the month. You can use DATE2 format(YYYYMM) format. YYYY is current year and MM is current month and you can use DATE2+1 which will give you next month.

Saro's control cards are for VB file. Do you also have the same file attributes?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Deepthi
Beginner


Joined: 20 Aug 2005
Posts: 27
Topics: 6
Location: MN

PostPosted: Fri Feb 26, 2010 6:10 am    Post subject: Reply with quote

Hi Kolusu,

Yes mine is also a VB file. The date format is in MM-DD-YYYY format. If I use a YYYYMM format, how would it help? Would it not replace the DD? I need to retain the same DD value in my header. Can you please post the code for the same?

Thanks,
_________________
Thanks,
Deepthi.

Our lives begin to end the day we become silent about things that matter.
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: Fri Feb 26, 2010 11:57 am    Post subject: Reply with quote

Deepthi,


The following DFSORT JCL will give you the desired results. This will put MM-DD-YYYY in position 37 (inclusive of RDW) and it retains the DD value. However remember that you may end up with an invalid date as the 01-30-2010 would be translated to 02-30-2010 which is invalid date.

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=Your input vb file,DISP=SHR
//SORTOUT  DD SYSOUT=*,LRECL=nnn                                     
//SYSIN    DD *                                                       
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=(21,4,SS,EQ,C'HEDR,TRLR'),BUILD=(1,4,DATE2+1,5))
  OUTREC IFTHEN=(WHEN=(27,4,SS,EQ,C'HEDR,TRLR'),                     
  BUILD=(1,4,11,32,9,2,45,4,5,4,53))                                 
//*

change LRECL=nnn to actual file length

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


Joined: 20 Aug 2005
Posts: 27
Topics: 6
Location: MN

PostPosted: Mon Mar 01, 2010 2:57 am    Post subject: Reply with quote

Thanks Kolusu Smile
_________________
Thanks,
Deepthi.

Our lives begin to end the day we become silent about things that matter.
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