Q: I'm trying to split a packed field containing a date in MDY format into separate fields so I can create an access path that will sort the records in YMD format. I have tried the SST keyword, but it will only substring on zoned, character, or hexadecimal data types. I need some advice on how to get around this problem.
? John Grzybowski
A: If you're stuck with a packed field containing dates in MDY format, there is a way to create a logical access path by date over the file. The trick is to first override the field definition to zoned. You can do this by placing an S in position 35 on the packed field in the DDS for the logical file. You can then use the SST keyword to break down the field into its separate components by creating three new character fields. These new fields become the key fields for the logical file. You can see this technique illustrated in Figures 3 and 4.
? James Sedwick
TechTalk: Creating an Access Path over a Packed MDY Field
Figure 3: Physical File Definition
A R DATEREC A FLD1 3 0 TEXT('FIELD 1') A FLD2 3 0 TEXT('FIELD 2') A MDY 6 0 TEXT('DATE FIELD') A K FLD1
TechTalk: Creating an Access Path over a Packed MDY Field
Figure 4: Logical File Definition by YMD
A R DATEFMT PFILE(DATEPF) A FLD1 R A FLD2 R A MDY R S A YEAR I SST(MDY 5 2) A MONTH I SST(MDY 1 2) A DAY I SST(MDY 3 2) A K YEAR A K MONTH A K DAY
LATEST COMMENTS
MC Press Online