|
View previous topic :: View next topic
|
| Author |
Message |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Hello,
I have a input file with
Record format . . . : FB
Record length . . . : 9
INPUT FILE:
| Code: |
20080101
20080102
20080103
20080104
20080105
20080106
20080107
20080108
20080109
20080110
20080111
20080112
20080113 |
I need to create the output file with
Record format . . . : FB
Record length . . . : 9
OUTPUT FILE:
| Code: |
001311111
80CCCCCCC
---------
<
002411111
80CCCCCCC
---------
*
003511111
80CCCCCCC
---------
<%
004611111
80CCCCCCC |
Rules:
The input file will always contain 600 records as dates in YYYYMMDD format(giorgian format).I need to create the output file in YYDDD format(julian format) appended with day i.e. 1 to 7 where 1=sunday, 2=monday....7=saturday.
After that the five digits(column 5 to 10) corresponds to holiday flags in five different states(S1,S2,S3,S4,S5) for the following days which may not be present in the input file. If its holiday (including saturday sunday) then it should be flagged with 0 and if its not a holiday then it should be 1.
list of holiday:
1st JAN all the states(S1,S2,S3,S4,S5)
26th JAN all the states(S1,S2,S3,S4,S5)
2nd march for S5
9th march s3
10th april all the states(S1,S2,S3,S4,S5)
13th april all the states(S1,S2,S3,S4,S5)
25ht april all the states(S1,S2,S3,S4,S5)
4th may for S2
1st june for S5
8th june for S1,S2,S3,S4
28th sep for S5
5th oct for S2 and S4
2nd Nov for S3
25th Dec all the states(S1,S2,S3,S4,S5)
26th Dec all the states(S1,S2,S3,S4,S5).
For eg for 1st june the output records should be:
| Code: |
013100000
85CCCCCCC
012211110
95CCCCCCC |
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Quote: |
| After that the five digits(column 5 to 10) corresponds to holiday flags in five different states(S1,S2,S3,S4,S5) for the following days which may not be present in the input file. If its holiday (including saturday sunday) then it should be flagged with 0 and if its not a holiday then it should be 1. |
Rajatbagga,
The output you show does NOT match the requirements. take the first record.20080101( January 1st) is indeed a holiday and yet you show the 5 flags as 1. It should be zeros.
Assuming that it is a typo then the following DFSORT JCL will give you the desired results.
| Code: |
//STEP0100 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=your 9 byte input file,
// DISP=SHR
//SORTOUT DD DSN=Your output 9 byte file,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
OPTION COPY,NOSZERO,SDB=YES
INREC IFTHEN=(WHEN=INIT,OVERLAY=(11:01,04,ZD,MOD,+4,EDIT=(T),
12:01,04,ZD,MOD,+100,EDIT=(TTT),15:01,04,ZD,MOD,+400,EDIT=(TTT))),
IFTHEN=(WHEN=(15,3,ZD,EQ,0,OR,(11,1,ZD,EQ,0,AND,12,3,ZD,GT,0)),
OVERLAY=(18:C'L'),HIT=NEXT),
IFTHEN=(WHEN=(05,02,ZD,EQ,01),
OVERLAY=(20:3,2,7,2,ZD,EDIT=(TTT),
30:+01,SUB,01,04,ZD,EDIT=(TTTT),
34:+10,ADD,05,02,ZD,EDIT=(TT))),
IFTHEN=(WHEN=(05,02,ZD,EQ,02),
OVERLAY=(20:3,2,+031,ADD,07,02,ZD,EDIT=(TTT),
30:+01,SUB,01,04,ZD,EDIT=(TTTT),
34:+10,ADD,05,02,ZD,EDIT=(TT))),
IFTHEN=(WHEN=(05,02,ZD,EQ,03),
OVERLAY=(20:3,2,+059,ADD,07,02,ZD,EDIT=(TTT),
30:01,04,34:+02,SUB,05,02,ZD,EDIT=(TT))),
IFTHEN=(WHEN=(05,02,ZD,EQ,04),
OVERLAY=(20:3,2,+090,ADD,07,02,ZD,EDIT=(TTT),
30:01,04,34:+02,SUB,05,02,ZD,EDIT=(TT))),
IFTHEN=(WHEN=(05,02,ZD,EQ,05),
OVERLAY=(20:3,2,+120,ADD,07,02,ZD,EDIT=(TTT),
30:01,04,34:+02,SUB,05,02,ZD,EDIT=(TT))),
IFTHEN=(WHEN=(05,02,ZD,EQ,06),
OVERLAY=(20:3,2,+151,ADD,07,02,ZD,EDIT=(TTT),
30:01,04,34:+02,SUB,05,02,ZD,EDIT=(TT))),
IFTHEN=(WHEN=(05,02,ZD,EQ,07),
OVERLAY=(20:3,2,+181,ADD,07,02,ZD,EDIT=(TTT),
30:01,04,34:+02,SUB,05,02,ZD,EDIT=(TT))),
IFTHEN=(WHEN=(05,02,ZD,EQ,08),
OVERLAY=(20:3,2,+212,ADD,07,02,ZD,EDIT=(TTT),
30:01,04,34:+02,SUB,05,02,ZD,EDIT=(TT))),
IFTHEN=(WHEN=(05,02,ZD,EQ,09),
OVERLAY=(20:3,2,+243,ADD,07,02,ZD,EDIT=(TTT),
30:01,04,34:+02,SUB,05,02,ZD,EDIT=(TT))),
IFTHEN=(WHEN=(05,02,ZD,EQ,10),
OVERLAY=(20:3,2,+273,ADD,07,02,ZD,EDIT=(TTT),
30:01,04,34:+02,SUB,05,02,ZD,EDIT=(TT))),
IFTHEN=(WHEN=(05,02,ZD,EQ,11),
OVERLAY=(20:3,2,+304,ADD,07,02,ZD,EDIT=(TTT),
30:01,04,34:+02,SUB,05,02,ZD,EDIT=(TT))),
IFTHEN=(WHEN=(05,02,ZD,EQ,12),
OVERLAY=(20:3,2,+334,ADD,07,02,ZD,EDIT=(TTT),
30:01,04,34:+02,SUB,05,02,ZD,EDIT=(TT)))
OUTREC IFTHEN=(WHEN=INIT,
OVERLAY=(40:30,4,ZD,DIV,+100,EDIT=(TTTT),
44:30,4,ZD,MOD,+100,EDIT=(TT),
47:((+26,MUL,34,2,ZD),SUB,+2),DIV,+10,LENGTH=8,
55:47,8,SFF,ADD,07,02,ZD,ADD,44,2,ZD,LENGTH=8,
63:55,8,SFF,ADD,(44,2,ZD,DIV,+4),ADD,
(40,4,ZD,DIV,+4),LENGTH=8,
71:(63,8,SFF,SUB,
(+2,MUL,40,4,ZD)),MOD,+7,LENGTH=8)),
IFTHEN=(WHEN=(18,1,CH,EQ,C'L',AND,05,2,ZD,GT,2),
OVERLAY=(22:+1,ADD,22,03,ZD,EDIT=(TTT)),HIT=NEXT),
IFTHEN=(WHEN=(71,8,SFF,LT,0),
OVERLAY=(80:+7,ADD,71,8,SFF,EDIT=(T)),HIT=NEXT),
IFTHEN=(WHEN=(71,8,SFF,GE,0),OVERLAY=(80:71,8,SFF,EDIT=(T)))
OUTFIL IFOUTLEN=9,
IFTHEN=(WHEN=INIT,BUILD=(20,5,ZD,PD,LENGTH=3,
+1,ADD,80,1,ZD,PD,LENGTH=1,5X'1C',1,8)),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0101',OR,14,4,CH,EQ,C'0126',OR,
14,4,CH,EQ,C'0410',OR,14,4,CH,EQ,C'0413',OR,
14,4,CH,EQ,C'0425',OR,14,4,CH,EQ,C'1225',OR,
14,4,CH,EQ,C'1226',OR,4,1,PD,EQ,1,OR,4,1,PD,EQ,7),
OVERLAY=(5:5X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0302'),OVERLAY=(9:X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0309'),OVERLAY=(7:X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0504'),OVERLAY=(6:X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0601'),OVERLAY=(9:X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0608'),OVERLAY=(5:4X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0928'),OVERLAY=(9:X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'1005'),OVERLAY=(6:X'0C',8:X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'1102'),OVERLAY=(7:X'0C'))
/*
|
Hope this helps...
Cheers |
|
| Back to top |
|
 |
Ramya A
Active User

Joined: 26 Jul 2004 Posts: 104
|
|
|
|
Hi Kolusu,
It would be really great if you could briefly explain the logic used in the above sort card. Thanks. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Ramya Arun,
The INREC processing converts the gregorian date to julian date by checking it is a leap year.
The dayname calculation(OUTREC processing) is based on the zellers congruence formulla. You can find more information on google.
| Code: |
//** 00 = SUNDAY 01 = MONDAY 02 = TUESDAY 03 = WEDNESDAY **
//** 04 = THURSDAY 05 = FRIDAY 06 = SATURDAY **
|
The psuedo code for the dayname calculation is
| Code: |
//*********************************************************************
//** **
//** IF IN-MONTH < 3 **
//** SUBTRACT 1 FROM IN-YEAR **
//** ADD 10 TO IN-MONTH **
//** ELSE **
//** SUBTRACT 0 FROM IN-YEAR **
//** SUBTRACT 2 FROM IN-MONTH **
//** END-IF **
//** **
//** DIVIDE IN-YEAR BY 100 GIVING IN-CENTURY REMAINDER IN-YEAR **
//** **
//** COMPUTE IN-TEMP = ((26 * IN-MONTH) - 2) / 10. **
//** **
//** COMPUTE IN-TEMP = IN-TEMP + IN-DAY + IN-YEAR. **
//** **
//** COMPUTE IN-TEMP = IN-TEMP + **
//** (IN-YEAR / 4) + **
//** (IN-CENTURY / 4) **
//** **
//** **
//** COMPUTE IN-TEMP = IN-TEMP - (2 * IN-CENTURY). **
//** **
//** DIVIDE IN-TEMP BY 7 GIVING IN-TEMP REMAINDER IN-DOW. **
//** **
//** IF IN-DOW < 0 **
//** ADD 7 TO IN-DOW **
//** END-IF. **
//** **
//** DISPLAY 'DAY NAME : ' IN-DOW **
//** **
//*********************************************************************
|
The outfil uses a bunch of IFTHEN's to populate the holiday flags |
|
| Back to top |
|
 |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Hi Skolusu,
Thanks a lot you are a Genius. I need one more favour regarding this, Kindly let me know how can I create the above input file starting form date 20080101 till 600 days. I mean from 20080101 to 20090822 by writing a JCL intself.
Thanks,
Rajat |
|
| Back to top |
|
 |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Hello Skolusu,
After submiting the JOB posted by you I got the below output.
| Code: |
000001
001300000
80FCCCCCC
-----------------
000002 <
002411111
80FCCCCCC
-----------------
000003 *
003511111
80FCCCCCC
-----------------
000004 |%
004611111
80FCCCCCC
-----------------
000005 ¬@
005700000
80FCCCCCC |
the output i wanted was:
| Code: |
000001
001300000
80CCCCCCC
----------------
000002 <
002411111
80CCCCCCC
----------------
000003 *
003511111
80CCCCCCC
----------------
000004 <%
004611111
80CCCCCCC
----------------
000005 *@
005700000
80CCCCCCC |
Eveything is exacly same but If i compare the two outputs carefully then in the lines 80FCCCCCC letter F is not there, it should be like 80CCCCCCC. Can you please let me know how can i rectify this. |
|
| Back to top |
|
 |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Hello Skolusu
| rajatbagga wrote: |
After submiting the JOB posted by you I got the below output.
| Code: |
000001
001300000
80FCCCCCC
-----------------
000002 <
002411111
80FCCCCCC
-----------------
000003 *
003511111
80FCCCCCC
-----------------
000004 |%
004611111
80FCCCCCC
-----------------
000005 ¬@
005700000
80FCCCCCC |
the output i wanted was:
| Code: |
000001
001300000
80CCCCCCC
----------------
000002 <
002411111
80CCCCCCC
----------------
000003 *
003511111
80CCCCCCC
----------------
000004 <%
004611111
80CCCCCCC
----------------
000005 *@
005700000
80CCCCCCC |
Eveything is exacly same but If i compare the two outputs carefully then in the lines 80FCCCCCC letter F is not there, it should be like 80CCCCCCC. Can you please let me know how can i rectify this. |
I rectified this problem by using
| Code: |
| IFTHEN=(WHEN=INIT,BUILD=(+0,ADD,20,5,ZD,PD,LENGTH=3, |
Instead of using
| Code: |
| IFTHEN=(WHEN=INIT,BUILD=(20,5,ZD,PD,LENGTH=3, |
Now Kindly let me know how can I create the above input file(mentioned in my first post) starting form date 20080101 till 600 days. I mean from 20080101 to 20090822 by writing a JCL itself. |
|
| Back to top |
|
 |
karthikr44
Active User

Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
hi rajatbagga,
Use IEBDG utility for test data setup and modify the below JCL according to ur requirements, Refer IEBDG manuals for more information,
//JSTP0010 EXEC PGM=IEBDG
//SYSPRINT DD SYSOUT=*
//INFIL DD DSN=DEV2.USDSEMGC.CTLGGRP.SRT.TS032,DISP=SHR,
// DCB=(RECFM=FB,LRECL=200)
//OUT DD DSN=DEV2.USDSEMGC.CTLGGRP.TS032,
// DISP=(NEW,CATLG),
// VOL=SER=TSOPK,SPACE=(CYL,(10,1)),
// DCB=(RECFM=FB,LRECL=200,BLKSIZE=2000)
//SYSIN DD *
DSD OUTPUT=(OUT),INPUT=(INFIL)
FD NAME=FIELD1,LENGTH=02,STARTLOC=29,PICTURE=2,'AR'
CREATE QUANTITY=63,INPUT=INFIL,NAME=(FIELD1)
END
/* |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
I rectified this problem by using
IFTHEN=(WHEN=INIT,BUILD=(+0,ADD,20,5,ZD,PD,LENGTH=3,
Instead of using
IFTHEN=(WHEN=INIT,BUILD=(20,5,ZD,PD,LENGTH=3, |
Kolusu's job gives the results you wanted with DFSORT. If you had to do what you said to get the correct results, then you're using Syncsort (WER messages), not DFSORT (ICE messages). DFSORT uses a C sign for conversion to PD. Syncsort uses an F sign for conversion to PD.
Since you're not using DFSORT, please don't post in the DFSORT Forum. Kolusu and I are DFSORT developers. DFSORT and Syncsort are competitive products. We're happy to answer questions on DFSORT and DFSORT's ICETOOL, but we don't answer questions on Syncsort. |
|
| Back to top |
|
 |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Hello Frank,
Actully this was required at two of my mainframe sites one uses DFSORT and other uses SYNCSORT.
The results coming with DFSORT were perfect. I stimulated the same code with syncsort as well and its working fine now.
Can you please let me know how can I create the above input file(mentioned in my first post) starting form date 20080101 till 600 days. I mean from 20080101 to 20090822 by writing a DFSORT JCL itself.
Regards,
Rajat |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
rajatbagga,
The following DFSORT JCL will create a 9 byte file of dates starting from Jan 1st of the current year followed by the next 600 days.
| Code: |
//STEP0100 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
CURYR,S'&YR4.'
//SORTIN DD *
DUMMY RECORD
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,BUILD=(CURYR,20:X)),
IFTHEN=(WHEN=INIT,
OVERLAY=(11:01,04,ZD,MOD,+4,EDIT=(T),
12:01,04,ZD,MOD,+100,EDIT=(TTT),
15:01,04,ZD,MOD,+400,EDIT=(TTT))),
IFTHEN=(WHEN=(15,3,ZD,EQ,0,OR,
(11,1,ZD,EQ,0,AND,12,3,ZD,GT,0)),
OVERLAY=(18:C'L'))
OUTFIL REPEAT=600,IFOUTLEN=9,
IFTHEN=(WHEN=INIT,BUILD=(1,4,SEQNUM,3,ZD,10X,18:18,1)),
IFTHEN=(WHEN=(18,1,CH,EQ,C' ',AND,5,3,ZD,GT,365),
OVERLAY=(+635,ADD,1,7,ZD,M11,LENGTH=7),HIT=NEXT),
IFTHEN=(WHEN=(18,1,CH,EQ,C'L',AND,5,3,ZD,GT,366),
OVERLAY=(+634,ADD,1,7,ZD,M11,LENGTH=7),HIT=NEXT),
IFTHEN=(WHEN=(8,1,CH,EQ,C' '),
OVERLAY=(10:X'01',3,5,ZD,TO=PD,LENGTH=3),HIT=NEXT),
IFTHEN=(WHEN=(9,1,CH,EQ,C' '),
OVERLAY=(01:10,4,DT1,EDIT=(TTTTTTTT)))
/*
|
Hope this helps...
Cheers |
|
| Back to top |
|
 |
rajatbagga
Active User

Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Hello Kolusu,
Thanks a million, its working perfectly fine.....  |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707 (Nov, 2009), you can now use WEEKDAY date functions to calculate the day of the week and also holidays as shown below
| Code: |
//STEP0100 EXEC PGM=SORT
//SORTIN DD DSN=your 9 byte input file,
// DISP=SHR
//SORTOUT DD DSN=Your output 9 byte file,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
INREC IFOUTLEN=9,IFTHEN=(WHEN=INIT,
BUILD=(1,8,Y4T,TOJUL=Y2U,1,8,Y4T,WEEKDAY=DIGIT1,5X'1C',1,8)),
IFTHEN=(WHEN=INIT,OVERLAY=(4:4,1,ZD,PD,LENGTH=1)),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0101',OR,14,4,CH,EQ,C'0126',OR,
14,4,CH,EQ,C'0410',OR,14,4,CH,EQ,C'0413',OR,
14,4,CH,EQ,C'0425',OR,14,4,CH,EQ,C'1225',OR,
14,4,CH,EQ,C'1226',OR,4,1,PD,EQ,1,OR,4,1,PD,EQ,7),
OVERLAY=(5:5X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0302'),OVERLAY=(9:X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0309'),OVERLAY=(7:X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0504'),OVERLAY=(6:X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0601'),OVERLAY=(9:X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0608'),OVERLAY=(5:4X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'0928'),OVERLAY=(9:X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'1005'),OVERLAY=(6:X'0C',8:X'0C')),
IFTHEN=(WHEN=(14,4,CH,EQ,C'1102'),OVERLAY=(7:X'0C'))
//*
|
With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707 (Nov, 2009), you can now use TOJUL/TOGREG date functions to generate a 9 byte file of dates starting from Jan 1st of the current year followed by the next 600 days.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYMNAMES DD *
CURYR,S'&YR4.'
//SYSOUT DD SYSOUT=*
//SORTIN DD *
DUMMY RECORD
//SORTOUT DD DSN=Your output 9 byte file,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,BUILD=(CURYR,C'1231')),
IFTHEN=(WHEN=INIT,OVERLAY=(10:1,8,Y4T,TOJUL=Y4T))
OUTFIL REPEAT=600,IFOUTLEN=9,
IFTHEN=(WHEN=INIT,BUILD=(1,4,SEQNUM,3,ZD,10:10,7)),
IFTHEN=(WHEN=(1,7,ZD,GT,10,7,ZD),
OVERLAY=(1:1,4,ZD,ADD,+1,EDIT=(TTTT),
5,3,ZD,SUB,14,3,ZD,EDIT=(TTT)),HIT=NEXT),
IFTHEN=(WHEN=(1,1,CH,GT,C' '),BUILD=(1,7,Y4T,TOGREG=Y4T))
//* |
For complete details on WEEKDAY/TOJUL/TOGREG and the other new functions available with the Nov, 2009 DFSORT PTF, see:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174 |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|