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


  • Subject: Re: add file with same name from different AS/400 into pgm
  • From: "John Taylor" <john.taylor@xxxxxxxxxxxxxxx>
  • Date: Thu, 27 Jan 2000 11:37:17 -0700

RE: add file with same name from different AS/400 into pgmHi Joel,

I just came into this thread, so I'll apologize in advance if I'm repeating
something that has already been considered. What I'd like to suggest is that
you take a more modular approach to the application design, by moving the
database I/O into separate modules. Using your specific situation, we might
end up with three distinct modules as follows:

ModMain      - Mainline control module
ModLclDB    - Module for local database I/O.
ModDdmDB  - Module for the remote DDM file I/O.

ModMain would declare an external data structure based on the common record
format of the files, and specify it as an EXPORT. Both DB modules would
declare the same data structure, and specify it as IMPORT. This will allow
you to work with the fields in ModMain as though there was a single copy of
the file declared within the module itself. Of course, ModMain does not
actually have any F-specs for either file.

Each DB module contains an almost identical structure - the only difference
being which file it is actually processing. The module will declare the file
on the F-spec with a user-controlled open. The modules export the following
sub-procedures:

ModLclDB:
  LclDbOpen( 'LIBRARY/FILE' )
  LclDbChain( Key1: Key2 )
  LclDbSetll( Key1: Key2 )
  LclDbSetgt( Key1: Key2 )
  LclDbReadNext()
  LclDbReadPrv()
  LclDbClose()

ModDdmDB:
  DdmDbOpen( 'LIBRARY/FILE' )
  DdmDbChain( Key1: Key2 )
  DdmDbSetll( Key1: Key2 )
  DdmDbSetgt( Key1: Key2 )
  DdmDbReadNext()
  DdmDbReadPrv()
  DdmDbClose()

The majority of the procedures are self-explanatory. There is a little bit
of additional action that needs to take place in the "xxxDbOpen" procedures,
in order to manage the overrides. Here is the basic pseudo-code for
LclDbOpen():

   * Only one file open at a time!
      CallP      DdmDbClose()

    * Override the file name to the lib/file that the caller passed in as a
parameter
      CallP      RunCmd( 'OVRDBF FILE(MYFILE) TOFILE(' + iParm1 + ')
OVRSCOPE(*ACTGRPDFN)' )

     * Try to open the file and respond accordingly
      Open(e)  MYFILE
      If            Not %Error
          Clear                  FileDS
          Return     *On
      Else
          Return     *Off
      Endif

The "xxxDbClose()"  procedures should also issue an appropriate DLTOVR
command as part of the clean-up.

That about does it. ModMain remains in control of the general application
logic and just routes the I/O to the appropriate call, based on which file
the user wants to read.

Just some food for thought...


John Taylor
Canada


----- Original Message -----
From: Stone, Joel
To: 'RPG400-L@midrange.com'
Sent: Thursday, January 27, 2000 09:12
Subject: RE: add file with same name from different AS/400 into pgm


Thanks for the idea, but Im pretty sure the RENAME fails because there are
two files with the same format, and RPG cant figure out which one to rename.
Is this correct?
Any other ideas?
-----Original Message-----
From: Hartman Richard [mailto:richard.hartman@brctsg.com]
Sent: Wednesday, January 26, 2000 7:06 PM
To: 'RPG400-L@midrange.com'
Subject: RE: add file with same name from different AS/400 into pgm


You can try renaming the record format of the file in the file definition
section of the program. You add    RENAME(formatname:formatname2) in the key
words section.
This is what we do when we use two logical files in our program, that are
based off of the same file.
 I do not know if this works for physical files or not?
Then if you had the same field names in both files you could add a prefix to
the fields on one of the file specs by doing:
PREFIX(xx)
I don't know if this will work for your problem. But it is the best I can
offer at the time.
Richard
> -----Original Message-----
> From: Stone, Joel [SMTP:StoneJ@GourmetAward.com]
> Sent: Wednesday, January 26, 2000 4:29 PM
> To:   'RPG400-L@midrange.com'
> Subject:      RPG: add file with same name from different AS/400 into pgm
>
> I need to add an order file to a inquiry RPG pgm.  The file has the same
> name as a file already in the pgm.  What is an easy way to accomplish
> this???
>
> Only one of the files must be open at any point in time, but a user could
> look at one file and then the other in the same session.
>
> Call qcmdexc to ovrdbf and re-open the file with each read to the orders?
>
> Note: I dont think I can use an LF to combine the files, because the
> second file is on another box using DDM, which is sometimes down.  If the
> DDM file is down, I still want the user to be able to see his local
> orders!
>
> Thanks!


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