Operating Systems

DFSORT: IFTHEN, Numeric Tests & Relative Dates

4 Pages

Finally, we use the OUTFIL statement to display one line for each interval with the dates for that interval and the total of the amounts for that interval. HEADER2 creates header records for the report, including the date of the run. SECTIONS treats all records with the same value in positions one through 21 (the interval dates) as a group. TRAILER3 creates one trailer record for each group with the interval and total for that group. For example, with our current date of 2006/07/07, the output record for the first interval would have ‘2006/06/30-2006/07/04’ in positions one through 21 and ‘14538.8’ in positions 29 through 35 (we increased the total by one digit to avoid overflow). We want a trailer record with the interval and total for each group, but no data records, so we use NODETAIL to suppress the data records. We don’t want ANSI carriage control characters for our report, so we use REMOVECC to eliminate them.

Figure 4 shows the output report with the headings, including the run date, the actual dates for the three intervals, and the total for each interval.

Past and Future Date Constants

You can use new relative date keywords in the INCLUDE and OMIT statements, the INCLUDE and OMIT parameters of the OUTFIL statement, and the WHEN parameter of an IFTHEN clause to test date fields with appropriate formats against past and future date constants. For example, you can test:

  • A BI, CH, AC, or AQ field against a DATE1-30 or DATE3(.)+205 character constant
  • A BI, ZD, PD, FI, FS, UFF or SFF field against a DATE2P-10 or DATE3P+45 decimal constant
  • A Y2x field against a Y’DATE3’-18 or Y’DATE2’+12 constant.

The available date constants are as follows (of course, the same keywords without -d or +d are constants for the current date):

  • DATE1-d, DATE1(s)-d, DATE1P-d, DATE3-d, DATE3(s)-d and DATE3Pd are constants for the current date -d days in the form ‘yyyymmdd’, ‘ y y y y smms d d’, + y y y ymmd d , ‘yyyyddd’, ‘yyyysddd’ and +yyyyddd, respectively.
  • Y’DATE1’-d and Y’DATE3’-d are constants for the current date -d days in the form Y’yymmdd’ and Y’yyddd’, respectively.
  • DATE1+d, DATE1(s)+d, DATE1P+d, DATE3+d, DATE3(s)+d and DATE3P+d are constants for the current date +d days in the form ‘yyyymmdd’, ‘yyyysmmsdd’, +yyymmdd, ‘yyyyddd’, ‘yyyysddd’ and +yyyyddd, respectively.
  • Y’DATE1’+d and Y’DATE3’+d are constants for the current date +d days in the form Y’yymmdd’ and Y’yyddd’, respectively.
  • DATE2-m, DATE2(s)-m and DATE2P-m are constants for the current date -m months in the form ‘yyyymm’, ‘yyyysmm’ and +yyyymm, respectively.
  • Y’DATE2’-m is a constant for the current date -m months in the form Y’yymm’.
  • DATE2+m, DATE2(s)+m and DATE2P+m are constants for the current date +m months in the form ‘yyyymm’, ‘yyyysmm’ and +yyyymm, respectively.
  • Y’DATE2’+m is a constant for the current date +m months in the form Y’yymm’.

You can use new relative date keywords in the INREC, OUTREC, and OUTFIL statements to generate past and future date constants. The available date constants are as follows (of course, the same keywords without -d or +d generate constants for the current date):

  • DATE1-d, DATE1(s)-d, DATE1P-d, DATE3-d, DATE3(s)-d and DATE3Pd are constants for the current date -d days in the form ‘yyyymmdd’, ‘ y y y y smms d d’, P’y y y ymmd d’, ‘yyyyddd’, ‘yyyysddd’ and P’yyyyddd’, respectively.
  • DATE1+d, DATE1(s)+d, DATE1P+d, DATE 3 + d , DATE 3 ( s ) + d a n d DATE3P+d are constants for the current date +d days in the form ‘yyyymmdd’, ‘yyyysmmsdd’, P’yyyymmdd’, ‘yyyyddd’, ‘yyyysddd’ and P’yyyyddd’, respectively.
  • DATE2-m, DATE2(s)-m and DATE2Pm are constants for the current date -m months in the form ‘yyyymm’, ‘yyyysmm’ and P’yyyymm’, respectively. • DATE2+m, DATE2(s)+m and DATE2P+m are constants for the current date +m months in the form ‘yyyymm’, ‘yyyysmm’ and P’yyyymm’, respectively.

Summary

DFSORT’s IFTHEN function can be used in a wide variety of situations that require conditional reformatting of records while sorting, merging or copying, and can often eliminate multiple passes over the data. Other new features such as numeric tests and relative dates also can make you more productive. By using the techniques discussed here, you can tap into those features whenever you need them. Future articles will discuss additional DFSORT functions you can use. Z

For More Information

Visit the DFSORT Website at www.ibm.com/storage/dfsort/for complete documentation on the features discussed in this article. In particular, my “User Guide for DFSORT PTFs UK90007 and UK90006” paper (April 2006) discusses the numeric tests, relative dates, TO=PDF and TO=PDC functions, and my “User Guide for DFSORT PTFs UQ95214 and UQ95213” paper (December 2004) discusses the IFTHEN, OVERLAY, BUILD, TO=ZDF and TO=ZDC functions. All the DFSORT documentation can be accessed online from www.ibm.com/ servers/storage/support/software/sort/mvs/srtmpub.html.

4 Pages