Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed Mar 23, 2005 2:41 pm Post subject:
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 assumed that your input file is of FB recfm and has an LRECL of 80 bytes. The date field(CCYYMMDD) starts at pos 1.
A brief explanation of the job.calculating the no:of days in julian format needs the year portion to be checked for a leap year. Once you figure that out it is very easy to calculate the julian date.
So we take the year and divide it by 4,100 and 400 and get the remainder on the inrec fields.
Now using a change command on OUTREC FIELDS we change the remainder to "L" if the remainder is a zero. we also add the max date of every month as a single string at the end of every record. We also subtract 1 from the month of the date field.
Using another change command on the OUTFIL OUTREC, we change the max date of february from 28 to 29 if the year is a leap year.
using another change command on the OUTFIL OUTREC, we add a series of '1's and '0's depending on the month.
for ex:
Code:
MONTH Max date
Jan 31
Feb 28/29
Mar 31
Apr 30
May 31
Jun 30
Jul 31
Aug 31
Sep 30
Oct 31
Nov 30
Dec 31
Let us take current date as example. today is 2005-03-23. So subtracting 1 from month portion results in 2. so need to add up the max date of jan and feb and days in march to get the day of the year.
so we create a string of 0's and 1's depending on the month for a length of 12 bytes.
The next copy step , now multiples this string with max date of everymonth and adds them up together. It also adds the days of the date field to get the day of the year.
Thanks Kolusu for your prompt solution. atleast it gave me some direction but Its looks very lengthy. actually i need to convert 3 dates at a go into yyyyddd format. I will have to repeat this for all these dates indivisually. I am wondering if we can do this with one control card and with less calculations.. may be frank would like to do this with MOD.
01 S-EOF-INFILE PIC X(01) VALUE 'N'.
01 WS-JULIAN-DATE PIC 9(07).
PROCEDURE DIVISION.
PERFORM 1000-INITIALIZATION
PERFORM 2000-GET-JULIAN-DATE UNTIL S-EOF-INFILE = 'Y'
CLOSE INFILE
GOBACK
.
1000-INITIALIZATION.
*************************************************************
*THIS PARAGRAPH OPENS AND DOES THE PRIME READ OF THE FILES. *
*************************************************************
OPEN INPUT INFILE
PERFORM 3000-READ-INFILE
.
2000-GET-JULIAN-DATE.
*************************************************************
*THIS PARAGRAPH GETS THE JULIAN DATE FOR THE GREGORIAN DATE.*
*************************************************************
INITIALIZE WS-JULIAN-DATE
COMPUTE WS-JULIAN-DATE = FUNCTION DAY-OF-INTEGER
(FUNCTION INTEGER-OF-DATE
(IN-DATE))
DISPLAY 'THE JULIAN DATE IS : ' WS-JULIAN-DATE
PERFORM 3000-READ-INFILE
.
3000-READ-INFILE.
*************************************************************
*THIS PARAGRAPH IS PERFORMED TO READ THE INPUT FILE. *
*************************************************************
READ INFILE
AT END
MOVE 'Y' TO S-EOF-INFILE
END-READ
.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Mon Nov 16, 2009 2:26 pm Post subject:
With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707, you can use the new date conversion function TOJUL like shown below to get the desired results
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