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



I see what you're saying, but I think the documentation is speaking to a very specific situation wherein you did not do a Read before your Chain that is chaining out to the very same record. In that case success would position the file to where you Chain'd to, and a failed chain wouldn't reposition the file, but in your scenario the position of the file is already there.

Given what you're seeing, Chain is not like SetLL, which would position to the end of the file if no record was found for the SetLL.

Kurt Anderson
Sr. Programmer/Analyst - Application Development, Service Delivery Platform


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Vernon Hamberg
Sent: Friday, December 18, 2015 9:37 AM
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxx>
Subject: Re: CHAIN not found and subsequent READ - docs wrong?

Thanks, Kurt, yeah, I hear you - but the line I quoted says you CAN'T do a subsequent read operation unless you reposition the file.

So the docs are at least confusing, right?

Vern

On 12/18/2015 8:29 AM, Kurt Anderson wrote:
While what you quoted doesn't say this, I'm guessing a Chain that results in no hit, does not change the file position. So with your read before the chain having already read successfully, it set the file position, the failed Chain did not move it, so the read after the Chain "works" and reads the next record.

So the line from the documentation that backs up what I just said comes right before what you quoted:
"When the CHAIN operation is successful, the file specified in name is positioned such that a subsequent read operation retrieves the record logically following or preceding the retrieved record."

Specifically, it's saying that the file is positioned after a successful chain. So if it's not successful, it's not positioned. That's my take. Keep in mind that I don't recall the last time I coded a Chain and then a Read to follow it.

Kurt Anderson
Sr. Programmer/Analyst - Application Development, Service Delivery
Platform


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of
Vernon Hamberg
Sent: Friday, December 18, 2015 9:18 AM
To: RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
Subject: CHAIN not found and subsequent READ - docs wrong?

Y'all

The ILE RPG Reference has this to say about a CHAIN that does not
complete -

"When the CHAIN operation is not completed successfully (for example, an error occurs or no record is found), the file specified in name must be repositioned (for example, by a CHAIN or SETLL operation) before a subsequent read operation can be done on that file."

Now I've seen that when record-not-found happens, that I can do a READ
without repositioning, no problem. Here's the scenario -

READ keyedfile fileds;

CHAIN somekey keyedfile fileds; (%found(keyedfile) = *OFF)

READ keyedfile fileds;


The 2nd READ returns the record that follows the one returned by the first READ - so the READ continues from where things were before the failed CHAIN.

That seems NOT to be how the documentation says it should work - I did not have to do another successful CHAIN or SETLL - "successful" is my word added as my assumption.

Confirm or deny, anyone?

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


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


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.