|
Buck, Thanks. I wound up creating the files as UsrOpn and in each of the functions that use the file I do a C If NOT %Open(CCOHD) C Open CCOHD C EndIf And I created 3 functions called CloseCCOHD, CloseCCOHD04 and CloseCCODT which are the 3 files I use in the service program. The program, at the end, calls each of these in turn, which simply do a C Close CCOHD C Return Everything seems to work now, and I didn't have to hard code the library name anywhere. So I guess the answer is, it will open the file pointed to by the library list, and not just reopen the same file. > I do not want to hard code library names in the program, so I guess my > question is: If I define this file as USROPN, and close it and immediately > reopen it, will it switch to the file pointed to in the Library List, or > will it just reopen the same file again? Regards, Jim Langston Buck Calabro wrote: > > Jim, > Any open will use *LIBL to resolve to the actual file unless overridden. > Your service program must not have LR on, because it's leaving CCOHD open. > You can either set LR on or use an explicit CLOSE to close it. I'd go with > the explicit CLOSE with a comment to let the next programmer in know that > the close is being done to be able to OPEN a different file. > > Buck > > > -----Original Message----- > > From: Jim Langston > > Sent: Monday, January 15, 2001 2:17 PM > > To: RPG400-L@midrange.com > > Subject: Library list heartache > > > > I have a program that processes a customer given file into > > our own OS/400 files written in RPG. > > > > In test environment, everything works great, but now that it's > > in production I find a problem. > > > > I have a CL calling this same program twice, once to process > > records for one of my locations, the second time to process records > > for another location. It adds to the library list for the second > > call, and calls the program with another parameter. > > > > Now here's the problem. > > > > I have this program calling some modules that are bound together into > > a service program. One of these modules has a file in the F-Specs, which > > it searches to see if the record exists. What I find is happening is > > when the module is first called the library list is pointing to a certain > > file which it opens. After that program is done, it gets called again, > > but it still has the previous file open, so it is looking at the wrong > > records (pain in the neck to track down that bug). > > > > I do not want to hard code library names in the program, so I guess my > > question is: If I define this file as USROPN, and close it and immediately > > reopen it, will it switch to the file pointed to in the Library List, or > > will > > it just reopen the same file again? > > > > Snippet from the CL: > > > > /*** REMOVE THE LIBRARY SO WE KNOW IT IS *FIRST ***/ > > RMVLIBLE LIB(CARTCNX) > > MONMSG MSGID(CPF0000) > > ADDLIBLE LIB(CARTCNX) > > CALL PGM(BSTORDADD) PARM('CNX') > > > > /*** REMOVE THE LIBRARY SO WE KNOW IT IS *FIRST ***/ > > RMVLIBLE LIB(CARTSEA) > > MONMSG MSGID(CPF0000) > > ADDLIBLE LIB(CARTSEA) > > CALL PGM(BSTORDADD) PARM('SEA') > > > > Snippet from the RPG: > > > > C Eval FilePrefix = OHICFP > > C Eval FileSuffix = GetNextSuffix(FilePrefix) > > > > Snippet from the RPG Module: > > > > FCCOHD UF E K DISK > > ... > > C CCOHD_Key KList > > C KFld GNS_Prefix > > > > C Eval FileSuffix = -1 > > > > C CCOHD_Key SetLL OHdRc > > C CCOHD_Key Reade(N) OHdRc > > C DoW Not %Eof(CCOHD) > > > > That is where it is giving me problems. On the second call to the RPG it > > still has > > CARTCNX/CCOHD open instead of CARTSEA/CCOHD. > > > > Regards, > > > > Jim Langston +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
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.