you would think this should be easy. But you are dealing with subfile here
(ahh good stuff.. :). Remember that a chain to a subfile record will cause
the sflnxtchg flag to get turn off. So, you readc will not work once the
subfile record is chained, unless, of course, you update the subfile with
sflnxtchg indicator on after that chained. But here is the problem, when
you use chain to read a subfile record, there is no way for you to tell if
the record has been changed by the user, therefore, there is no way for you
to decide whether you should turn around to update the chained record with
the sflnxtchg indicator on. So, pretty simple? unfortunately, no, it is not
simple at all.
One more thing to remember is that after you use chain/readc to touch the
subfile, the only way to force READC to perform the READC from the beginning
of the subfile again, is to make %eof occur or do a write/read of subfile
control record (<= can not be sure about the later one).
Please note that above are base on experince (which means that I migth state
something wrong) not base on any doc....
Note: I have done before to get around this minor subfile problem:
Use readc to loop thru the subfile and record down all the RR# in an array
first. Then does the chain loop. After eac chain operation, use the RRN to
check the readc array and update the subfile with SFLNXTCHG on if the RRN
exist in the array. After exit the chain loop, do a dummy readc to force a
%eof, which should make the next readc start from the beginning of subfile.
There is got to be an easier way than this (But that is all I know to do).
"Florin Todor - YYZ Concord" <ftodor@xxxxxxxxxxxxxxxx> wrote in message
news:mailman.3408.1285874338.2702.rpg400-l@xxxxxxxxxxxxxxx
Hello,
I have an issue, which, in my opinion shouldn't be an issue at all
because it is pretty straight forward...
Anyway, I have a subfile where I need to check (for ALL records) if a
specific field has a certain value. I do this using CHAIN RRN op-code.
I, also, want to make EVERY record available for the next READC
operation; pretty simple, right? The only problem is it doesn't work!
The READC does not see any "changed" record...
Here is the relevant code:
C sr_chkhaz begsr
/Free
s1rrn = 1;
Dow s1rrn <= 30 and
v_hazfrt = 'N';
Chain s1rrn R010D02;
If %found();
If #DHAZ = 'X' or
#DHAZ = 'H';
v_hazfrt = 'Y';
Endif;
*in37 = *on;
Update R010D02;
*in37 = *off;
Endif;
s1rrn += 1;
Enddo;
s1rrn = 1;
Write R010D03;
/End-free
C endsr
*in37 turns on/off SFLNXTCHG for R010D02 Subfile record:
A R R010D02 SFL
A 37
AO 69 SFLNXTCHG
The excerpt of the main program:
......................................................
C exsr sr_chkhaz
C move *off *in35
C *in35 doweq *off
C readc r010d02 35
<<<<<<----------*in35 is turned *on
C *in35 ifeq *off
........................................................................
.............
Any thoughts?
Thank you
Florin Todor
<mailto:ftodor@xxxxxxxxxxxxxxxx>
As an Amazon Associate we earn from qualifying purchases.