×
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.
On Mon, 2016-03-07 at 11:01 -0500, Hoteltravelfundotcom wrote:
HI I have this situation.
Orderheader
1.read and update some fields.
Order detail.
The key is order# and orderline.
I have the order# from step1.
My question is
when reading
Setll with order #
and reade with order# ?
Just use one key in the key list, or %KDS (with explicit reference to 1
key), or the single field.
Since the orderline is only in the detail file no wheres else.
step2.
setll orderdetail based on order#
loop while = order#
order# reade orderdetail
move, update etc.
endloop
My preference is for a do until loop with a leave, or further
conditional test. The reason is that %eof may be left on from a previous
file opp, so would never do the first dowhile in the above example.
There is also a problem with your example in that by using reade the
only records that can be read are for the given order number, so order#
will always equal ordernofromfile even if end of data/file is reached,
which you're not testing.
firstkey setll file
do until %eof
firstkey reade file
if %eof
leave
endif
...do stuff...
enddo
...or something like...
firstkey setll file
do until %eof
firstkey reade file
if NOT %eof
..do stuff...
endif
enddo
The problem with the second example is that the if NOT %eof/endif could
end up covering a lot of statements in between, and I much prefer the
test and get out of dodge method of using a leave; which is just a
glorified branch too (ie. if NOT %eof - goto statement just after
enddo).
... likewise in fixedformat/old style...
firstkey setll file
dou *in99
firstkey reade file 99
if *in99
leave
endif
...do stuff...
enddo
is this perfectly fine?
As an Amazon Associate we earn from qualifying purchases.