Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Gerd Hofmans

New User

Joined: 24 Dec 2015
Posts: 4
Location: belgium

 Posted: Thu Jan 14, 2016 5:30 pm    Post subject: Calculate a timeframe with DFsort 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.

Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Thu Jan 14, 2016 6:49 pm    Post subject: Reply to: Calculate a timeframe with DFsort Have you looked at the various date-functions available? Can you show what you have got already?
Gerd Hofmans

New User

Joined: 24 Dec 2015
Posts: 4
Location: belgium

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

 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
Terry Heinze

JCL Moderator

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

 Posted: Thu Jan 14, 2016 7:48 pm    Post subject: Gerd Hofmans, In the future, please use Code tags for readability.
Gerd Hofmans

New User

Joined: 24 Dec 2015
Posts: 4
Location: belgium

Posted: Thu Jan 14, 2016 8:01 pm    Post subject:

 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                /*
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

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

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

New User

Joined: 24 Dec 2015
Posts: 4
Location: belgium

 Posted: Fri Jan 15, 2016 12:19 pm    Post subject: Reply to: Calculate a timeframe with DFsort 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.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics calculate the record count and based ... naveensrimf DFSORT/ICETOOL 1 Tue Jan 08, 2019 11:20 pm Need advise in calling DFSORT from REXX ajithajt CLIST & REXX 9 Thu Nov 29, 2018 10:50 am How to handle different file length b... javen777 DFSORT/ICETOOL 15 Mon Nov 26, 2018 12:13 pm How to count the number of times key ... vnktrrd DFSORT/ICETOOL 14 Thu Nov 15, 2018 9:19 pm DFSORT output in CSV for data spans i... hiravibk DFSORT/ICETOOL 3 Tue Nov 13, 2018 7:55 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us