Syncsort - dates must be Monday and Sunday.

Author Message
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

Posted: Wed Nov 07, 2012 11:41 pm

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

Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

 Posted: Thu Nov 08, 2012 12:09 am What if they are neither Monday nor Sunday?
dick scherrer

Moderator Emeritus

Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

 Posted: Thu Nov 08, 2012 12:26 am Hello, What if the dates are more than 6 days apart? What if both dates are a Monday (or Friday)?
Akatsukami

Global Moderator

Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

Posted: Thu Nov 08, 2012 12:27 am

 Bill Woodger wrote: What if they are neither Monday nor Sunday?

If I understand the TS correctly, heesh is stating:
1. If date #1 does not fall on a Monday, change it to the latest date before it that does fall on a Monday
2. If date #2 does not fall on a Sunday, change it to the earliest date after date #1 that does fall on a Sunday.
3. Hi, Opal!
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

 Posted: Thu Nov 08, 2012 12:43 am 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....
dick scherrer

Moderator Emeritus

Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

 Posted: Thu Nov 08, 2012 1:08 am Hello, Looks like (to me) that even if something is implemented, it may not fill the actual need . . .
Akatsukami

Global Moderator

Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

Posted: Thu Nov 08, 2012 2:32 am

 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.
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

Posted: Thu Nov 08, 2012 7:55 am

 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.
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

Posted: Thu Nov 08, 2012 8:47 am

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.
prino

Senior Member

Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

 Posted: Thu Nov 08, 2012 2:56 pm Round holes and square pegs... How long would it have take you to do this in PL/I, Cobol or REXX?
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

 Posted: Thu Nov 08, 2012 3:08 pm 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.
enrico-sorichetti

Superior Member

Joined: 14 Mar 2007
Posts: 10873
Location: italy

 Posted: Thu Nov 08, 2012 3:22 pm 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 processes , ( no hardcopy track of changes ) s going thru the JCL promotion/approval process rather than the APPLICATION DEVELOPMENT one
dick scherrer

Moderator Emeritus

Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

Posted: Thu Nov 08, 2012 8:00 pm

Hi Enrico,

 Quote: 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 . . .
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

Posted: Thu Nov 08, 2012 8:16 pm

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.
dick scherrer

Moderator Emeritus

Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

Posted: Thu Nov 08, 2012 8:24 pm

Hello,

 Quote: don't know PL/I or REXX.....
Then COBOL may be the way for you to go . . .
Akatsukami

Global Moderator

Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

Posted: Thu Nov 08, 2012 8:26 pm

 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.
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

gcicchet

Senior Member

Joined: 28 Jul 2006
Posts: 1702
Location: Australia

Posted: Fri Nov 09, 2012 3:11 am

Hi,

I doubt your date calculation is working, try this as an input
 Code: 20121106 20121101

What is your result now ? Is it a valid date ?

The result I get is

 Code: 20121095

Gerry
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

 Posted: Fri Nov 09, 2012 4:10 am Hi Gerry, Which calculation?
gcicchet

Senior Member

Joined: 28 Jul 2006
Posts: 1702
Location: Australia

Posted: Fri Nov 09, 2012 4:24 am

Hi Bill,

 Code: OUTREC FIELDS=(1:12,6,Y2T,SUB,+6)

Gerry
Bill Woodger

Moderator Emeritus

Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

 Posted: Fri Nov 09, 2012 4:39 am Thanks Gerry. I was fearing I'd have to look at the other one :-)
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

 Posted: Fri Nov 09, 2012 7:30 am Bill, thanks for the links. Gerry, why would I subtract greater (20121106) value from lesser (20121101) value Thanks.
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

Posted: Fri Nov 09, 2012 7:34 am

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.

Active User

Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

Posted: Fri Nov 09, 2012 3:07 pm

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...

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
ramsri

Active User

Joined: 18 Oct 2008
Posts: 380
Location: India

Posted: Sat Nov 10, 2012 7:43 am

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.
 View Bookmarks All times are GMT + 6 Hours

 Topic Forum Replies Similar Topics Compare only first records of the fil... SYNCSORT 7 Amount of days between two dates PL/I & Assembler 8 Count Records with a crietaria in a f... DFSORT/ICETOOL 5 DFSORT/SYNCSORT/ICETOOL JCL & VSAM 8 Syncsort "Y2C" Function SYNCSORT 1
Search our Forums:

 IBMMainframes.com is not an official and/or affiliated with IBM® in anyway Board Rules | FAQ | Downloads | Wiki | SiteMap | Contact Us