|
View previous topic :: View next topic
|
| Author |
Message |
Gerd Hofmans
New User
Joined: 24 Dec 2015 Posts: 4 Location: belgium
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Have you looked at the various date-functions available? Can you show what you have got already? |
|
| Back to top |
|
 |
Gerd Hofmans
New User
Joined: 24 Dec 2015 Posts: 4 Location: belgium
|
|
|
|
| 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 |
|
 |
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
Gerd Hofmans,
In the future, please use Code tags for readability. |
|
| Back to top |
|
 |
Gerd Hofmans
New User
Joined: 24 Dec 2015 Posts: 4 Location: belgium
|
|
|
|
| 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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
Gerd Hofmans
New User
Joined: 24 Dec 2015 Posts: 4 Location: belgium
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|