Examples: Access iSeries DDM remote files (iSeries-to-iSeries)
The examples show how access to a DDM file becomes an indirect reference (by using DDM) to the actual file on some other server. These examples are iSeries™-to-iSeries examples.
All of these examples assume that the DDM file on the local iSeries server is named DDMLIB/RMTCAR and that it is associated with a remote file named SALES/CAR on an iSeries server in Chicago.
Create a DDM file to access a remote file
CRTDDMF FILE(DDMLIB/RMTCAR) RMTFILE(SALES/CAR) RMTLOCNAME(CHICAGO) TEXT('Chicago file SALES/CAR')This command creates a DDM file named RMTCAR and stores it in the DDMLIB library on the local server. The remote file to be accessed is the CAR database file in the SALES library on the Chicago server. (The remote file is not accessed at the time the Create DDM File (CRTDDMF) command is used to create the DDM file. The existence of the file SALES/CAR is not checked when the DDM file is created.) Later, when the DDM file is accessed by a local program, the remote location CHICAGO is used by DDM to access the SALES/CAR file on the Chicago server.
Copy a local file to a remote file
CPYF FROMFILE(QGPL/AUTO) TOFILE(DDMLIB/RMTCAR)This command copies the data from the AUTO file in the QGPL library on the local server into a remote file named SALES/CAR on the Chicago server, by using the DDM file DDMLIB/RMTCAR.
Allocate a remote file and member for use
ALCOBJ OBJ((DDMLIB/RMTCAR *FILE *EXCL))The Allocate Object (ALCOBJ) command is used to allocate (lock) both the DDM file (RMTCAR) on the source server and the first member of the remote file (as well as the file itself) on the target server. In effect, the commandALCOBJ OBJ((SALES/CAR *FILE *EXCL *FIRST))is run on the target server.
Override a local file with a DDM file
OVRDBF FILE(FILEA) TOFILE(DDMLIB/RMTCAR) POSITION(*RRN 3000)This command overrides the database file FILEA with the DDM file RMTCAR, stored in the DDMLIB library. Both files are on the source server. Whatever remote file is identified in the DDM file (in this case, SALES/CAR on the Chicago system) is the file actually used by the source server program. When the remote file is opened, the first record to be accessed is record 3000.
Display records in a remote file
DSPPFM FILE(DDMLIB/RMTCAR)This command displays the records in the first member of the remote file SALES/CAR, which is associated with the DDM file DDMLIB/RMTCAR.
Display the object description of a DDM file
DSPOBJD OBJ(DDMLIB/RMTCAR) OBJTYPE(*FILE)This command displays, on the local server, the object description of the RMTCAR DDM file. No reference is made by this command to the associated remote file on the Chicago server.
Display the file description of a DDM file
DSPFD FILE(DDMLIB/RMTCAR) TYPE(*ATR) FILEATR(*DDM) SYSTEM(*LCL)This command displays, on the source server, the file description of the DDM file named RMTCAR in the DDMLIB library. As indicated by the TYPE parameter, the attributes of the DDM file are displayed. Only the DDM file's attributes are displayed because FILEATR(*DDM) is specified.
Because SYSTEM(*LCL) is specified, the attributes of the DDM file are displayed and the remote server is not accessed. If SYSTEM(*RMT) is specified, the attributes of the associated remote file are displayed. If *RMT or *ALL is specified, the remote server is accessed to get the attributes of the remote file.
Delete a DDM file
DLTF FILE(DDMLIB/RMTCAR) SYSTEM(*LCL)This command deletes the DDM file on the local server. Again, no reference is made to the associated SALES/CAR file on the Chicago server. If SYSTEM(*RMT) or SYSTEM(*FILETYPE) is specified, SALES/CAR on the Chicago server would be deleted.
Parent topic:
Access files with DDM