Adam's suggestion is the only way I can think of to accomplish your
desired functionality without opening and closing files to change
libraries. If you want to pretty it up some, you could hide the select
logic in a subprocedure so that it is out of the mainline. Something
like:
Fdetail IF E K DISK EXTFILE('LIB1/detail')
F RENAME(detail:L1det)
F PREFIX('L1')
Fdetail IF E K DISK EXTFILE('LIB2/detail')
F RENAME(detail:L2det)
F PREFIX('L2')
Then, your read logic would look like
do %eof(masterfile)
Read masterfile
Myfield = GetDetailFileField(........)
StartSubprocedure GetDetailFileField
select
when library = 'LIB1'
chain L1Det
when library = 'LIB2'
chain L2Det
endsl
EndSubprocedure
Of course, this only works if the # of libraries involved is relatively
constant. If # of libraries is completely variable (eg. library = item
and user can create items at will), I have an idea that may work, but
would require a little bit of thought before I post it.
Brian May
Project Lead
Management Information Systems
Garan, Incorporated
Starkville, Mississippi
Young i Professionals
http://www.youngiprofessionals.com
David FOXWELL wrote:
First read of masterfile :
ovrdbf to detailfile in lib1 or addlible lib1 in correct position
Chain to detailfile reads file in lib1
Second read of masterfile
ovrdbf to detailfile in lib2 or addlible lib2 in correct position
Chain to detailfile still reads file in lib1 because still open
[W]e are on V5R4.
I can think of a way of doing this, but it isn't particularly pretty. Nor
is it tested, but I've done something similar before. You could define a
different F-spec for each library's detail file, renaming the record
formats and prefixing the fields as appropriate.
Fdetail IF E K DISK EXTFILE('LIB1/detail')
F RENAME(detail:L1det)
F PREFIX('L1')
Fdetail IF E K DISK EXTFILE('LIB2/detail')
F RENAME(detail:L2det)
F PREFIX('L2')
Then, your read logic would look like
do %eof(masterfile)
Read masterfile
select
when library = 'LIB1'
chain L1Det
when library = 'LIB2'
chain L2Det
endsl
Myfield = detail file field
Hope this helps,
Adam
As an Amazon Associate we earn from qualifying purchases.