× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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 allows
multiple RCVF cycles of the same physical file in the same CLLE program by
retrieving the number of records in the file and only attempting that number
of reads so that CPF0864 is not triggered. However, in my attempt to
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 in
debug mode, and I'm seeing that the POSDBF is being executed when my record
read count =&NBRCURRCD from RTVMBRD. When I "Display Open Files" on the
job, the file is open and sitting at the last Relative Record Number. If I
ignore CPF5230 and continue, the next RCVF triggers the CPF0864 error.

I've pasted below the source to the testing app I've created to debug this.
The call to ReGen2 would normally change the data in the e2VaultDir file,
but I've swapped that out for the seven lines that follow for the purpose of
testing this. The DLTF, CRTPF,& CPYF mimic the behavior of what happens to
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


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.