View previous topic :: View next topic
Author
Message
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi, we use Syncsort for z/OS v1.3.2. We receive a file (LRECL=80,RECFM=FB) with dates in it in CCYYMMDD format and need to check whether it belongs to Monday or Sunday.
Input:
Code:
20121008 20121014
20121023 20121028
20121105 20121113
As you could see, dates in 1st record belong to Monday and Sunday but in 2nd record start date is not Monday while end date is Sunday. In 3rd record, start date is Monday while end date is not Sunday. Is it possible to check the given dates and correct them to have Monday dates in start date and Sunday dates in end dates a week.
Expected Output:
Code:
20121008 20121014
20121022 20121028
20121105 20121112
Please help. Thanks.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
What if they are neither Monday nor Sunday?
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19243 Location: Inside the Matrix
Hello,
What if the dates are more than 6 days apart?
What if both dates are a Monday (or Friday)?
Back to top
Akatsukami Global Moderator Joined: 03 Oct 2009Posts: 1787 Location: Bloomington, IL
Bill Woodger wrote:
What if they are neither Monday nor Sunday?
If I understand the TS correctly, heesh is stating:
If date #1 does not fall on a Monday, change it to the latest date before it that does fall on a Monday
If date #2 does not fall on a Sunday, change it to the earliest date after date #1 that does fall on a Sunday.
Hi, Opal!
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Well, if first date is a Monday, then 2nd date should be following Sunday.
If 2nd date is a Sunday, then first date should be the previous Monday.
So, if the first date is not a Monday AND the second date is not a Sunday....
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19243 Location: Inside the Matrix
Hello,
Looks like (to me) that even if something is implemented, it may not fill the actual need . . .
Back to top
Akatsukami Global Moderator Joined: 03 Oct 2009Posts: 1787 Location: Bloomington, IL
Bill Woodger wrote:
Well, if first date is a Monday, then 2nd date should be following Sunday.
If 2nd date is a Sunday, then first date should be the previous Monday.
So, if the first date is not a Monday AND the second date is not a Sunday....
I agree with Mr. Scherrer that the requirement needs clarification. However, if the two rules ("Hi, Opal!" can be disregarded for this effort ) are applied sequentially, I believe that they will cover all cases, even if the result is not always if desired.
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Quote:
Well, if first date is a Monday, then 2nd date should be following Sunday.
If 2nd date is a Sunday, then first date should be the previous Monday.
So, if the first date is not a Monday AND the second date is not a Sunday....
Bill Woodger got me right.....Is it possible to achieve it in SYNCSORT?
Thanks.
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Started experimenting by doing this but don't get satisfactory results
Code:
//STEP0001 EXEC PGM=SORT
//SORTIN DD *
20121106 20121111
//SYSIN DD *
OPTION COPY
OUTREC FIELDS=(1:12,6,Y2T,SUB,+6)
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
Output:
Code:
********************************* TOP OF DATA **********************************
20121105
******************************** BOTTOM OF DATA ********************************
Don't know why it does not sit at 1st position though I used "1:" in outrec Must be heading in wrong direction
Thanks.
Back to top
prino Senior Member Joined: 07 Feb 2009Posts: 1311 Location: Vilnius, Lithuania
Round holes and square pegs...
How long would it have take you to do this in PL/I, Cobol or REXX?
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Every time you do a calculation, if you do not specify a length for the result, you get the default length. The default length is 15 bytes.
Back to top
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10879 Location: italy
seems that the trend is reversed now,
up to a certain time nobody was aware/was using the advanced sort capabilities
and a program was written even for a simple reformatting
now it is the other way around , sort, alway sort, forever sort
just wondering about ...
non auditability of <sort> processes ,
( no hardcopy track of changes )
<sort>s going thru the JCL promotion/approval process
rather than the APPLICATION DEVELOPMENT one
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19243 Location: Inside the Matrix
Hi Enrico,
Quote:
<sort>s going thru the JCL promotion/approval process
rather than the APPLICATION DEVELOPMENT one
Oh, yes. . .
Far too many places have allowed this to speed up the promotion process
Many of my clients have no rules for documenting the "code" in sort-grams or other utility processes. Once upon a time the sort basically sorted stuff and maybe tossed duplicates. Maybe not much of an issue then. Now business rules are being implemented this way as well as "batch spufi" that gets around the the need for a database review of a new process or fix-it. . .
Oh, well . . .
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
don't know PL/I or REXX.....
Bill, got results with your suggestion.....
Code:
//STEP0001 EXEC PGM=SORT
//SORTIN DD *
20121106 20121111
//SYSIN DD *
OPTION COPY
OUTREC FIELDS=(1:12,6,Y2T,SUB,+6,LENGTH=9)
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
Any other suggestion on how do I check for Monday/Sunday?
Thanks.
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19243 Location: Inside the Matrix
Hello,
Quote:
don't know PL/I or REXX.....
Then COBOL may be the way for you to go . . .
Back to top
Akatsukami Global Moderator Joined: 03 Oct 2009Posts: 1787 Location: Bloomington, IL
prino wrote:
How long would it have take you to do this in PL/I, Cobol or REXX?
(name decently suppressed) wrote:
don't know PL/I or REXX.....
I suggest that this states the reason, not only the existence of this thread, but for 99% of help boards.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Ramsri,
How about this one?
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
I doubt your date calculation is working, try this as an input
What is your result now ? Is it a valid date ?
The result I get is
Gerry
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Hi Gerry,
Which calculation?
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi Bill,
Code:
OUTREC FIELDS=(1:12,6,Y2T,SUB,+6)
Gerry
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Thanks Gerry. I was fearing I'd have to look at the other one :-)
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Bill, thanks for the links.
Gerry, why would I subtract greater (20121106) value from lesser (20121101) value
Thanks.
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Gerry, but I tried below values and got an invalid date
Sort:
Code:
//STEP0001 EXEC PGM=SORT
//SORTIN DD *
20121126 20121202
//SYSIN DD *
OPTION COPY
OUTREC FIELDS=(1:12,6,Y2T,SUB,+6)
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
Output:
Code:
********************************* TOP OF DATA **********************************
20121196
******************************** BOTTOM OF DATA ********************************
Thanks.
Back to top
bodatrinadh Active User Joined: 05 Jan 2007Posts: 101 Location: chennai (India)
Hi Ramsri
Quote:
Bill Woodger got me right.....Is it possible to achieve it in SYNCSORT?
It can be achieved in SYNCSORT 1.4.0.1R.. Not sure in 1.3.2...
The below code will give you Day for your Date Vales...
Code:
//STEP010 EXEC PGM=SORT
//SORTIN DD *
20121008 20121014
20121023 20121028
20121105 20121113
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY(21:7,2,23:5,2,25:1,4,61:16,2,63:14,2,65:10,4,
29:(21,2,ZD,
ADD,
((+26,MUL,(23,2,ZD,ADD,+1)),DIV,+10),
ADD,
25,4,ZD,
ADD,
(25,4,ZD,DIV,+4),
ADD,
(+6,MUL,(25,4,ZD,DIV,+100)),
ADD,
(25,4,ZD,DIV,+400)),MOD,+7,
69:(61,2,ZD,
ADD,
((+26,MUL,(63,2,ZD,ADD,+1)),DIV,+10),
ADD,
65,4,ZD,
ADD,
(65,4,ZD,DIV,+4),
ADD,
(+6,MUL,(65,4,ZD,DIV,+100)),
ADD,
(65,4,ZD,DIV,+400)),MOD,+7,
80:X)),
IFTHEN=(WHEN=(5,2,ZD,EQ,1,OR,5,2,ZD,EQ,2),
OVERLAY(21:7,2,23:5,2,ZD,ADD,+12,TO=ZD,LENG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EN=(WHEN=(83,1,ZD,EQ,3),
OVERLAY=(25:C'TUE ')),
IFTHEN=(WHEN=(83,1,ZD,EQ,4),
OVERLAY=(25:C'WED ')),
IFTHEN=(WHEN=(83,1,ZD,EQ,5),
OVERLAY=(25:C'THU ')),
IFTHEN=(WHEN=(83,1,ZD,EQ,6),
OVERLAY=(25:C'FRI '))
Output :-
Code:
MON 20121008 20121014 SUN
TUE 20121023 20121028 SUN
MON 20121105 20121113 TUE
2. This Step will give your desire output...
Code:
//*
//STEP010 EXEC PGM=SORT
//SORTIN DD *
MON 20121008 20121014 SUN
TUE 20121023 20121028 SUN
MON 20121105 20121113 TUE
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'TUE'),
OVERLAY=(1:C'MON ',5:DATEADD=(5,8,DTNS=(4MD),-1,DAY))),
IFTHEN=(WHEN=(25,3,CH,EQ,C'TUE'),
OVERLAY=(25:C'MON ',14:DATEADD=(14,8,DTNS=(4MD),-1,DAY)))
SORT FIELDS=COPY
Output:-
Code:
MON 20121008 20121014 SUN
MON 20121022 20121028 SUN
MON 20121105 20121112 MON
Note :- The above code is tested on SYNCSORT FOR Z/OS 1.4.0.1R
Thanks
-3nadh
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi 3nadh, Thank you very much.
Got the results with 1st solution you've provided
2nd solution failed because we are still at SYNCSORT FOR Z/OS 1.3.2.2R
Code:
SYSIN :
INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'TUE'),
OVERLAY=(1:C'MON ',5:DATEADD=(5,8,DTNS=(4MD),-1,DAY))),
*
IFTHEN=(WHEN=(25,3,CH,EQ,C'TUE'),
OVERLAY=(25:C'MON ',14:DATEADD=(14,8,DTNS=(4MD),-1,DAY)))
SORT FIELDS=COPY
WER268A INREC STATEMENT : SYNTAX ERROR
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
Wish you a great and bright Diwali.
Back to top
Please enable JavaScript!