So when you come out of the step2 subroutine, %eof is always *ON. So when you check it in the SRBPOL loop, %EOF is still *ON, and the loop ends. One way to prevent this is to check %EOF immediately after the associated read. Another way to prevent this is to pass the file name to %EOF() as a parameter. I the second case, any intervening reads of other files will not affect %EOF. If you are using a DOU loop with your read at the top of the loop, you need to use the %EOF(filename) form because you could potentially have intervening reads elsewhere in your program affecting %EOF. You also have another issue with the loop as you have written it.

dou %eof
reade
... do some stuff
enddo

This will ... do some stuff even after you hit end of file. This is how that works, read the first record, ... do some stuff, not end of file. Read the next record, ... do some stuff, not end of file. Attempt to read next record, record not found (%eof now *ON), ... do some stuff. End the loop. Notice that ... do some stuff happens at the end of the loop every time when the record is not found. In fact, the only reason you do not ... do some stuff when there are no records is because of the if %equal condition that contains the dou %eof loop.

To ensure that intervening reads do not cause problems like you are seeing here, it is best to use the %eof(filename) form.

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx


-----Hoteltravelfundotcom <hoteltravelfun@xxxxxxxxx> wrote: -----
To: "RPG programming on the IBM i (AS/400 and iSeries)" <rpg400-l@xxxxxxxxxxxx>
From: Hoteltravelfundotcom <hoteltravelfun@xxxxxxxxx>
Date: 03/08/2016 04:32PM
Subject: Re: READ for not exact key


step2 is reading a different file, the item file. See we have a one time
thing here because of the move to the new facility. They started receiving
in the new facility and some products
need to be moved and then the warehouse balance file has to be accordingly.
I have to change this to reflect your idea about the %EOF file name.

But my question is, will this conceptually work. We are setll and reade
partial key. back on step 1. the order number is all we have yet we want to
read each orderline, why? so that each item will have the warehouse change
and the purchase order qty subtracted from old warehouse and added to the
new wh.

in the second step,
c step2 begsr
c* Step2 move the order Qty from old to new warehouse
c srol setll srbsro
c if %equal
c* dou %eof
c srol reade srbsro
c ohords iflt 30
c eval olsrom = whs
c* here do the qty switch. take the item from step 1,passed whs parm
c* and add the qty from srbpol for that item to the whs item in sro
c eval srpurq = srpurq + svqty
c update sro
c endif
c* Enddo
c endif
c* now update whs 100
c srolnn setll srbsro
c if %equal
c* dou %eof
c srol reade srbsro
c eval srpurq = srpurq - svqty
c*
c* Enddo
c endif
c endsr

----------------------------------


c srol klist
c kfld item 35
c kfld whs
c srolnn klist
c kfld item 35
c kfld whs100
c endsr
c*


On Tue, Mar 8, 2016 at 4:25 PM, Mark Murphy/STAR BASE Consulting Inc. <
mmurphy@xxxxxxxxxxxxxxx> wrote:

Here you still have to check %eof immediately after your reade because you
need to know if you read a record or not.

To answer your question, you are going to have to look into subroutine
step2. This or something it calls may be reading the same file, or a
different file to %eof. %eof is based on the most recent read. Try using
%eof(filename) instead. Then it will be associated with the most recent
read of that file. You still have the opportunity to step on your own toes.
If step2 is also reading srbpol to %eof you will still only get a single
record even if you use %eof(filename).

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx


-----Hoteltravelfundotcom <hoteltravelfun@xxxxxxxxx> wrote: -----
To: "RPG programming on the IBM i (AS/400 and iSeries)" <
rpg400-l@xxxxxxxxxxxx>
From: Hoteltravelfundotcom <hoteltravelfun@xxxxxxxxx>
Date: 03/08/2016 03:56PM
Subject: Re: READ for not exact key


What I want to do is process all the order# lines.
I am getting the order# from previous step. From header.

Now here I want to read all order lines. But its doing only 1 time.

pol setll srbpol
if %equal
dou %eof
pol reade srbpol
ohords iflt 30
eval ohsrom = svsrom
eval ohsrom = whs
eval oloqty = svqty
eval olline = svline
update orppl
*now take this line item and qty and update warehouse balances
eval item = olprdc
exsr step2
endif
enddo
endif
*


pol
( I remove the orderline from ths klist because I wont be getting that from
the previous read which is the
order header)

c pol klist
c* Production order:Ord no: Ord line:
c kfld prod
c kfld ohorno 1200
c* kfld lline 500

On Tue, Mar 8, 2016 at 3:53 PM, Roche, Bob <broche@xxxxxxxxxxxxxxxxx>
wrote:

I will say first I am in the SETLL READ DOW group.
From what I remember SETLL does not set %EOF. %EOF Without a file
designator uses last file read, in this case we don't have enough code to
know the file it is referencing. So the DOU %EOF has no reference on the
first pass. This coding made more sense with indicators because you can
set
the indicator before entering your loop. You cannot in the program set
%EOF.

Of course if I'm wrong about SETLL and %EOF this email was a waste.

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of
Hoteltravelfundotcom
Sent: Tuesday, March 08, 2016 2:00 PM
To: RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
Subject: READ for not exact key

pol setll srbpol
if %equal
dou %eof
pol reade srbpol
ohords iflt 30
eval ohsrom = svsrom


Pol = order#


actual key of file is

order#
orderline

when running I am only getting one read. Is that correct?

the thing is, I dont have order lines from the previous file read that
header where I get the order#/.

Do I create my own order line values? or should this be working.
--
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.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.
--
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.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

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

Please contact support@xxxxxxxxxxxx for any subscription related
questions.
--
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.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.