Can someone please clarify the internal workings of the READ #file DYNAMIC #direction STARTING FROM #key statement.
To summarise my issue, I need to extract and print interest rates from a file over a specific period (start and end date Eg 01 Jan 2009 - 31 Dec 2009). Whenever the interest rate changes, a new record is added to the file. The date the interest rate changes is the descriptor in YYYYMMDD -format (N8).
I setup the key with the period start date ‘20090101’ and #direction variable to ‘D’. The first read finds the interest rate effective on the start date (actual date was 20081115). I then change direction to ‘A’, fluff around and then drop thru to the END-READ. However the next READ exits the loop as its reads past the STARTING FROM #key value. (Next rate change was 20090205.)
I would have though that the READ should continue to the end of file or I explicitly executed an ESCAPE BOTTOM after reading past the period end date.
I know the problem can be solved using WITH REPOSITION and ESCAPE TOP REPOSITION or with READ #file VARIABLE and multiple loops, but I really want to know why the READ #file DYNAMIC exits after changing direction and reading past the start key. Is this they way it’s supposed to work?
Let me know if you require any additional information or a sample file and code.
Thanks.