DDM example 3: Access multiple iSeries files

 

Using the same communications environment as in the previous examples, this example is used to ask inventory questions of identically named files on the two remote iSeries™ servers and the remote System/38™.

To do so, a program must be written (shown here in pseudocode) on the central server that can access the files named LIB/MASTER on the servers in Chicago, in Toronto, and in New York. (In this example, the MASTER files are keyed files, and the first member of each of these files is the one used. Also, data description specifications (DDS) for the MASTER files exist on the central server in Philadelphia.)

The program asks the local order entry operator for an item number (ITEMNO), and returns the quantity-on-hand (QOH) information from the files in Chicago, Toronto, and New York.

The following commands are issued on the server in Philadelphia:

CRTDDMF  PGMLIB/CHIFILE  RMTFILE(*NONSTD 'MASTER.LIB')
         RMTLOCNAME(CHIC)
CRTDDMF  PGMLIB/TORFILE  RMTFILE(LIB/MASTER)   RMTLOCNAME(TOR)
CRTDDMF  PGMLIB/NYCFILE  RMTFILE(LIB/MASTER)   RMTLOCNAME(NYC)

Here is a sample of the pseudocode to accomplish the task:

By using the code examples, you agree to the terms of the Code license and disclaimer information.

DECLARE CHIFILE, TORFILE, NYCFILE INPUT Open CHIFILE, TORFILE and NYCFILE LOOP:  Show a display asking for ITEMNO    Read ITEMNO from the display       Read record from CHIFILE with the key ITEMNO       Read record from TORFILE with the key ITEMNO       Read record from NYCFILE with the key ITEMNO       Write all QOH values to the display    If not function key, go to LOOP Close CHIFILE, TORFILE and NYCFILE END

Before the program is compiled, Override with Database File (OVRDBF) commands can be used to override the three files used in the program with local files that contain the external description formats, identical to the remote files being accessed. Doing so significantly reduces the time required for the compile, since the files on the remote server do not have to be accessed then.

After the program has been compiled correctly, the overrides should be deleted so that the program is able to access the remote files.

An alternative to the use of overrides is to keep the file definitions in a different library. The program can be compiled using the file definitions in that library and then run using the real library.

 

Parent topic:

Examples: Code DDM-related tasks