2009-01-08

Example: Copying an iSeries database file that has packed decimal fields to the QNetWare file system

Note:
Read the Code disclaimer information for important legal information.

Suppose you want to make an iSeries™ database file available to all NetWare users. If the database file is externally defined (using DDS) and has packed decimal fields, you cannot copy it directly to a file in QNetWare file system. You need to first copy it to a physical file; then you can copy it to a file in QNetWare. If fields are in packed decimal format, you need to create a logical file to convert the packed decimal fields to zoned decimal fields. The following example shows how to copy and convert a file that contains packed decimal fields. You can also see an example of how you might do this with an ILE C for iSeries program.

The file in this example is in library DATALIB and has the name CUSTCDT. You can refer to these example displays:

To copy the CUSTCDT database file to the QNetWare file system, you would follow these steps:

  1. Create a directory in the QNetWare file system to use for storing iSeries database files. For example, to create a directory on server SRVNW0A, you would enter:
      MKDIR DIR('/QNetWare/SRVNW0A.SVR/SYS/DTA')
    DTAAUT(*INDIR) OBJAUT(*INDIR) CRTOBJAUD(*NONE)
  2. To convert packed decimal fields to zoned decimal:
    1. Create a logical file CUSTCDTL over CUSTCDT:
      CRTLF FILE(DATALIB/CUSTCDTL) SRCFILE(DATALIB/QDDSSRC)
      CUSTCDTL is the name of the logical file, and DATALIB/QDDSSRC is the source physical file that contains the member CUSTCDTL. Example: DDS for logical file CUSTCDTL shows the DDS definition of such a logical file.

      Optionally, you can select a subset of fields you want to copy to QNetWare. Just put the fields you need into the logical file. You can also specify an ordering sequence on the logical file.

    2. To redefine packed decimal fields as zoned decimal, specify S for the data type for those fields.

      There is no need to specify other field definitions. The logical file is built over the physical file and copies all the field definitions from it.

  3. After you create the logical file, you can use it to copy the data to a program-described physical file. But first you must create the program-described physical file. To do that, you must know the record length of the logical file, because the program-described file must have the same record length. You can find the record length of the logical file by using the command:
    DSPFD FILE(CUSTCDTL) TYPE(*RCDFMT)

    The resulting display for the example logical file CUSTCDTL shows that it has a record length of 60:

                            Record  Format Level
    Format Fields Length Identifier
    CUSREC 11 60 3B84438D4C428
    Text . . . . . . . . . . . . . . . . . . . :
    Total number of formats . . . . . . . . . . : 1
    Total number of fields . . . . . . . . . . . : 11
    Total record length . . . . . . . . . . . . : 60
  4. Create the program-described physical file:

    CRTPF DATALIB/CUSTSTMF RCDLEN(60)

  5. Copy the logical file CUSTCDTL to the program-described physical file CUSTSTMF:

    CPYF FROMFILE(CUSTCDTL) TOFILE(CUSTSTMF) MBROPT(*ADD) FMTOPT(*NOCHK)

    FMTOPT(*NOCHK) is required because the record formats of the database files are different.

  6. Copy the program-described file CUSTSTMF into the QNetWare/SRVNW0A.SVR/SYS/DTA directory of the QNetWare file system that you created in step 1:
    1. On the iSeries command line, type CPYTOSTMF and press F4. The Copy to Stream File (CPYTOSTMF) display appears
    2. In the From database file member field, specify the path name of the CUSTSTMF program-described datasbase file 1 .
    3. In the To stream file field, specify the path name of the stream file 2 .

      In this case you would use the drive letter as a link to CUSTCDT.DAT.

    4. The default value for the Data conversion option causes iSeries to use the coded character set identifier (CCSID) equivalent of the stream file data code page and the database file CCSID to convert the data during the copy operation. To use your own translation table object instead, specify *TBL and enter the table name into the TBL parameter. 3
    5. If your database file has a CCSID of 65535, you must enter a valid CCSID code in the Database file CCSID field for your data to be correctly converted to ASCII. The values 0, 65534, and 65535 are not valid to use with this command. 4
    6. In the Stream file code page field, specify the ASCII code page of the NetWare server to convert the data. To obtain the code page of server SRVNW0A, you would enter:
        DSPMFSINF OBJ('/QNetWare/SRVNW0A.SVR/SYS/DTA')
      This example converts the database file data from CCSID 37 to ASCII code page 850. 5
  7. Now you can access the data from a NetWare workstation. Map a drive to the SYS volume of server SRVNW0A and then change into the DTA directory of the mapped drive.
  8. You can now look at the data in CUSTCDT.DAT (use any DOS editor), and you will see that the file no longer contains any field information. The application that accesses the data must know the record structure. To put more field information into the stream file (such as a field separator character), you must write your own program.
source :
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzaef/rzaefcpydatabase.htm

1 comment:

Angga's PC said...

tuh kan yad, kalo posting pake bahasa bule langsung tampil i-k-l-a-n nya. he2x. kunjung balik yah..