|
Hi Dan,
You're missing something fundamental. POSDBF has *no* direct impact on
a file you declare in your CL program with DCLF. Seriously. POSDBF can
*only* be used to affect files opened in the background with the OPNDBF
or OPNQRYF commands. Not files declared with DCLF.
If you don't understand the difference between opening a file in your
program, and opening it with OPNDBF or OPNQRYF, then you need to take a
step back and learn that part now, or you'll never really understand how
this technique works.
Anyway... with that in mind do the following before your ReadLoop:
OPNDBF FILE(E2VAULTDIR) OPTION(*INP) OPNID(DIR)
OVRDBF FILE(e2VaultDir) TOFILE(QTEMP/e2VaultDir) SHARE(*YES)
ReadLoop: /*existing */
Rcvf OpnID( dir ) /*existing */
When your CL program calls the first RCVF in the program, it will open
the file in your CL program. Since SHARE(*YES) has been defined, that
means it'll share the same ODP as the one opened with OPNDBF.
When you do the POSDBF later, it positions the one you opened with
OPNDBF -- but since the ODP is shared, that'll also position your CL's
copy -- letting you read it again.
At the end of the program (the EndOfFile: tag) you need to insert a CLOF
statement to close the copy of the file you opened with OPNDBF.
Good luck
On 4/28/2010 12:00 PM, Dan wrote:
Clumps of hair on floor. I found references in the archive that allowsby
multiple RCVF cycles of the same physical file in the same CLLE program
retrieving the number of records in the file and only attempting thatnumber
of reads so that CPF0864 is not triggered. However, in my attempt toin
develop an app to use this technique, POSDBF is failing with CPF5230 "No
file open with OPNID(DIR)." The thing is that I'm stepping through this
debug mode, and I'm seeing that the POSDBF is being executed when myrecord
read count =&NBRCURRCD from RTVMBRD. When I "Display Open Files" on theI
job, the file is open and sitting at the last Relative Record Number. If
ignore CPF5230 and continue, the next RCVF triggers the CPF0864 error.this.
I've pasted below the source to the testing app I've created to debug
The call to ReGen2 would normally change the data in the e2VaultDir file,of
but I've swapped that out for the seven lines that follow for the purpose
testing this. The DLTF, CRTPF,& CPYF mimic the behavior of what happensto
the e2VaultDir file in ReGen2. The following commands should be executed
before compiling and running the application:
CrtPF qtemp/e2VaultDir RcdLen(40)
CrtPF qtemp/e2VaultDi$ RcdLen(40)
TIA!
- Dan
Pgm
Dclf e2VaultDir OpnId( dir )
Dcl&NbrCurRcd *dec ( 10 0 )
Dcl&ReadCount *dec ( 10 0 )
Loop1:
/* Call ReGen2<=== disable for test */
DBU qtemp/e2VaultDi$ /* test */
DltF qtemp/e2VaultDir /* test */
MonMsg CPF2105 /* File not found */ /* test */
CrtPF qtemp/e2VaultDir RcdLen(40) /* test */
cpyf qtemp/e2VaultDi$ qtemp/e2VaultDir /* test */ +
MBROPT(*add) FMTOPT(*NOCHK) /* test */
RtvMbrD qtemp/e2VaultDir NbrCurRcd(&NbrCurRcd )
OvrDbf e2VaultDir qtemp/e2VaultDir
ChgVar&ReadCount 0
ReadLoop:
Rcvf OpnID( dir )
ChgVar&ReadCount (&ReadCount + 1 )
If (&ReadCount>=&NbrCurRcd ) Then( Do )
PosDBF OpnID( dir ) Position( *Start )
Goto EndOfFile
Enddo
Goto ReadLoop
EndOfFile:
DltOvr e2VaultDir
Goto Loop1
EndPgm
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.