I have a variable length VSAM (237 to 4087bytes), a date in PD (yyyyddd) on fix position 16 with 4 bytes.
May I know if I can sort out records with this date > (today - 7year) ?
This is for housekeeping purpose (remove records older than 7year) so leap year can be ignored.
I review DATE3P, DATEDIFF, but cannot figure how to specify in INCLUDE COND statement in sort, as it is variable length file, I am not sure how to put e.g. a (date - 7year) field at end of each record, or in another temp file ?
One way, Use INREC OVERLAY to get the final dates ( date- 7 years) and later use that value in OUTFIL INCLUDE to apply filter.
Able to show some lines of code?
I meant records need intact to sort out if within 7 years.
When using &DATE3P you must add/subtract years as normal packed decimal (where years shifted 3 digits left, e.g. 7 years = 7000), and then to compare your packed decimal date with the result of decimal addition/subtraction of the current date. Not a big deal...
Without learning insertions the code should be even more simple, and shorter.
This is the learning test sample. I deliberately do not give you a ready-to-use solution, to make you think a little bit before copy-and-paste the code.
One way, Use INREC OVERLAY to get the final dates ( date- 7 years) and later use that value in OUTFIL INCLUDE to apply filter.
Able to show some lines of code?
I meant records need intact to sort out if within 7 years.
When using &DATE3P you must add/subtract years as normal packed decimal (where years shifted 3 digits left, e.g. 7 years = 7000), and then to compare your packed decimal date with the result of decimal addition/subtraction of the current date. Not a big deal...
Without learning insertions the code should be even more simple, and shorter.
This is the learning test sample. I deliberately do not give you a ready-to-use solution, to make you think a little bit before copy-and-paste the code.
Make use of the AGE=YD operator in INREC and later filter by INCLUDE/OMIT. That's the simplest way of doing the task.
Yes, it simplifies (in DFSORT only) the calculation of date difference value.
But the main incovenience remains the same: the date difference calculated in any manner MUST be (temporary) stored as a separate filed, in order to use it in any condition parameter, like
INCLUDE=(...)...