IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Syncsort - dates must be Monday and Sunday.


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Nov 07, 2012 11:41 pm
Reply with quote

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

Expected Output:
Code:

20121008 20121014
20121022 20121028
20121105 20121112


Please help. Thanks.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Thu Nov 08, 2012 12:09 am
Reply with quote

What if they are neither Monday nor Sunday?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Nov 08, 2012 12:26 am
Reply with quote

Hello,

What if the dates are more than 6 days apart?

What if both dates are a Monday (or Friday)?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Thu Nov 08, 2012 12:27 am
Reply with quote

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!
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Thu Nov 08, 2012 12:43 am
Reply with 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....
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Nov 08, 2012 1:08 am
Reply with quote

Hello,

Looks like (to me) that even if something is implemented, it may not fill the actual need . . .
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Thu Nov 08, 2012 2:32 am
Reply with quote

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 icon_biggrin.gif) are applied sequentially, I believe that they will cover all cases, even if the result is not always if desired.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Nov 08, 2012 7:55 am
Reply with quote

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
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Nov 08, 2012 8:47 am
Reply with quote

Started experimenting by doing this but don't get satisfactory results icon_sad.gif

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 icon_eek.gif icon_confused.gif Must be heading in wrong direction icon_rolleyes.gif

Thanks.
Back to top
View user's profile Send private message
prino

Senior Member


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

PostPosted: Thu Nov 08, 2012 2:56 pm
Reply with quote

Round holes and square pegs...

How long would it have take you to do this in PL/I, Cobol or REXX?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Thu Nov 08, 2012 3:08 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10833
Location: italy

PostPosted: Thu Nov 08, 2012 3:22 pm
Reply with quote

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

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Nov 08, 2012 8:00 pm
Reply with quote

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

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
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Nov 08, 2012 8:16 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Nov 08, 2012 8:24 pm
Reply with quote

Hello,

Quote:
don't know PL/I or REXX.....
Then COBOL may be the way for you to go . . .
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Thu Nov 08, 2012 8:26 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Thu Nov 08, 2012 8:35 pm
Reply with quote

Ramsri,

How about this one?
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Nov 09, 2012 3:11 am
Reply with quote

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
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Fri Nov 09, 2012 4:10 am
Reply with quote

Hi Gerry,

Which calculation?
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Nov 09, 2012 4:24 am
Reply with quote

Hi Bill,

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



Gerry
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Fri Nov 09, 2012 4:39 am
Reply with quote

Thanks Gerry. I was fearing I'd have to look at the other one :-)
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Fri Nov 09, 2012 7:30 am
Reply with quote

Bill, thanks for the links.

Gerry, why would I subtract greater (20121106) value from lesser (20121101) value icon_confused.gif

Thanks.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Fri Nov 09, 2012 7:34 am
Reply with quote

Gerry, but I tried below values and got an invalid date icon_sad.gif

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
View user's profile Send private message
bodatrinadh

Active User


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

PostPosted: Fri Nov 09, 2012 3:07 pm
Reply with quote

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,LENGTH=2,
                  25:1,4,ZD,SUB,+1,TO=ZD,LENGTH=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,
                                   80:X)),
              IFTHEN=(WHEN=(14,2,ZD,EQ,1,OR,14,2,ZD,EQ,2),
          OVERLAY(61:16,2,63:14,2,ZD,ADD,+12,TO=ZD,LENGTH=2,
                  65:1,4,ZD,SUB,+1,TO=ZD,LENGTH=4,
                  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=(43,1,ZD,EQ,0),
                   BUILD=(1:C'SAT ',5:1,17,83:83,1)),
             IFTHEN=(WHEN=(43,1,ZD,EQ,1),
                   BUILD=(1:C'SUN ',5:1,17,83:83,1)),
             IFTHEN=(WHEN=(43,1,ZD,EQ,2),
                   BUILD=(1:C'MON ',5:1,17,83:83,1)),
             IFTHEN=(WHEN=(43,1,ZD,EQ,3),
                   BUILD=(1:C'TUE ',5:1,17,83:83,1)),
             IFTHEN=(WHEN=(43,1,ZD,EQ,4),
                   BUILD=(1:C'WED ',5:1,17,83:83,1)),
             IFTHEN=(WHEN=(43,1,ZD,EQ,5),
                    BUILD=(1:C'THU ',5:1,17,83:83,1)),
              IFTHEN=(WHEN=(43,1,ZD,EQ,6),
                    BUILD=(1:C'FRI ',5:1,17,83:83,1))
       OUTREC IFTHEN=(WHEN=(83,1,ZD,EQ,0),
                    OVERLAY=(25:C'SAT ')),
              IFTHEN=(WHEN=(83,1,ZD,EQ,1),
                    OVERLAY=(25:C'SUN ')),
              IFTHEN=(WHEN=(83,1,ZD,EQ,2),
                    OVERLAY=(25:C'MON ')),
              IFTHEN=(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
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Sat Nov 10, 2012 7:43 am
Reply with quote

Hi 3nadh, Thank you very much.

Got the results with 1st solution you've provided icon_biggrin.gif
2nd solution failed because we are still at SYNCSORT FOR Z/OS 1.3.2.2R icon_sad.gif

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Count Records with a crietaria in a f... DFSORT/ICETOOL 5
No new posts DFSORT/SYNCSORT/ICETOOL JCL & VSAM 8
No new posts Syncsort "Y2C" Function SYNCSORT 1
No new posts Arithmetic division using Syncsort SYNCSORT 6
This topic is locked: you cannot edit posts or make replies. SUM based on two conditions using SYN... SYNCSORT 7
Search our Forums:

Back to Top