Joined: 20 Aug 2005 Posts: 11 Topics: 1 Location: chennai
Posted: Tue Feb 23, 2010 4:22 am Post subject: Date updation
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.
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Tue Feb 23, 2010 11:10 am Post subject:
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))
//*
Joined: 20 Aug 2005 Posts: 27 Topics: 6 Location: MN
Posted: Thu Feb 25, 2010 6:26 am Post subject:
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.
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Thu Feb 25, 2010 12:38 pm Post subject:
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
Joined: 20 Aug 2005 Posts: 27 Topics: 6 Location: MN
Posted: Fri Feb 26, 2010 6:10 am Post subject:
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.
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Fri Feb 26, 2010 11:57 am Post subject:
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.
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