Rather than develop logic to determine which of up to nine files to read from next, the program uses the matching record logic built-in to RPG.
Thus it uses primary and secondary files and thus the cycle.


-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Charles Wilt
Sent: Friday, January 17, 2025 10:40 AM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: RPG Cycle doesnt work, then it does

"files being matched are files generated using the OPENQRYF"

Generated, as in using just OPNQRYF? Or are you also using CPYFRMQRYF to actually create *FILE objects?

Has this ever worked?

I too would like to see some actual code...

Feels to me that you're picking up an already opened data path, thus the EOF; which then gets closed and when the program is rerun it works.

But really, OPNQRYF and the cycle...why?

Charles




On Fri, Jan 17, 2025 at 8:08 AM <tgarvey@xxxxxxxxxx> wrote:

Back again, from late 2024.



I appreciate all the responses to my original issue from late last year.
I've tried all of them to no avail.
I have to try being more specific in what is being done here, in the
hopes a light will go off for someone.



We have a process which generates RPGLE source code which uses the RPG
matching records function.
The files being matched are files generated using the OPENQRYF
command. The Open Query files appear as f specs in the RPGLE source
code as primary and secondary files.

The necessary overrides are all done appropriately before the source
code is generated and compiled.

While I have been primarily testing and debugging this process
interactively, I've also tested it in batch mode. The results are the same.



When the generated program is called (BTW the program object is in
QTEMP), only the INZSR is executed. The two primary and secondary
files are both in status 0011 (end of file on a read) and I know this
because I have the INFDS structures for both. So, LR is set on and
nothing in the C specs gets executed.

Since I am testing this interactively and using debug, as soon as the
first execution ends I can call up a command line and issue the very
same call command to the same generated program, as it is in QTEMP and
all the overrides are intact.
When I do that, the two input primary and secondary files have data in
them and the program executes correctly. LR is not set on until both
files have actually reached end of file.



So, how/why would the two input files, which are the results of using
openqryf, apparently NOT have data in them, and then suddenly have
data in them when the program is called from a command line?



BTW, I modified the process to call the generated program back to back
and both executions result in the apparent empty primary and secondary files.
But even then I can call the program from the command line, in the
middle of the debug session, and it works.



Any ideas?



Warm Regards and thanks in advance



Thomas Garvey



--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription
related questions.


--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.



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-2025 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.