Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Calculate a timeframe with DFsort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Gerd Hofmans

New User


Joined: 24 Dec 2015
Posts: 4
Location: belgium

PostPosted: Thu Jan 14, 2016 5:30 pm    Post subject: Calculate a timeframe with DFsort
Reply with quote

Hi, while migrating a 4th gen language to DFsort, i need to calculate an end-date and begin-date, based on a date in a sequential infile.
If the month of that infile date is 1, then the begindate is yearminusone/01/01 (format is YYYY/MM/DD) and the end date is yearminusone/12/31. in the other case (MM ne 1), the begindate is the beginning of the year and the enddate is the last day of the previous month. (e.g. 2016/01/14 => begindate = 2015/01/01, enddate = 2015/12/31 - 2016/05/14 => begindate = 2016/01/01, enddate = 2016/04/30.
(Later i need to check if a date in another input file is between these dates).
I have tried a variety of calculations, but it looks too complicated right now. Can you suggest a (the best) way to do this.
Kind Regards, Gerd.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Jan 14, 2016 6:49 pm    Post subject: Reply to: Calculate a timeframe with DFsort
Reply with quote

Have you looked at the various date-functions available? Can you show what you have got already?
Back to top
View user's profile Send private message
Gerd Hofmans

New User


Joined: 24 Dec 2015
Posts: 4
Location: belgium

PostPosted: Thu Jan 14, 2016 7:39 pm    Post subject: Reply to: Calculate a timeframe with DFsort
Reply with quote

Code:
//SORTIN     DD *                                                     
20160314                                                               
//SORTOUT    DD SYSOUT=X                                               
//SYSIN      DD *                                                     
  SORT FIELDS=COPY                                                     
   INREC IFTHEN=(WHEN=INIT,                                           
         OVERLAY=(81:1,8,Y4T(/),                                       
                  93:1,4,UFF,LENGTH=4,EDIT=(TTTT),C'/01/01',           
                 117:1,8,Y4T,SUBMONS,+1,TOGREG=Y4T)),                 
         IFTHEN=(WHEN=(86,2,ZD,EQ,1),                                 
         OVERLAY=(93:81,4,UFF,SUB,+1,LENGTH=4,EDIT=(TTTT),C'/01/01',   
                 150:81,4,UFF,SUB,+1,LENGTH=4,EDIT=(TTTT),C'/12/31')),
         IFTHEN=(WHEN=(86,2,ZD,NE,1),                                 
         OVERLAY=(150:117,8,Y4T,LASTDAYM,TOGREG=Y4T(/)))               
*                                                                     
   OUTREC IFTHEN=(WHEN=INIT,                                           
           BUILD=(1:81,10,                                             
                 12:93,10,                                             
                 24:150,10))                                           
*       


This works ...

Code'd
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Thu Jan 14, 2016 7:48 pm    Post subject:
Reply with quote

Gerd Hofmans,
In the future, please use Code tags for readability.
Back to top
View user's profile Send private message
Gerd Hofmans

New User


Joined: 24 Dec 2015
Posts: 4
Location: belgium

PostPosted: Thu Jan 14, 2016 8:01 pm    Post subject:
Reply with quote

Code:
//SORTIN     DD *                                                     
20160114                                                               
//SORTOUT    DD SYSOUT=X                                               
//SYSIN      DD *                                                     
  SORT FIELDS=COPY                                                     
   INREC IFTHEN=(WHEN=INIT,                                           
         OVERLAY=(81:1,8,Y4T(/),                                       
                  93:1,4,UFF,LENGTH=4,EDIT=(TTTT),C'/01/01',           
                 117:1,8,Y4T,SUBMONS,+1,TOGREG=Y4T)),                 
         IFTHEN=(WHEN=(86,2,ZD,EQ,1),                                 
         OVERLAY=(117:81,4,UFF,SUB,+1,LENGTH=4,EDIT=(TTTT),C'/12/31')),
         IFTHEN=(WHEN=(86,2,ZD,NE,1),                                 
         OVERLAY=(117:117,8,Y4T,LASTDAYM,TOGREG=Y4T(/)))               
*                                                                     
   OUTREC IFTHEN=(WHEN=INIT,                                           
           BUILD=(1:81,10,       * INPUT DATE YYYYMMDD                 
                  12:93,10,      * BEGIN DATE YYYY/MM/DD               
                  23:117,10))    * END   DATE YYYY/MM/DD               
/*                                                                     
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Jan 14, 2016 10:01 pm    Post subject: Reply to: Calculate a timeframe with DFsort
Reply with quote

You are around about there already.

Code:
  SORT FIELDS=COPY
   INREC IFTHEN=(WHEN=INIT,
                  OVERLAY=(81:1,8,Y4T(/),
                           93:1,4,C'/01/01',
                          117:1,8,Y4T,SUBMONS,+1,TOGREG=Y4T)),
         IFTHEN=(WHEN=(86,2,ZD,EQ,1),
                  OVERLAY=(93:81,4,ZD,SUB,+1,TO=ZD,LENGTH=4,C'/01/01',
                          150:81,4,ZD,SUB,+1,EDIT=(TTTT),C'/12/31')),
         IFTHEN=(WHEN=NONE,
                  OVERLAY=(150:117,8,Y4T,LASTDAYM,TOGREG=Y4T(/)))
*
   OUTREC  BUILD=(1:81,10,
                 12:93,10,
                 24:150,10))


If numeric-data is in a fixed position, prefer ZD to UFF/SFF.

You don't need a LENGTH with an EDIT, since the mask determines the length. The other option is with TO= and LENGTH=, which I've shown just for an example. Chose one or the other.

No need to negate the condition. IFTHEN=(WHEN=(logicalexpression) is like an EVALUATE in COBOL, once a condition is true, IFTHEN processing stops, unless you specify HIT=NEXT (when you need it) for one or more IFTHENs. WHEN=NONE is like WHEN OTHER in a COBOL EVALUATE.

If you only have one option on INREC/OUTREC/OUTFIL, you don't need WHEN=INIT. You need WHEN=INIT if you have multiple distinct things to do to each record.
Back to top
View user's profile Send private message
Gerd Hofmans

New User


Joined: 24 Dec 2015
Posts: 4
Location: belgium

PostPosted: Fri Jan 15, 2016 12:19 pm    Post subject: Reply to: Calculate a timeframe with DFsort
Reply with quote

Many thanks for the valuable directions. I am trying (learning) to use DFSORT in the way it needs to be used. It's a fantastic product, and i am putting a lot of effort into it to make it a standard for replacing other program languages (in combination with cobol). So far, it works great.
btw. i am working as a self-employed consultant at a large bank on a migration project. Again, many thanks and keep up the good work ;)
Kind Regards, Gerd.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts How to calculate an specific transact... lind sh CICS 2 Tue Sep 13, 2016 9:20 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts DFSORT sorting only specific records akodakka DFSORT/ICETOOL 4 Thu Aug 04, 2016 11:24 am
No new posts Symbolic Parameters in SYSIN DD state... madishpa DFSORT/ICETOOL 3 Mon Jun 27, 2016 6:23 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us