Brief: If you're looking for a simple, transparent way to access a remote database on an AS/400, IBM has a way for you to locate, retrieve and present the remote data virtually automatically, with distributed data management (DDM).
MIS shops that support multiple AS/400s are becoming more and more prevalent. Your AS/400s may be in the same room or at remote locations around the world; in either case, there may be occasions when you need to access data on one system using a program on another system. Imagine for example, that your company, located in Carlsbad, California, has just purchased a competitor located in Loveland, Colorado. Everyone from the CEO to the janitor is smiling-except you and your MIS team.
You are faced with the challenge of getting inventory information from one system to the other. Somebody suggests using Distributed Data Management (DDM) and soon a chorus of voices agrees that DDM might be just what you need. You're left with two questions: "What is DDM?" and "How can it help me?"
What is DDM?
DDM is part of OS/400. It permits applications or users on an AS/400 to access database files that exist on a remote system, with little or no RPG program modification. Access to remote files is transparent to the user except for the time required to establish a communications link between the two systems. (The systems may include AS/400s, S/36s, S/38s or other DDM-compatible systems.) For our example, we'll simplify things by having an inventory-inquiry program on the AS/400 in Carlsbad access a single inventory file on the AS/400 in Loveland. You can expand these concepts to access multiple programs and database files on the remote system and to allow two-way communication so that Loveland users can access the Carlsbad inventory.
I'll presume that you have established a point-to-point SDLC connection using Advanced Program-to-Program Communications (APPC). Establishing the connection is beyond the scope of this article, but I've included a reference list if you need more information on these topics. DDM connections are limited to either APPC (as we're using in this example) or Advanced Peer-to-Peer Networking (APPN).
There are three basic components of DDM that facilitate remote file processing: DDM files, Source DDM (SDDM) and Target DDM (TDDM). A DDM file contains information about how to find a database file on the remote system. When your RPG or CL program accesses a DDM file which points to a database file on the remote system, it triggers the entire DDM process. A DDM session is established between SDDM on the local AS/400 and TDDM on the target AS/400. The DDM session, SDDM and TDDM are all transparent to the user and the applications programmer, but they are necessary to pass the appropriate data to the program. We'll look at these elements in more detail in the following sections.
DDM Files
To access the inventory file on the Loveland system, you must create a DDM file on the Carlsbad system. DDM files are not database files accessible by programs! It might be helpful to think of a DDM file as a special type of access path: when a program on the source system (Carlsbad) accesses a DDM file, it is directed to the database file on the target system (Loveland). For each file in Loveland that you need to access, you'll need a DDM file on the Carlsbad system.
Before you can create a DDM file, you need some information about both the Loveland system and the Carlsbad system. You'll need to know the local location name for both systems and the local network ID and default mode for Loveland. Run the Display Network Attributes (DSPNETA) command (1) to get this information. Next you'll run the Create DDM File (CRTDDMF) command (2) in Carlsbad to define your DDM file for the inventory file in Loveland.
Before you can create a DDM file, you need some information about both the Loveland system and the Carlsbad system. You'll need to know the local location name for both systems and the local network ID and default mode for Loveland. Run the Display Network Attributes (DSPNETA) command (Figure 1) to get this information. Next you'll run the Create DDM File (CRTDDMF) command (Figure 2) in Carlsbad to define your DDM file for the inventory file in Loveland.
CRTDDMF has many parameters, most of which can be defaulted. But there are seven key DDM values that present valuable options you need to be aware of, so we'll cover them here. DDM has a wider variety of capabilities than I'll discuss in this article-you may need to modify additional parameters if you use these other features. For a comprehensive look at all of DDM's capabilities see the DDM Guide listed in the references section at the conclusion of this article. An important thing to keep in mind at all times is that DDM file information is based on locations, so the parameters that specify where database files are located are critical elements of the DDM file. Of the seven parameters we'll discuss, four deal directly with location.
1. Use the FILE parameter to specify a file name and library to store the DDM file on the Carlsbad system.
2. The remote file (RMTFILE) parameter points to the database file name and library on the Loveland system (e.g., NEWINV/INVTOT).
3. The remote location name (RMTLOCNAME) should match the local location from DSPNETA on the Loveland AS/400. Figures 1 and 2 show the relationship between DSPNETA parameters in Loveland and CRTDDMF in Carlsbad.
The next four parameters can all be defaulted, but you may need to specify them, depending on the complexity of your communications network.
4. The remote location can be further qualified with the remote network identifiers (RMTNETID) parameter (default *LOC). Two locations with the same remote location name but different remote network identifiers are two separate locations just as two files with the same name in different libraries are separate files. If you use the RMTNETID parameter, it should match the local network identifier from your Loveland DSPNETA command.
5. The DEV parameter specifies the name of the APPC device description on the source system that's used with this DDM file. You should default this parameter to *LOC for most applications. By taking the *LOC default, OS/400 will automatically select the appropriate APPC device associated with the remote location. If no APPC device description exists, OS/400 will build one.
6. The local location name (LCLLOCNAME) parameter (default *LOC) specifies the Carlsbad system and must match the default local location name on the Carlsbad DSPNETA command, unless you have multiple local locations defined. In that case, you may insert the local location name you desire.
7. The last DDM file parameter we will look at is MODE (default *NETATR), which refers to the mode name to be used in conjunction with the remote location name to establish a communication link. Either take the *NETATR default, which will get the MODE specified in the Carlsbad AS/400 network attributes, or specify a mode. As with local location name, this depends on the complexity of your particular AS/400 network environment. If you're not sure which local location name or which mode to use, ask your networking specialist.
For our example, we'll create a DDM file named RMTINV in library INVLIB on the Carlsbad system. It points to the inventory file in Loveland (INVTOT in NEWINV library). We'll use the RMTLOCNAME of LOVELAND. The CRT-DDMF command looks like this:
CRTDDMF FILE(INVLIB/RMTINV) + RMTFILE (NEWINV/INVTOT) + RMTLOCNAME(LOVELAND) + TEXT('DDM FOR REMOTE + INVENTORY FILE')
Once you've created your DDM files, you can use several commands to maintain them. I recommend using Work with DDM Files (WRK-DDMF) since it will allow you to create, change, display or delete DDM files easily.
Go to the Source
Unlike the DDM file, neither SDDM or TDDM require any input from you. These two elements establish the conversation between the Carlsbad system and the Loveland system. When a program on the Carlsbad AS/400 accesses a file, OS/400 looks for it within the Carlsbad database. In our example, a DDM file in Carlsbad points toward Loveland. At this point, the Carlsbad system will decide whether or not to start SDDM on the Carlsbad AS/400. It checks to see if an SDDM session for this job already exists, whether it's to Loveland or the Moon. If an SDDM session exists, it will be used. Otherwise, the Carlsbad system will start an SDDM session for the job. No matter how many DDM conversations are active or how many DDM files are open for a job, there will only be one SDDM session. You can find evidence of the SDDM session by using the Work with Configuration Status (WRKCFGSTS) command on the source system. Specify the line description that connects the source and target system for the configuration description (CFGD) parameter. You'll find an active job under that line.
In turn, SDDM checks to see if a DDM conversation to the remote system exists for this job. SDDM uses the remote location name and mode parameters in the DDM file to locate the correct system-for this part of the connection, Loveland and the Moon require separate conversations. If a DDM conversation exists for this job, SDDM will use it. If, however, a conversation for this job doesn't exist, SDDM sends a request to the Loveland system to start a TDDM job to establish the DDM conversation. Once the DDM conversation is active, SDDM and TDDM automatically handle the data interaction between systems. The entire process required to activate a DDM session is transparent to the user and occurs automatically.
Eyes on Target
Once the DDM conversation is established, TDDM is an active batch job on the Loveland system. You can find evidence of this job the same way you did for the SDDM job mentioned earlier (use the WRKCFGSTS command for the line description connecting the systems). You will find an active job for TDDM. It waits for instructions from SDDM and passes the request to database (or folder) management. For example, if a program in Carlsbad opens a DDM file, TDDM locates the file and passes on the request to open it. The result of the operation (in this case, a successful or unsuccessful file open) is returned to TDDM which, in turn, forwards it through the DDM connection to SDDM. SDDM forwards the information to the requesting application in Carlsbad and magically your program has opened the remote file.
Now let's talk about ending a DDM conversation. This is controlled by the DDM Conversation (DDMCNV) attribute of the Change Job (CHGJOB) command of the job in Carlsbad. The default for DDMCNV is *KEEP, which means that the DDM conversation will remain active until the job ends, or until a communications failure occurs. When using *KEEP, you may also use the Reclaim DDM Conversation (RCLDDMCNV), or the Reclaim Resource (RCLRSC) commands to explicitly terminate the DDM conversations.
You can override the default of DDMCNV to *DROP, using the CHGJOB command, which will terminate the DDM conversation automatically when all DDM files are closed and all file locks on the remote DDM file are removed (usually when the program ends). The key thing to remember about choosing between *DROP and *KEEP is the system overhead associated with keeping or restarting a DDM session.
If you think DDM will run multiple times throughout the day, *KEEP will save the system time and resources needed to start a DDM conversation.
On the other hand, specifying *DROP will free up the communications resources used by DDM.
What About the Application Programs?
We've got the basics of DDM plumbing sorted out, and it seems almost too easy to be true. But what about the application programs? What do we need to do to the RPG and CL programs in Carlsbad to display the Loveland inventory data? These modifications are surprisingly simple. A DDM file name can be used alomost anywhere a database file name can be used. If you externally define the DDM file which points to the Loveland inventory file in an RPG program, the DDS is automatically retrieved from the Loveland system. An even simpler solution is available for our example. The Loveland inventory file definition matches the Carlsbad inventory file so you can simply create a copy of the CL for the Carlsbad inventory inquiry. Insert an Override Database File (OVRDBF) command to point to the DDM file instead of the Carlsbad database file-DDM does the rest!
DDM files can also be specified in the Create RPG Program (CRTRPGPGM) command in the SRCFILE or PRTFILE parameters. When you specify a DDM file for SRCFILE, DDM automatically retrieves RPG specifications from the target system. If you use a DDM file for PRTFILE, a compiled program listing is stored in the specified database file on the target system.
Back to the Top
Now that we have the basic concepts of DDM laid out, let's review our example. Your mission is to attach a new option to the inventory inquiry menu which gives users access to the inventory in the Loveland location. To accomplish this goal, you'll need to :
1. Establish a communications link between the two systems.
2. Create a DDM file in Carlsbad that points to the Loveland inventory file.
3. Clone your existing inventory inquiry application and make it point to the Loveland inventory file.
When your users want to know the inventory in the Loveland location, all they have to do is select the new menu option. The CL behind this menu option uses an OVRDBF command to point to the DDM file (RMTINV) in Carlsbad, which in turn points across the communications line to the inventory file (INVTOT) in Loveland. SDDM and TDDM will be busily exchanging data and the Loveland inventory will appear on the screens of your Carlsbad users.
DDM offers an elegantly simple way to access data on a remote system. Its performance is not the greatest, but its flexibility, simplicity and transparent user interface make DDM a tool you should take advantage of.
You and your MIS team will be doing lots of smiling when your boss asks how you managed to accomplish this task so fast. Just smile at him and say, "It's DDM Magic."
Kris Neely is the connectivity editor for Midrange Computing.
References
APPC Programmers Guide (SC41-8189) APPN Guide (SC41-8188) Communications Management Guide (SC41-0024) Distributed Data Management Guide (SC41-9600)
An Introductin to Distributed Data Management
Figure 1 The Display Network Attributes Screen
Display Network Attributes System: MC Current system name . . . . . . . . . . . . . . : MC Pending system name . . . . . . . . . . . . . : Local network ID . . . . . . . . . . . . . . . . : APPN Local control point name . . . . . . . . . . . . : LOVELAND Default local location . . . . . . . . . . . . . : LOVELAND Default mode . . . . . . . . . . . . . . . . . . : LU62 APPN node type . . . . . . . . . . . . . . . . . : *NETNODE Maximum number of intermediate sessions . . . . : 200 Route addition resistance . . . . . . . . . . . : 128 Server network ID/control point name . . . . . . : *LCLNETID *ANY More... Press Enter to continue. F3=Exit F12=Cancel
An Introductin to Distributed Data Management
Figure 2 The Create DDM File Command
Create DDM File (CRTDDMF) Type choices, press Enter. DDM file . . . . . . . . . . . . FILE > RMTINV Library . . . . . . . . . . . > INVLIB Remote file: RMTFILE File . . . . . . . . . . . . . > INVTOT Library . . . . . . . . . . > NEWINV Nonstandard file 'name' . . . _______________________________ ______________________________________________________________________________ ______________________________________________________________________________ _________________________________________________________________ Remote location . . . . . . . . RMTLOCNAME > LOVELAND Text 'description' . . . . . . . TEXT > 'DDM FOR REMOTE INVENTORY FILE' ___________________ Additional Parameters Device: DEV APPC device description . . . *LOC Local location . . . . . . . . . LCLLOCNAME *LOC Mode . . . . . . . . . . . . . . MODE *NETATR Remote network identifier . . . RMTNETID *LOC Access Method: ACCMTH Remote file attribute . . . . *RMTFILE Local access method . . . . . ___________ Share open data path . . . . . . SHARE *NO_ Record format level check . . . LVLCHK *RMTFILE Authority . . . . . . . . . . . AUT *LIBCRTAUT Replace file . . . . . . . . . . REPLACE *YES Bottom F3=Exit F4=Prompt F5=Refresh F12=Cancel F13=How to use this display F24=More keys
LATEST COMMENTS
MC Press Online