Test/Demo jobs for Indexed files - Contents by Part#


Part_1 - test/demo jobs for Indexed file I/O
- IDXFORMAT1, IDXFORMAT3, IDXFORMAT8,
- illustrating Indexed file formats with 'uvhd'
- copying files from Sequential to Indexed & back
- testing 'Variable Length' Indexed files IDXFORMAT3 & IDXFORMAT8

Part_2 - test/demo jobs for Indexed file 'UPDATES'
- intended to help you write uvcopy jobs to solve your unique problems.
- review Indexed file update instructions (set,red,wrt,upd,upw,del).
- demo jobs to update Indexed files (produpISF1,produpIDX32,produpISF3)
- master & detail test files provided to run the demo jobs
- add, update,& delete records in master files
- could help you to maintain your Indexed files

Part_3 - File & Record locking provided by D-ISAM & uvcopy.
- Operating Instructions to test/demo record locking
- test/demo results: console displays & test file listing
- uvcopy job listings (ISFlock1 & ISFlock2)

Prior to October 2008, only autolock was provided for record locking and 'deadlock' was possible. In Oct 2008 option 'l4' was extended to instructions 'red' & 'upd' to provided complete control over record locking.

Notes re uvcopy Indexed Files

  1. uvcopy can handle Indexed files compatible with Micro Focus COBOL which is usually used for mainframe COBOL conversions to unix/linux.

  2. 'uvcopy' with its Indexed file handling capability can replace many of the mainframe utilities that were used to maintain Indexed files on the mainframe (such as IDCAMS, EasyTrieve, FileAid, etc).

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

Part_1 uvcopy6.doc - test/demo jobs for Indexed file I/O

test uxcopy Indexed file handling - Contents

This section will illustrate several jobs used at UV Software using uxcopy to write IDXFORMAT8 files & read them back to verify file handling.


1B1. uxcopyIDXf8W - write various IDXf8 files to read back by uxcopyIDXf8R
- reads a text file & writes out 6 files with various options

1B2. uxcopyIDXf8R - read back various IDXf8 files written by uxcopyIDXf8W
- writes out the original text file (input to uxcopyIDXf8W)
- to verify file handling of the various formats

1B3. uxcopyIDXf8C - Copy 6 IDXf8 files written by uxcopyIDXf8W
- writes out same typ=... as input files
- to verify that we can copy variable length files unchanged
- can do that with 'cp' but uxcopy allows file maintenance
(select records, modify records, etc)

1C1. Operating Instructions to run test/demos uxcopyIDXf8W,8R,8C

1D1. I/O listings for test/demo job uxcopyIDXf8W
 input file listing (tmp/idxtest)
 output filenames in tmp1/...
- idxf8.dat,idxf8v60.dat,idxf8v60x1,
  idxf8v60x1y4,idxf8v60y4.dat,idxf8x1

1D2. uvhd hexdump of typ=IDXf8v60
- IDXFORMAT8, Indexed, Variable lth 60-252

1D3. IDXFORMAT3/8 file header record layout

1E1. I/O listings for test/demo job uxcopyIDXf3W
 input file listing (tmp/idxtest)
 output filenames in tmp1/...
- idxf3v60.dat/idx idxf3v60x1 idxf3v60x1y4
  idxf3v60y4.dat/idx idxf3x1y1 idxf3y1.dat/idx

1E2. uvhd hexdump of typ=IDXf3v60
- IDXFORMAT3, Indexed, Variable lth 60-252

These jobs are supplied in /home/uvadm/pf/demo/..., which is in the PFPATH of the supplied profile. You can run these at your site.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1A2. test Indexed Variable length file I/O

Purpose of this section

  1. The uxcopy jobs documented in this section were written to test the file handler for IDXFORMAT1,3,8 files, compatible with Micro Focus COBOL.

  2. This section will also help you to understand these file types & how you might use uxcopy to perform file maintenance on your variable length files.

  3. These uxcopy test jobs write 6 files to consolidate my test procedures. For file maintenance jobs, you would usually have only 1 file in & 1 file out, but these jobs show you how easy it would be to split 1 input file to multiple output files, possibly of different types. For example, you might read in a variable length indexed file & write out 1 or more text files with selected information to be sent to outside agencies.

  4. Also note that for simple file maintenancejobs, you can use 'uxcp' or 'uxsort'. You can run those with a 1 line command at the console or coded in a script. They also allow file type changes, selects, deletes, & limited record modifications. uxcp/uxsort are documented with uvcp/uvsort. See uvcp.htm#J1 & uvsort.htm#O1.

    uvcopy jobs to test typ=IDXf3 file options

Part_1 now gives priority to the jobs for testing IDXFORMAT8 (vs IDXFORMAT3), since IDXFORMAT8 allows files bigger than 2 gig & IDXFORMAT3 does NOT.

But there is a set of 'uxcopyIDXf3_' jobs to test write/read/copy for IDXFORMAT3 files. These are very similar & are not listed here, but you can of course view or print them from /home/uvadm/pf/demo/...

uxcopyIDXf3W
  • write various IDXf3 formats, for read back by uxcopyIDXf3R
  • same as uvcopyIDXf8W '1B1', but cannot handle files > 2 gig
uxcopyIDXf3R
  • read back IDXf3 files & convert back to text files
  • same as uvcopyIDXf8R '1B2', but cannot handle files > 2 gig
uxcopyIDXf3C
  • copy IDXf3 files written by uxcopyIDXf8W
  • same as uvcopyIDXf8C '1B3', but cannot handle files > 2 gig

compatibility with Micro Focus COBOL

Please see VSECOBOL.htm for samples of COBOL programs with IDXf3/IDXf8 files. VSECOBOL also includes scripts to prove uxcp compatibility with COBOL.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1B1. test Indexed Variable length file I/O

uxcopy job to WRITE typ=IDXFORMAT8 files

 # uxcopyIDXf8W - write various IDXFORMAT files to test uxcopy
 #              - by Owen Townsend, Jan30/06, updated Feb23/07
 #              - IDXFORMAT8 files created by Micro Focus COBOL EXTFH
 #              - file handler used by uxcp, uxsort, uxcopy, uxqrpg
 #
 # uxcopy uxcopyIDXf8W,fili1=dat1/idxtest,filo1=tmp1/idxf8,...,filo6=idxf8v60x1y4
 # ==============================================================================
 # uxcopy uxcopyIDXf8W    <-- same as above (files default)
 # ===================
 #
 #*uxcopyIDXf8W - write IDXf8 files for read back by uxcopyIDXf8R <-- this job
 # uxcopyIDXf8R - read back IDXf8 files written by uxcopyIDXf8W
 # uxcopyIDXf8C - copy files written by uxcopyIDXf8W, test recsize passthru
 # uxcopyIDXf3W - write IDXf3 formats for read back by uxcopyIDXf3R
 # uxcopyIDXf3R - read back IDXf3 files written by uxopyIDXf3W
 # uxcopyIDXf3C - copy files written by uxcopyIDXf3W, test recsize passthru
 #
 # OPTIONS: f1=IDXFORMAT1, f3=IDXFORMAT3, f8=IDXFORMAT8 (see www.microfocus.com)
 # x1=noindex, x2=indexed; y1=fixed, y2=variable, y4=scanback to last non-blank
 # v=min recsize, (maxsize declared by rcs=___)
 #
 #                      ** file types created **
 #
 # 1. IDXf8      - indexed, data maxsz 252+4 (since no minsz v optn)
 # 2. IDXf8v60   - indexed, variable format, but all 252+4 w/o option y4
 # 3. IDXf8v60y4 - indexed variable min v60+4, depending on last nonblank
 # 4. IDXf8x1    - noindex(x1), fixed 252, no IDX filehdr, same as typ=RSF
 #               - read back using typ=RSF, since no index & fixed lth (no v)
 # 5. IDXf8v60x1 - noindex(x1), varfmt, but all 252+4 w/o OPtion y4
 # 6. IDXf8v60x1y4 - noindex(x1), variable 60-252, depending on LNB
 #
 fili1=dat1/idxtest,typ=LST,rcs=256
 filo1=tmp1/idxf8,typ=IDXf8,rcs=252,isk1=0(4)            # fixed
 filo2=tmp1/idxf8v60,typ=IDXf8v60,rcs=252,isk1=0(4)      # varfmt fix252
 filo3=tmp1/idxf8v60y4,typ=IDXf8v60y4,rcs=252,isk1=0(4)  # variable 60->252
 filo4=tmp1/idxf8x1,typ=IDXf8x1,rcs=252                  # noindex fix252
 # - creates fixed lth seqntl (no IDXf8 filehdr), must use typ=RSF to read back
 #   (but uxcopyIDXf3W typ=IDXf3x1 does create IDXf3 hdr ?)
 filo5=tmp1/idxf8v60x1,typ=IDXf8v60x1,rcs=252            # noindex varfmt fix252
 filo6=tmp1/idxf8v60x1y4,typ=IDXf8v60x1y4,rcs=252        # noindex variable
 #

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

 @run
        opn    all
 #
 # begin loop to get input & write output files in various formats until EOF
 loop   get    fili1,a0              get next input record
        skp>   eof                   (cc set > at EOF)
        mvc    b0(252),a0            copy input to output area
 #
 # write output files in various formats until EOF
        put    filo1,b0              #IDXf8        - fixed rcs=252
        put    filo2,b0              #IDXf8v60     - varfmt fixed 252+4
        put    filo3,b0              #IDXf8v60y4   - varfmt 60-> 252
        put    filo4,b0              #IDXf8x1      - noindex fixed 252+4
        put    filo5,b0              #IDXf8v60x1   - noindex varfmt 252+4
        put    filo6,b0              #IDXf8v60x1y4 - noindex variable 60->252
        skp    loop
 #
 # EOF - close files & end job
 eof    cls    all
        msg    'Examine output files with "uvhd", example for output#1 above'
        msg    ' '
        msg    'uvhd tmp1/idxf8.dat v   <-- use "v" option for IDXf8 files'
        msg    '====================='
        eoj
 #
 #-------------------------- note re options --------------------------------
 #May13/07 - now pass recsize thru from last get to next put via $rv (rgstr v)
 #         - overruled if output typ not option v or option y1 or y4 spcfd
 # option 'v' writes records in the IDXf3/8 variable length format
 # option 'y1' writes fixed size records as spcfd by rcs=... on filo#=...
 # option 'y4' determines record length by scanning back from the rcs=...
 #             to the last non-blank (must omit length from op2 of 'put' instrn)
 #
 #------------------------- $rv passthru alternative --------------------------
 # You could write your own routine to determine the length & code the length
 # in a register in the op2 length of the 'put' instrn, for example:
 #
 #      scnr   b0(252),>' '          # scan back to last nonblank
 #      mvn    $rb,$rx               # save dsplcmnt in non-vol rgstr
 #      add    $rb,1                 # +1 for length
 #      put    filo3,b0($rb252)      # write size in $rb (max 252)
 #
 #------------------- script hang up on uxcopy #6 at UVSI ---------------------
 #
 # may hang up on #6 because I have only 1 user license for Micro Focus COBOL
 # - might bomb 'No Licenses available', if I did not have following in profile:
 #
 # export ASLMFRETRY="5,15"
 # ========================

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1B2. test Indexed Variable length file I/O

uxcopy job to READ typ=IDXFORMAT8 files

 # uxcopyIDXf8R - read back various IDXFORMAT files to test uxcopy
 #            - by Owen Townsend, Jan30/06, www.uvsoftware.ca
 #            - IDXFORMAT1,3,8 files created by Micro Focus COBOL EXTFH
 #            - file handler used by uxcp, uxsort, uxcopy, uxqrpg
 #
 # uxcopy uxcopyIDXf8R   <-- run job (see filenames on fili1-6/filo1-6 below)
 # ===================
 #
 # uxcopyIDXf8W - write IDXf8 files for read back by uxcopyIDXf8R
 #*uxcopyIDXf8R - read back IDXf8 files written by uxcopyIDXf8W   <-- this job
 # uxcopyIDXf8C - copy files written by uxcopyIDXf8W, test recsize passthru
 # uxcopyIDXf3W - write IDXf3 formats for read back by uxcopyIDXf3R
 # uxcopyIDXf3R - read back IDXf3 files written by uxopyIDXf3W
 # uxcopyIDXf3C - copy files written by uxcopyIDXf3W, test recsize passthru
 #
 # OPTIONS: f1=IDXFORMAT1, f3=IDXFORMAT3, f8=IDXFORMAT8 (see www.microfocus.com)
 # x1=noindex, x2=indexed; y1=fixed, y2=variable, y4=scanback to last non-blank
 # v=min recsize, (maxsize declared by rcs=___)
 #
 #*uxcopyIDXf8R - read back IDXf8 files written by uxcopyIDXf8W    <-- this job
 #              - writes text files typ=LSTt, which should be
 #                same as original file used to create the various IDXf8 files
 #
 # 1. IDXf8      - indexed, data maxsz 252+4 (since no minsz v optn)
 # 2. IDXf8v60   - indexed, variable format, but all 252+4 w/o option y4
 # 3. IDXf8v60y4 - indexed variable min v60+4, depending on last nonblank
 # 4. IDXf8x1    - noindex(x1), fixed 252, no IDX filehdr, same as typ=RSF
 #               - read back using typ=RSF, since no index & fixed lth (no v)
 # 5. IDXf8v60x1 - noindex(x1), varfmt, but all 252+4 w/o option y4
 # 6. IDXf8v60x1y4 - noindex(x1), variable 60-252, depending on LNB
 #
 fili1=tmp1/idxf8,typ=IDXf8,rcs=252,isk1=0(4)            # fixed rcs=252
 fili2=tmp1/idxf8v60,typ=IDXf8v60,rcs=252,isk1=0(4)      # varfmt fix252
 fili3=tmp1/idxf8v60y4,typ=IDXf8v60y4,rcs=252,isk1=0(4)  # variable 60->252
 fili4=tmp1/idxf8x1,typ=RSF,rcs=252                      # noindex fix252
 #  fili4 requires 'typ=RSF', Fixed Lth Seqntl (no IDXf8 filehdr)
 #  (note that typ=IDXf3x1 does create IDXf3 hdr ?)
 fili5=tmp1/idxf8v60x1,typ=IDXf8v60x1,rcs=252            # noindex varfmt fix252
 fili6=tmp1/idxf8v60x1y4,typ=IDXf8v60x1y4,rcs=252        # noindex variable
 #
 filo1=tmp2/idxf8L,typ=LSTt,rcs=252          # fixed rcs=252
 filo2=tmp2/idxf8v60L,typ=LSTt,rcs=252       # varfmt fix252
 filo3=tmp2/idxf8v60y4L,typ=LSTt,rcs=252     # variable 60->252
 filo4=tmp2/idxf8x1L,typ=LSTt,rcs=252        # noindex fix252
 filo5=tmp2/idxf8v60x1L,typ=LSTt,rcs=252     # noindex varfmt fix252
 filo6=tmp2/idxf8v60x1y4L,typ=LSTt,rcs=252   #noindex variable

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

 @run
        opn    all
 #
 # begin loop to get input & write output files in various formats until EOF
 man10  get    fili1,a0
        skp>   man20
        put    filo1,a0
        skp    man10
 #
 man20  get    fili2,a0
        skp>   man30
        put    filo2,a0
        skp    man20
 #
 man30  get    fili3,a0
        skp>   man40
        put    filo3,a0
        skp    man30
 #
 man40  get    fili4,a0
        skp>   man50
        put    filo4,a0
        skp    man40
 #
 man50  get    fili5,a0
        skp>   man60
        put    filo5,a0
        skp    man50
 #
 man60  get    fili6,a0
        skp>   man90
        put    filo6,a0
        skp    man60
 #
 # EOF - close files & end job
 man90  cls    all
        eoj
 #

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1B3. test Indexed Variable length file I/O

uxcopy job to COPY typ=IDXFORMAT8 files

 # uxcopyIDXf8C - read back various IDXFORMAT files to test uxcopy
 #            - by Owen Townsend, May13/07, www.uvsoftware.ca
 #            - IDXFORMAT1,3,8 files created by Micro Focus COBOL EXTFH
 #            - file handler used by uxcp, uxsort, uxcopy, uxqrpg
 #
 # uxcopy uxcopyIDXf8C   <-- run job (see filenames on fili1-6/filo1-6 below)
 # ===================
 #
 # uxcopyIDXf8W - write IDXf8 files for read back by uxcopyIDXf8R
 # uxcopyIDXf8R - read back IDXf8 files written by uxcopyIDXf8W
 #*uxcopyIDXf8C - copy files written by uxcopyIDXf8W, test recsize passthru <--*
 # uxcopyIDXf3W - write IDXf3 formats for read back by uxcopyIDXf3R
 # uxcopyIDXf3R - read back IDXf3 files written by uxopyIDXf3W
 # uxcopyIDXf3C - copy files written by uxcopyIDXf3W, test recsize passthru
 #
 # OPTIONS: f1=IDXFORMAT1, f3=IDXFORMAT3, f8=IDXFORMAT8 (see www.microfocus.com)
 # x1=noindex, x2=indexed; y1=fixed, y2=variable, y4=scanback to last non-blank
 # v=min recsize, (maxsize declared by rcs=___)
 #
 #May13/07 - pass thru recsize on $rv from get to put, if op2 lth omitted on put
 #         - if option 'v' spcfd & options y1/y4 not specified
 #
 #*uxcopyIDXf8C - read back IDXf8 files written by uxcopyIDXf8W    <-- this job
 #              - write out same typ=... as input files
 #              - verify output recsizes same as inputs (option v pass thru)
 #
 # 1. IDXf8      - indexed, data maxsz 252+4 (since no minsz v optn)
 # 2. IDXf8v60   - indexed, variable format, but all 252+4 w/o option y4
 # 3. IDXf8v60y4 - indexed variable min v60+4, depending on last nonblank
 # 4. IDXf8x1    - noindex(x1), fixed 252, no IDX filehdr, same as typ=RSF
 #               - read back using typ=RSF, since no index & fixed lth (no v)
 # 5. IDXf8v60x1 - noindex(x1), varfmt, but all 252+4 w/o option y4
 # 6. IDXf8v60x1y4 - noindex(x1), variable 60-252, depending on LNB
 #
 fili1=tmp1/idxf8,typ=IDXf8,rcs=252,isk1=0(4)            # fixed rcs=252
 fili2=tmp1/idxf8v60,typ=IDXf8v60,rcs=252,isk1=0(4)      # varfmt fix252
 fili3=tmp1/idxf8v60y4,typ=IDXf8v60y4,rcs=252,isk1=0(4)  # variable 60->252
 fili4=tmp1/idxf8x1,typ=RSF,rcs=252                      # noindex fix252
 #  fili4 requires 'typ=RSF', Fixed Lth Seqntl (no IDXf8 filehdr)
 #  (note that typ=IDXf3x1 does create IDXf3 hdr ?)
 fili5=tmp1/idxf8v60x1,typ=IDXf8v60x1,rcs=252            # noindex varfmt fix252
 fili6=tmp1/idxf8v60x1y4,typ=IDXf8v60x1y4,rcs=252        # noindex variable
 #
 filo1=tmp2/idxf8,typ=IDXf8,rcs=252                # fixed rcs=252
 filo2=tmp2/idxf8v60,typ=IDXf8v60,rcs=252          # varfmt fix252
 filo3=tmp2/idxf8v60y4,typ=IDXf8v60y4,rcs=252      # variable 60->252
 filo4=tmp2/idxf8x1,typ=RSF,rcs=252                # noindex fix252
 filo5=tmp2/idxf8v60x1,typ=IDXf8v60x1,rcs=252      # noindex varfmt fix252
 filo6=tmp2/idxf8v60x1y4,typ=IDXf8v60x1y4,rcs=252  #noindex variable

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

 @run
        opn    all
 #
 # begin loop to get input & write output files in various formats until EOF
 man10  get    fili1,a0
        skp>   man20
        put    filo1,a0
        skp    man10
 #
 man20  get    fili2,a0
        skp>   man30
        put    filo2,a0
        skp    man20
 #
 man30  get    fili3,a0
        skp>   man40
        put    filo3,a0
        skp    man30
 #
 man40  get    fili4,a0
        skp>   man50
        put    filo4,a0
        skp    man40
 #
 man50  get    fili5,a0
        skp>   man60
        put    filo5,a0
        skp    man50
 #
 man60  get    fili6,a0
        skp>   man90
        put    filo6,a0
        skp    man60
 #
 # EOF - close files & end job
 man90  cls    all
        eoj
 #

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1C1. test Indexed Variable length file I/O

test/demo IDXFORMAT8 Write/Read/Copy

You can run these demos after you have installed the Vancouver Utilities & setup the recommended profile with PATHs to the uv/ux utilities & PFPATHs to the uvcopy/uxcopy jobs (as documented at install.htm.

  1. Login as yourself ---> your home dir


 #2a. mkdir tmp      - for idxtest file from /home/uvadm/dat1
 #2b. mkdir tmp1     - for 6 output files from uxcopyIDXf8W
 #2c. mkdir tmp2     - for 6 output files from uxcopyIDXf8R
 #2d. mkdir tmp3     - for 6 output files from uxcopyIDXf8C

--- OR if subdirs already exist ---


 #2e. rm -f tmp/* tmp1/* tmp2/* tmp3/*

 #3. cp /home/uvadm/dat1/idxtest tmp   <-- get demo file from uvadm
     ===============================

 #4. uxcopy uxcopyIDXf8W    <-- Execute demo job to Write IDXf8 files
     ===================      - reads idxtest file from tmp subdir
                              - Writes 6 files (various types) into tmp1/...
                              - see uxcopy job listing on page '1B1'

 #5. ls -l tmp1             <-- display output files
     ==========

 #6a. uvhd tmp1/idxf8.dat v       <-- examine output files with uvhd
      =====================         - option 'v' for IDXFORMAT8 (or 3) files

 #6b. uvhd tmp1/idxf8v60.dat v    <-- see this file listed on page '1D2'
      ========================
 #6c. uvhd tmp1/idxf8v60y4.dat v
      ==========================
 #6d. uvhd tmp1/idxf8x1 r252      <-- option 'x1' writes fixed length seqntl file
      ======================
 #6e. uvhd tmp1/idxf8v60x1 v
      ======================
 #6f. uvhd tmp1/idxf8v60x1y4 v
      ========================

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1C2. test Indexed Variable length file I/O

test/demo IDXFORMAT8 Write/Read/Copy


 #7. uxcopy uxcopyIDXf8R   <-- Execute demo job to Read IDXf8 files
     ===================     - Reads 6 files of various types
                             - copies to sequential text files in tmp2/...
                             - extracting original text data from IDXf8 files

 #8. ls -l tmp2            <-- list output filenames
     ==========

 #9a. cat tmp2/idxf8L         <-- list output file contents
      ===============           - should be text files (same as original input)
 #9b. cat tmp2/idxf8v60L
      ==================
 #9c. cat tmp2/idxf8v60x1L
      ====================
 #9d. cat tmp2/idxf8v60x1y4L
      ======================
 #9e. cat tmp2/idxf8v60y4L
      ====================
 #9f. cat tmp2/idxf8x1L
      =================

 #10. uxcopy uxcopyIDXf8C   <-- Execute demo job to Copy IDXf8 files
      ===================   <-- reads 6 IDXf8 files of various types from tmp1
                              - Copies/writes 6 files of same types into tmp3

 #11. ls -l tmp3               <-- display output files
      ==========

 #12a. uvhd tmp3/idxf8.dat v        <-- examine output files with uvhd
       =====================          - option 'v' for IDXFORMAT8 (or 3) files

 #12b. uvhd tmp3/idxf8v60.dat v     <-- same as file listed on page '1D2'
       ========================

 #12c. uvhd tmp3/idxf8v60y4.dat v
       ==========================
 #12d. uvhd tmp3/idxf8x1 r252       <-- option 'x1' fixed length seqntl file
       ======================
 #12e. uvhd tmp3/idxf8v60x1 v
       ======================
 #12f. uvhd tmp3/idxf8v60x1y4 v
       ========================

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1D1. test Indexed Variable length file I/O

input text file for uxcopyIDXf3/uxcopyIDXf8

 0010.0060 idxtest text file to create Var Lth Indexed files.
 0020.0064 - input to COBOL,uxcp,uxcopy to create IDXf1,3,8 files
 0030.0065 - 01-04=ISAM key, 05=separator, 06-09=size, 10-400 text
 0040.0067 - output record varies from 64 to 256, depending on 06-09
 0050.0080 - here is an 80 byte record------------------------------------------>
 0060.0160 - here is a 160 byte record...........................................-----------------------------------------------
 0070.0240 - here is a 240 byte record (last record in file).....................-----------------------------------------------

tmp1 subdir listings after uxcpIDXf8W


 #1. -rw-rw-r--   1 uvadm   users    4864 May 13 13:57 idxf8.dat

 #2. -rw-rw-r--   1 uvadm   users    4112 May 13 13:57 idxf8v60.dat  <--see uvhd

 #3. -rw-rw-r--   1 uvadm   users     892 May 13 13:57 idxf8v60x1

 #4. -rw-rw-r--   1 uvadm   users     892 May 13 13:57 idxf8v60x1y4

 #5. -rw-rw-r--   1 uvadm   users    4112 May 13 13:57 idxf8v60y4.dat

 #6. -rw-rw-r--   1 uvadm   users    1764 May 13 13:57 idxf8x1
Note
  • IDXf8 files have only the .dat partition, but it includes indexes
  • unless option 'x1' specified or isk1=... not declared
  • IDXf3 Indexed files have 2 partitions .dat & .idx (see page '1E1')

Please see 'uvhd' hexdump listing of 'idxf8v60.dat' on the next page -->

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1D2. test Indexed Variable length file I/O

uvhd hexdump of IDXf8 file sample


 uvhd tmp1/idxf8v60.dat v       <-- option 'v' for IDXf8 (or IDXf3) files
 ========================
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 3.......0705131402518107051314025181.>.......................<..
             3F0000003333333333333333333333333333030000000000000000000F000300
             3E00000007051314025181070513140251810E0200180000106000000C000C00
          64 ............................................X"8*X"8*............
             0000000000000000000000000000000000000000000052325232000000000011
             00000007000022100000000000000000000000000008828A828A000000000000
         128 ................................................................
             00000011000000000000000000000000000000000000000F0000000000000000
             000000004244010400000040000000C0000000000000003E0000000000000000
                ----- system record 196-960 omitted (all x'00's) ----
         960 ................................................................
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
        3328 @<0010.0060 idxtest text file to create Var Lth Indexed files...
             4333332333326677677276772666627626766762567247624666766266667200
             0C0010E00600948453404584069C504F032514506120C4809E45854069C53E00
                      10        20        30        40        50        60
 r#        3 0123456789012345678901234567890123456789012345678901234567890123
        3392 @@0020.0064 - input to COBOL,uxcp,uxcopy to create IDXf1,3,8 fil
             4433332333322266777276244444277672776677276267667624456323232666
             000020E00640D09E05404F03F2FCC5830C583F0904F0325145094861C3C8069C
          64 es..
             6700
             5300
                      10        20        30        40        50        60
 r#        4 0123456789012345678901234567890123456789012345678901234567890123
        3464 @A0030.0065 - 01-04=ISAM key, 05=separator, 06-09=size, 10-400 t
             4433332333322233233345442667223337676767672233233376762233233327
             010030E00650D001D04D931D0B59C005D3501214F2C006D09D39A5C010D40004
          64 ext.
             6770
             5840
                      10        20        30        40        50        60
 r#        5 0123456789012345678901234567890123456789012345678901234567890123
        3536 @C0040.0067 - output record varies from 64 to 256, depending on
             4433332333322267777727666762767667267662332762333226676666662662
             030040E00670D0F540540253F240612953062FD06404F0256C04505E49E70FE0
          64 06-09...
             33233000
             06D09000
                      10        20        30        40        50        60
 r#        6 0123456789012345678901234567890123456789012345678901234567890123
        3608 @P0050.0080 - here is an 80 byte record-------------------------
             4533332333322266762672662332677627666762222222222222222222222222
             000050E00800D0852509301E080029450253F24DDDDDDDDDDDDDDDDDDDDDDDDD
          64 ----------------->..
             22222222222222222300
             DDDDDDDDDDDDDDDDDE00

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1D3. test Indexed Variable length file I/O

IDXORMAT3/IDXFORMAT8 file header layout

The Vancouver Utilities (uxcopy,uxsort,uxqrpg,uxcp,uvhd) are compatible with Micro Focus COBOL variable length sequential & Indexed files (IDXFORMAT3 & 8).

We will document the most important fields in the file header for IDXf3/IDXf8. If desired, you can find all fields defined on the Micro Focus website.

Note that you can investigate the file headers using 'uvhd' with option 'v' for IDXFORMAT3 or IDXFORMAT8. See sample on the previous page.

 000-003 - file header record length
         - 1st 4 bits x'30' identifies a system record
         - next 12 bits is header length if max record length is < 4095
         - next 28 bits is header length if max record length is => 4095

008-014 - creation date/time yymmddhhmmsscc (indexed files only)

039-039 - organization (1=seqntl, 2=indexed, 3=relative) 043-043 - file type (3=IDXFORMAT3, 8=IDXFORMAT8) 048-048 - recording mode (0=fixed, 1=variable)

 054-057 - maximum record length (big end format)
         - example recsize 80 = x'00000050'
 058-061 - minimum record length
 068-071 - record count (4 bytes Big-End Binary)
         - Indexed files only (not in variable length non-indexed file hdrs)

128-135 - offset to End-of-File (8 bytes binary big end format)

 140-141  - number of keys in Indexed file

record header layout

 000-000 - 1st 4 bits identifies the record type
 x'1_'   - system record - duplicate occurrence record
 x'2_'   - deleted record
 x'3_'   - system record
 x'4_'   - user data record
 x'5_'   - reduced user data record
 x'6_'   - pointer record
 x'7_'   - user data record referenced by a pointer record
 x'8_'   - reduced user data record referenced by a pointer record

000-001 - next 12 bits is the record length if max recsize < 4095 000-003 - next 28 bits is the record length if max recsize =? 4095 002-... - record data if max recsize < 4095 004-... - record data if max recsize => 4095

Note
  • all records are padded with x'00's to a multiple of 4 bytes

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1E1. test Indexed Variable length file I/O

input text file for uxcopyIDXf3/uxcopyIDXf8

 0010.0060 idxtest text file to create Var Lth Indexed files.
 0020.0064 - input to COBOL,uxcp,uxcopy to create IDXf1,3,8 files
 0030.0065 - 01-04=ISAM key, 05=separator, 06-09=size, 10-400 text
 0040.0067 - output record varies from 64 to 256, depending on 06-09
 0050.0080 - here is an 80 byte record------------------------------------------>
 0060.0160 - here is a 160 byte record...........................................-----------------------------------------------
 0070.0240 - here is a 240 byte record (last record in file).....................-----------------------------------------------

tmp1 subdir listings after uxcpIDXf3W


 #1. -rw-rw-r--   1 uvadm   users    1148 May 13 13:58 idxf3v60.dat
     -rw-rw-r--   1 uvadm   users    3072 May 13 13:58 idxf3v60.idx

 #2. -rw-rw-r--   1 uvadm   users     892 May 13 13:58 idxf3v60x1

 #3. -rw-rw-r--   1 uvadm   users     892 May 13 13:58 idxf3v60x1y4

 #4. -rw-rw-r--   1 uvadm   users    1148 May 13 13:58 idxf3v60y4.dat
     -rw-rw-r--   1 uvadm   users    3072 May 13 13:58 idxf3v60y4.idx

 #5. -rw-rw-r--   1 uvadm   users    1764 May 13 13:58 idxf3x1y1

 #6. -rw-rw-r--   1 uvadm   users    1920 May 13 13:58 idxf3y1.dat
     -rw-rw-r--   1 uvadm   users    3072 May 13 13:58 idxf3y1.idx
Note
  • IDXf3 Indexed files have 2 partitions .dat & .idx
  • IDXf8 files have only the .dat partition, but it includes indexes
  • unless option 'x1' is specified for a non-indexed file

Please see 'uvhd' hexdump listing of 'idxf3v60.dat' on the next page -->

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

1E2. test Indexed Variable length file I/O

uvhd hexdump of IDXf3 file sample


 uvhd tmp1/idxf3v60.dat
 ======================
                      10        20        30        40        50        60
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 0~......0705131358591507051313585915.>.......................<..
             370000003333333333333333333333333333030000000000000000000F000300
             0E00000007051313585915070513135859150E0200000000100000000C000C00
          64 ............................................X"8*................
             0000000000000000000000000000000000000000000052320000000000000000
             00000000000020100000000000000000000000000000828A0000000000000000
                      10        20        30        40        50        60
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
         384 @<0010.0060 idxtest text file to create Var Lth Indexed files...
             4333332333326677677276772666627626766762567247624666766266667200
             0C0010E00600948453404584069C504F032514506120C4809E45854069C53E00
                      10        20        30        40        50        60
 r#        3 0123456789012345678901234567890123456789012345678901234567890123
         448 @@0020.0064 - input to COBOL,uxcp,uxcopy to create IDXf1,3,8 fil
             4433332333322266777276244444277672776677276267667624456323232666
             000020E00640D09E05404F03F2FCC5830C583F0904F0325145094861C3C8069C
          64 es..
             6700
             5300
                      10        20        30        40        50        60
 r#        4 0123456789012345678901234567890123456789012345678901234567890123
         516 @A0030.0065 - 01-04=ISAM key, 05=separator, 06-09=size, 10-400 t
             4433332333322233233345442667223337676767672233233376762233233327
             010030E00650D001D04D931D0B59C005D3501214F2C006D09D39A5C010D40004
          64 ext.
             6770
             5840
                      10        20        30        40        50        60
 r#        5 0123456789012345678901234567890123456789012345678901234567890123
         584 @C0040.0067 - output record varies from 64 to 256, depending on
             4433332333322267777727666762767667267662332762333226676666662662
             030040E00670D0F540540253F240612953062FD06404F0256C04505E49E70FE0
          64 06-09...
             33233000
             06D09000
                      10        20        30        40        50        60
 r#        6 0123456789012345678901234567890123456789012345678901234567890123
         656 @P0050.0080 - here is an 80 byte record-------------------------
             4533332333322266762672662332677627666762222222222222222222222222
             000050E00800D0852509301E080029450253F24DDDDDDDDDDDDDDDDDDDDDDDDD
          64 ----------------->..
             22222222222222222300
             DDDDDDDDDDDDDDDDDE00

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

Part_2 test/demo jobs for Indexed file updates

Demo jobs for Indexed file updates - Contents

This section includes several sample uvcopy jobs & is intended to help you to write uvcopy jobs to maintain your Indexed files on Unix/Linux/Windows.


2A1. Review of Indexed file update instructions (set, red, wrt, upd, upw, del).
See primary documentation for these instructions in uvcopy3.htm.

2B1. produpISF1 - update typ=ISF Indexed master file with details
(adds,updates,deletes)
- applies when detail updating records contain all master fields

2C1. produpISF2 - update typ=ISF Indexed master file with details
- applies when master records contain fields that must be
preserved (such as sales history, etc)

2D1. produpISF3 - update typ=ISF Indexed master file with details
- applies when detail updating records contain all master fields
and you don't care if the record was already on file or not
- uses the 'upw' instruction which combines upd & wrt.

similar jobs for IDXFORMAT3 & IDXFORMAT8

produpIDX31
  • same as produpISF1 above, but for IDXFORMAT3 (typ=ISXf3)
produpIDX32
  • same as produpISF2 above, but for IDXFORMAT3 (typ=ISXf3)
produpIDX33
  • same as produpISF3 above, but for IDXFORMAT3 (typ=ISXf3)
produpIDX81
  • same as produpISF1 above, but for IDXFORMAT8 (typ=ISXf8)
produpIDX82
  • same as produpISF2 above, but for IDXFORMAT8 (typ=ISXf8)
produpIDX83
  • same as produpISF3 above, but for IDXFORMAT8 (typ=ISXf8)

Test files are supplied for the various uvcopy/uxcopy demo jobs. The test files are listed before & after updates. You are encouraged to run these jobs & verify your results.

dat1/prodmas1
  • product master file
  • a text file that is loaded into an indexed file in the
    /home/uvadm/tmp subdir before update jobs are executed.
dat1/produpdts
  • product detail updates (adds,updates,deletes)

The update instructions apply to both typ=ISF & typ=IDX Indexed files. 'typ=ISF' is compatibility with C-ISAM & MF COBOL FIXED IDXFORMAT1. 'typ=IDXf3/f8' are compatibility with Micro Focus COBOL Variable IDXFORMAT3/8. Note that typ=IDX is provided by an alternate version of uvcopy, named 'uxcopy' which is linked with Micro Focus EXTFH.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2A1. Demo jobs for Indexed file Updates

Instructions for Indexed Files (set,red,wrt,upd,upw,del)


 #1. set - set key of reference & file pointer in an Indexed file
     ===
     setk2m7 filr1,c0       - select key 2 & set ptr => key in area c

'set' will change the current record position (file pointer) to the key value stored in the record area. Option 'm' determines the comparison between the key value & the record position set (m5=, m6>, m7=>).


 #2. red - read a record from an indexed file
     ===
     redm7 filr1,r0           - read record whose key => stored key
     skp=  found                cc set = if record found & no err
     skp!  nofind               cc set not= if no matching record found

 #3. wrt - write a new record into an Indexed file
     ===
     wrt   filr1,b0           - write record b0(rcsz) to filr1
     skp=  ok                   cc set = if no errors
     skp!  dup                  cc not= if duplicate key (record already exists)

The data record to be added must be stored in the op2 area. The record will be added to file & all key indexes updated.


 #4. upd - update a record in an Indexed file
     ===
     upd   filr1,r0            - update record r0(rcsz) in filr1
     skp=  ok                    cc set = if no errors

The record to be updated must be stored in the op2 record area and must already exist. The primary key is used to access & rewrite the record. uvcopy does not allow duplicates on the primary key.


 #5. del - delete a record in an Indexed file
     ===
     del   filr1,r0            - delete record r0(rcsz) in filr1
     skp=  ok                    cc set = if no errors

The key of the record to be deleted must be stored in its proper location in the op2 record area & the record must already exist. uvcopy does not allow duplicates on the primary key.


 #6. upw - update/write record depending on key present/absent
     ===
     upw   filr1,r0            - update record r0(rcsz) in filr1
     skp=  updated               cc set = if existing record updated
     skp<  inserted              cc set < if new record inserted

'upw' combines the functions of 'upd' & 'wrt'. upw will update the record if the key already exists, otherwise it will insert(write) a new record. 'upw' makes the coding simpler (can omit condition code testing), when you don't have to care whether the record is already present or not.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2B1. Demo jobs for Indexed file Updates

produpISF1 - demo update typ=ISF Indexed file

prodmas1 file Before updates

The product master is supplied as a text file (/home/uvadm/dat1/prodmas1) that must be loaded to an Indexed file in the tmp subdir before the update job is executed. In fact the uvcopy update job will do this automatically using a 'sys' instruction to execute the 'uvcp' command. See listing next page.

           1         2         3         4
 01234567890123456789012345678901234567890
 product# description           price
 =========================================
 BBQ010   BAR-B-Q              0019500
 CHR015   LAWN CHAIR           0004500
 HAM010   CLAW HAMMER          0000950
 HAM020   BALL PEEN HAMMER     0001200
 HAM035   JACK HAMMER          0029500
 SAW011   HAND SAW             0001975
 SAW012   RIP SAW              0002500
 SAW051   POWER SAW            0008500
 TAB012   LAWN TABLE           000850W

dat1/produpdts - product detail file of Updates, Adds, Deletes

 SAW051 U B&D POWER SAW        0008500
 RAKE10 A GARDEN RAKE          0001375
 SAW012 D
 UMB030 A PATIO UMBRELLA       0003900
 HAM010 U HAMMER SPECIAL       0000595

Execute test/demo job produpISF1


 #1. uvcopy produpISF1     <-- update of tmp/prodISF1 with dat1/produpdts
     =================

See resulting updated master file listed on the next page --->

See the produpISF1 uvcopy job listed 2 pages ahead --->

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2B2. produpISF1 - test/demo update typ=ISF Indexed file

<-- See input master file & detail file listed on the previous page.

Execute test/demo job & verify results


 #1. uvcopy produpISF1     <-- update of tmp/prodISF1 with dat1/produpdts
     =================

 #2. cat tmp/prodISF1      <-- display the updated master file
     ================          (in PHYSICAL SEQUENCE)

tmp/prodISF1 file AFTER updates

 BBQ010   BAR-B-Q              0019500
 CHR015   LAWN CHAIR           0004500
 HAM010 U HAMMER SPECIAL       0000595
 HAM020   BALL PEEN HAMMER     0001200
 HAM035   JACK HAMMER          0029500
 SAW011   HAND SAW             0001975
 UMB030 A PATIO UMBRELLA       0003900
 SAW051 U B&D POWER SAW        0008500
 TAB012   LAWN TABLE           000850W
 RAKE10 A GARDEN RAKE          0001375

Alternative method to list updated file


 #2. uvcopy listISF,fili1=tmp/prodISF1,filo1=tmp/ISF.txt <-- convert ISF to text
     ===================================================

 #3. cat tmp/ISF.txt      <-- display text file created from ISF updated file
     ===============          (now in KEY SEQUENCE)
 BBQ010   BAR-B-Q              0019500
 CHR015   LAWN CHAIR           0004500
 HAM010 U HAMMER SPECIAL       0000595
 HAM020   BALL PEEN HAMMER     0001200
 HAM035   JACK HAMMER          0029500
 RAKE10 A GARDEN RAKE          0001375
 SAW011   HAND SAW             0001975
 SAW051 U B&D POWER SAW        0008500
 TAB012   LAWN TABLE           000850W
 UMB030 A PATIO UMBRELLA       0003900

'listISF' is a supplied pre-programmed uvcopy job that can be used to convert any typ=ISF file to a text file for easier display/list with vi, cat, lp, etc. Note that listISF will list the records in key sequence, whereas cat or vi shows them in the physical sequence. Compare these typ=ISF methods to the techniques used after produpIDX32 to list typ=IDXf3 files, which can not be listed directly with vi,cat,etc, and must be displayed with uvhd, or converted with listIDX.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2B3. produpISF1 - test/demo update typ=ISF Indexed file

 # produpISF1 - uvcopy Parameter File from UVSI stored in: /home/uvadm/pf/demo/
 # produpISF1 - update product master file with detail file (updates,adds,deletes)
 #            - test/demo Indexed file instructions (upd,wrt,del)
 #              when updates can replace entire master rec (else see produpISF2)
 #            - this job for typ=ISF Indexed Sequential FIXED C-ISAM/D-ISAM files
 #            - must load ISF file to tmp subdir from text file (see sys below)
 #
 #usage: uvcopy produpISF1   <-- use uvcopy for typ=ISF (vs uxcopy for typ=IDX)
 #       =================
 #
 opr='produpISF1 - uvcopy job to demo ISF random updates (upd,wrt,del)'
 fili1=dat1/produpdts,rcs=80,typ=LST
 filr1=tmp/prodISF1,rcs=80,typ=ISF
 filo1=tmp/produpERRS,rcs=80,typ=LSTt
 @run
        msgwy  'load ISF file to tmp subdir y/n ? (via sys & uvcp)'
        skp!    man10
        sys    'uvcp "fili1=dat1/prodmas1,rcs=80,typ=LST,filo1=tmp/prodISF1,typ=ISF,isk1=0(6)"'
 man10  opn     all
 # begin loop to get/put records until EOF
 man20  get     fili1,a0
        skp>    eof
        mvc     b0(80),a0             store detail in random I/O area
 #
 # test command col 8 - update or delete ?
 man24  cmc     a7(1),'U'             update ?
        skp=    man30
        cmc     a7(1),'A'             write new record ?
        skp=    man40
        cmc     a7(1),'D'             delete ?
        skp=    man50
        msg     a0(72)                display detail rec in error
        msgw    'update command invalid (not U,A,D) - enter to bypass'
        skp     man20
 #
 # update existing record - replace entire record
 man30  upde3   filr1,b0              REPLACE existing record
        skp!    man60
        skp     man20
 # add/write new record
 man40  wrte3   filr1,b0             write new record
        skp!    man60
        skp     man20
 # delete record
 man50  dele3   filr1,b0              delete
        skp!    man60
        skp     man20
 #
 # common error routine - if cc not good after upd,wrt,del
 # note - option 'e3' on upd,wrt,del above reports errors to screen
 man60  put     filo1,a0              write detail to err file
        skp     man20
 eof    cls     all
        eoj

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2B4. produpISF1 - test/demo update typ=ISF Indexed file

NOTE1 (see prior page)

    msgwy 'load ISF file to tmp subdir y/n ? (via sys & uvcp)'        #<-NOTE1->
    skp!   man10
    sys   'uvcp "fili1=dat1/prodmas1,rcs=80,typ=LST,filo1=tmp/prodISF1,typ=ISF,isk1=0(6)"'

'msgwy' displays message & waits for operator to reply y/n. Reply 'y' will load the Indexed file for the update test, via the 'sys' instruction. In this case 'sys' runs the 'uvcp' utility, but you can use sys to run any command.

You might reply 'n' on a 2nd run to bypass the master file load & see what happens when you apply the updates a 2nd time. Try it, see if errors occur ?

NOTE2 (see prior page)

 # update existing record - replace entire record
 man30  upde3   filr1,b0              REPLACE existing record         #<-NOTE2->

This update (in produpISF1) replaces the entire record in the master file with a new record from the detail file. Compare this to the next job (produpIDX32) which updates only part of the master record (preserving the sales history).

produpIDX32 preserves the sales history by 1st reading the existing master record (via 'redm5') & moving only the new description & price into the record.

NOTE3 (see prior page)

 # common error routine - if cc not good after upd,wrt,del
 # note - option 'e3' on upd,wrt,del above reports errors to screen
 man60  put     filo1,a0              write detail to err file        #<-NOTE3->

This writes any detail update records that caused errors to a separate file (tmp/produpERRS) for subsequent investigation. Try running the update a 2nd time (as suggested in NOTE1 above) & see if you get anything in this file ?

As noted above, option 'e3' can be coded on upd, wrt, del to display error messages if no record is found for upd, or record already onfile for wrt. In some cases, this might replace the necessity of the error file ?

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2C1. Demo jobs for Indexed file Updates

produpIDX32 - demo update typ=IDXf3 Indexed file

prodmas2 file Before updates

The product master is supplied as a text file (/home/uvadm/dat1/prodmas2) that must be loaded to an Indexed file in the tmp subdir before the update job is executed. In fact the uxcopy update job will do this automatically using a 'sys' instruction to execute the 'uvcp' command. See 2 pages ahead.

           1         2         3         4         5         6         7
 01234567890123456789012345678901234567890123456789012345678901234567890123456789
 product# description           price     thisyear  lastyear  2yrs ago  3yrs ago
 ===============================================================================
 BBQ010   BAR-B-Q              0019500   000000000 000039000 000078000 000019500
 CHR015   LAWN CHAIR           0004500   000013500 000090000 000004500 000018000
 HAM010   CLAW HAMMER          0000950   000009500 000000950 000001800 000003800
 HAM020   BALL PEEN HAMMER     0001200   000012000 000003600 000002400 000000000
 HAM035   JACK HAMMER          0029500   000000000 000059000 000000000 000000000
 SAW011   HAND SAW             0001975   000003850 000019750 000000000 000001975
 SAW012   RIP SAW              0002500   000000000 000000000 000000000 000000000
 SAW051   POWER SAW            0008500   000017000 000008500 000008500 000008500
 TAB012   LAWN TABLE           0007500   000015000 000037500 000000750 000000000

dat1/produpdts - product detail file of Updates, Adds, Deletes

 SAW051 U B&D POWER SAW        0008500
 RAKE10 A GARDEN RAKE          0001375
 SAW012 D
 UMB030 A PATIO UMBRELLA       0003900
 HAM010 U HAMMER SPECIAL       0000595

Run test/demo job & verify results


 #1. uxcopy produpIDX32     <-- update of tmp/prodIDX32 with dat1/produpdts
     ==================
Note
  • you will get 1 ERR 'command invalid (not U,A,D) - enter to bypass'
  • intentional error ('D' not coded, see listing 2 pages ahead)

See resulting updated master file listed on the next page --->

See the produpIDX32 uxcopy job listed 2 pages ahead --->

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2C2. produpIDX32 - test/demo update typ=IDXf3 Indexed file

<-- See input master file & detail file listed on the previous page.


 #1. uxcopy produpIDX32     <-- update of tmp/prodIDX32 with dat1/produpdts
     ==================

 #2. uxcopy listIDX,fili1=tmp/prodIDX32,filo1=tmp/IDX32.txt <-- cnvt IDX to text
     ======================================================

 #3. cat tmp/IDX32.txt        <-- display updated file contents
     =================

tmp/prodIDX32 file AFTER updates

 BBQ010   BAR-B-Q              0019500   000000000 000039000 000078000 000019500
 CHR015   LAWN CHAIR           0004500   000013500 000090000 000004500 000018000
 HAM010 U HAMMER SPECIAL       0000595   000009500 000000950 000001800 000003800
 HAM020   BALL PEEN HAMMER     0001200   000012000 000003600 000002400 000000000
 HAM035   JACK HAMMER          0029500   000000000 000059000 000000000 000000000
 RAKE10 A GARDEN RAKE          0001375   000000000 000000000 000000000 000000000
 SAW011   HAND SAW             0001975   000003850 000019750 000000000 000001975
 SAW012   RIP SAW              0002500   000000000 000000000 000000000 000000000
 SAW051 U B&D POWER SAW        0008500   000017000 000008500 000008500 000008500
 TAB012   LAWN TABLE           0007500   000015000 000037500 000000750 000000000
 UMB030 A PATIO UMBRELLA       0003900   000000000 000000000 000000000 000000000

uvhd Alternative to display typ=IDXf3 files

'typ=IDXf3' are complex files that cannot be displayed with text type utilities (such as vi, cat, lp, etc). 'listIDX' above is a uxcopy job that converts any typ=IDXf3 file into a text file that may be displayed with vi,cat,lp,etc. Alternatively, you can use 'uvhd' with option 'v' to view directly:


 uvhd tmp/prodIDX32 v     <-- hexdump display for typ=IDXf3 files
 ====================
                       1         2         3         4         5         6
 r#        1 0123456789012345678901234567890123456789012345678901234567890123
           0 0~......0302101322449003021013224490.>...................P...(..
             3700000033333333333333333333333333330300000000000000000005000200
             0E00000003021013224490030210132244900E02000000001000000000000800
          64 ............................................X.6.................
             00000000000000000000000000000000000000000000503E0000000000000000
             0000000000002010000000000000000000000000000080600000000000000000
                       1         2         3         4         5         6
 r#        2 0123456789012345678901234567890123456789012345678901234567890123
         212 @OBBQ010   BAR-B-Q              0019500   000000000 000039000 00
             4444533322244524252222222222222233333332223333333332333333333233
             0F221010000212D2D10000000000000000195000000000000000000039000000
          64 0078000 000019500...
             33333332333333333000
             00780000000019500000

uvhd displays the system header record, followed by the data records. In this case only the 1st data record is shown, but the others can be seen in the text file display above from th listIDX conversion job.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2C3. produpIDX32 - test/demo update typ=IDXf3 Indexed file

 # produpIDX32 - update product master file with details (updates,adds,deletes)
 #            - test/demo Indexed file instructions (upd & wrt)
 #            - updates master file with ytd sales fields that must be preserved
 #              (vs produpIDX31 where entire master record is replaced by detail)
 #            - this job for typ=IDX Indexed Sequential Variable IDXFORMAT3 files
 #              (see produpISF1 for 'typ=ISF' C-ISAM/D-ISAM Fixed files)
 #            - must load IDX file to tmp subdir from text file (see sys below)
 #Jan2006 - update IDX to IDX
 #
 #usage: uxcopy produpIDX32   <-- use uxcopy for typ=IDX (vs uvcopy for typ=ISF)
 #       ==================
 #
 opr='produpIDX32 - uxcopy job to demo IDX random updates (upd & wrt)'
 fili1=dat1/produpdts,rcs=80,typ=LST
 filr1=tmp/prodIDX32,rcs=80,typ=IDXf3v40
 filo1=tmp/produpERRS,rcs=80,typ=LSTt
 @run
        msgwy  'load IDXf3 file to tmp subdir y/n ? (via sys & uvcp)'
        skp!    man10
        sys    'uxcp "fili1=dat1/prodmas2,rcs=80,typ=LST,filo1=tmp/prodIDX32,typ=IDXf3v40,isk1=0(6)"'
 man10  opn     all
 # begin loop to get/put records until EOF
 man20  get     fili1,a0
        skp>    eof
        mvc     b0(80),a0             store detail in random I/O area
 # test command col 8 - update or delete ?
 man24  cmc     a7(1),'U'             update ?
        skp=    man30
        cmc     a7(1),'A'             write new record ?
        skp=    man40
        msg     a0(72)                display detail rec in error
        msgw    'update command invalid (not U,A,D) - enter to bypass'
        skp     man20
 # update existing record
 man30  redm5   filr1,b0              read by stored key to see if present ?
        skp!    man60                 if not found - goto err rtn
        mvc     b6(34),a6             move new dscrptn & price into master <-NOTE
        upd     filr1,b0              update existing record
        skp!    man60                 if any err - goto err rtn
        skp     man20
 # add/write new record (must not be present)
 man40  redm5   filr1,b0              read by stored key to see if present ?
        skp=    man60                 if already present - goto err rtn
        mvc     b40(40),'000000000 000000000 000000000 000000000 '
        wrt     filr1,b0              write new record
        skp!    man60                 if any err - goto err rtn
        skp     man20
 # common error routine - if cc not good after upd,wrt,del
 man60  cat     a0(80),'ERR: rec absent for update, or present for add ?'
        msg     a0(80)                display errmsg
        put     filo1,a0              write detail to err file
        skp     man20
 eof    cls     all
        eoj

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2C4. produpIDX32 - test/demo update typ=IDXf3 Indexed file

NOTE1 (see prior page)

 filr1=tmp/prodIDX32,rcs=80,typ=IDXf3v40                              #<-NOTE1->

Since this job loads & updates a typ=IDXf3 file (vs typ=ISF on previous job), we declare a minimum record size via option 'v' on typ=IDXf3v40 & the maximum record size is declared via the rcs keyword on rcs=80. When a minimum recsize is declared (via option 'v'), uxcopy automatically determines the record length by scanning back to the last nonblank.

This is insignificant in this case since the master records are 79 bytes of data, plus a 2 byte record header, rounded up to a multiple of 4. This makes the records 84 bytes, which can be seen on the 'uvhd' record dump at the bottom of page '2C2'.

NOTE2 (see prior page)

 # update existing record
 man30  redm5   filr1,b0              read by key, see if onfile ?    #<-NOTE2->
        skp!    man60                 if not found - goto err rtn
        mvc     b6(34),a6             move new dscrptn+price into master
        upd     filr1,b0              update existing record

Compare the coding here (in produpIDX32) to the corresponding code in the previous job (produpISF1).

Here we need to read before update, since we are updating only part of the master records (description & price) & we need to preserve the sales history.

NOTE3 (see prior page)

 # add/write new record (must not be present)
 man40  redm5   filr1,b0              read by key to see if onfile ?  #<-NOTE3->
        skp=    man60                 if already onfile - goto err rtn
        mvc     b40(40),'000000000 000000000 000000000 000000000 '
        wrt     filr1,b0              write new record

Since we are creating a new product master, we initialize the sales history fields to all zeros.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2D1. Demo jobs for Indexed file Updates

produpISF3 - demo update using 'upw' (vs upd + wrt)

Please see 'produpISF3' listed on the next page --->

We will not illustrate the test data files before & after update as we did for the previous jobs since the results are exactly the same as for produpISF1.

NOTE1 (see next page)

 # update existing record OR add/write new record
 # - depending on master file record present or absent
 # - 'upw' combines 'upd' & 'wrt', but can only be used when master
 #    record has no existing data fields that must be preserved
 #    (ie - data that is not in the updating detail records)
 man30  upw     filr1,b0              update/write existing/new record  #<-NOTE1

The description in this code says it all. 'upw' reduces the code & is convenient when the master record has no data that needs to be preserved, ie the detail updating record can simply replace the entire existing master record.

You can run 'upw' update jobs a 2nd time without generating any errors (as would happen with the previous jobs), since the 2nd time the original 'adds would be perceived as 'updates'.

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

2D2. produpISF3 - test/demo update using 'upw' (vs upd + wrt)

 # produpISF3 - uvcopy Parameter File from UVSI stored in: /home/uvadm/pf/demo/
 # produpISF3 - update product master file with detail file (updates,adds,deletes)
 #            - test/demo Indexed file instructions - 'upw' vs upd+wrt
 #              when updates can replace entire master rec (else see produpISF2)
 #            - this job for typ=ISF Indexed Sequential FIXED C-ISAM/D-ISAM files
 #              (vs produpIDX33 typ=IDXf3 Indexed Sequential Variable IDXFORMAT3)
 #            - must load ISF file to tmp subdir from text file (see sys below)
 #
 #usage: uvcopy produpISF3   <-- use uvcopy for typ=ISF (vs uxcopy for typ=IDXf3)
 #       =================
 #
 opr='produpISF3 - uvcopy job to demo ISF random updates "upw" vs upd+wrt'
 fili1=dat1/produpdts,rcs=80,typ=LST
 filr1=tmp/prodISF3,rcs=80,typ=ISF
 filo1=tmp/produpERRS,rcs=80,typ=LSTt
 @run
        msgwy  'load ISF file to tmp subdir y/n ? (via sys & uvcp)'
        skp!    man10
        sys    'uvcp "fili1=dat1/prodmas1,rcs=80,typ=LST,filo1=tmp/prodISF3,typ=ISF,isk1=0(6)"'
 man10  opn     all
 # begin loop to get/put records until EOF
 man20  get     fili1,a0
        skp>    eof
        mvc     b0(80),a0             store detail in random I/O area
 # test command col 8 - update or delete ?
 man24  cmc     a7(1),'U'             update ?
        skp=    man30
        cmc     a7(1),'A'             write new record ?
        skp=    man30                 (same code for upw vs upd+wrt)
        cmc     a7(1),'D'             delete ?
        skp=    man50
        msg     a0(72)                display detail rec in error
        msgw    'update command invalid (not U,A,D) - enter to bypass'
        skp     man20
 #
 # update existing record OR add/write new record
 # - depending on master file record present or absent
 # - 'upw' combines 'upd' & 'wrt',  but can only be used when master record
 #    has no existing data fields that must be preserved
 #    (ie - data that is not in the updating detail records)
 man30  upw     filr1,b0              update/write existing/new record
        skp!    man60
        skp     man20
 # delete record
 man50  dele3   filr1,b0              delete
        skp!    man60
        skp     man20
 # common error routine - if cc not good after upd,wrt,del
 # note - option 'e3' on upd,wrt,del above reports errors to screen
 man60  put     filo1,a0              write detail to err file
        skp     man20
 #
 eof    cls     all
        eoj

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

Part_3 uvcopy6.doc - test/demo jobs for Indexed file I/O

Part 3 - Record Locking


3A1. File & Record locking provided by D-ISAM & uvcopy.

3B1. Operating Instructions to test/demo record locking

3B2. Demo results: console displays & test file listing

3C1. uvcopy job 'ISFlock1' to demo record locking (1st of 2 jobs)

3C2. uvcopy job 'ISFlock2' to demo record locking (2nd of 2 jobs)

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

3A1. uvcopy6.doc - test/demo jobs for Indexed file I/O

File & Record Locking provided by D-ISAM & uvcopy

D-ISAM provides the following locking modes, invoked by options l0,l1,l2,l4 via typ=ISFl# on the filr_ declaration:

  1. l1 - read-only file lock (default)

  2. l0 - No locking (multi-job updates would corrupt the file)

  3. l2 - autolock record locking, requires only typ=ISFl2 on filr1 declaration.

  4. l4 - manulock record locking, requires option l4 on filr1, read,& update.

Prior to October 2008, only autolock was provided for record locking. 'autolock' is not perfect & 'deadlock' is possible if you are running 2 jobs updating the same records at the same time.

In Oct 2008 'manulock' (option l4) was extended to instructions 'red' & 'upd' to provided complete control over record locking. Here are the relevant lines extracted from demo job 'ISFlock2' listed on page '3C2'.


 filr1=tmp1/prodmas1,typ=ISFl4,rcs=79,isk1=0(6)  <-- specify manulock 'l4'
 ==============================================

      redm5l4w2r5 filr1,a0(79)   <-- read by key=(m5), manulock(l4),
      ========================       wait 2 seconds(w2), retry 5 times(r5)

      updl4  filr1,a0(79)        <-- update locked record(l4) & release lock
      ===================

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

3B1. File & Record Locking provided by D-ISAM & uvcopy

Op. Instrns. for Record Lock demo

Two jobs (ISFlock1 & ISFlock2) are provided to test manual record locking, using option 'l4' on filr1 typ=ISFl4, redl4,& updl4. See the 2 jobs listed on pages '3C1' & '3C2'.


 #1. Login as uvadm --> /home/uvadm

 #2. mkdir tmp1        <-- make a temp dir
     ==========

 #3. uvcp "fili1=dat1/prodmas1,typ=LST,rcs=80\
          ,filo1=tmp1/prodmas1,typ=ISFl4,rcs=79,isk1=0(6)"
     =====================================================
     - load an Indexed file for test jobs ISFlock1 & ISFlock2

 #4. uvcopy ISFlock1
     ===============

 #4a. prompts to load Indexed file (saves having to key above 'uvcp')
      - enter 'y' to load test file

 #4b. prompts 'record read with lock - enter to update'
      (do NOT enter yet)

 #5. Login on a 2nd screen --> /home/uvadm

 #6. uvcopy ISFlock2
     ===============
     - attempts to read product 'HAM020' with record lock (redm5l4w2r5)
     - waits 10 seconds (options w2r5, wait 2 seconds x 5 retries = 10)
     - then prompts 'record locked - enter to retry'

 #7. Wait 10 seconds to observe the 'retry' message

 #8. now Enter & immediately switch back to the 1st screen

 #9. Enter on 1st screen to complete the 1st update

 #10. switch back to screen 2 & observe results

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

3B2. File & Record Locking provided by D-ISAM & uvcopy

console log - 1st screen

081025:121630:ISFlock1: uvcopy ver=20081004 pf=/home/uvadm/pf/demo/ISFlock1 uvcopy DISAM ext=dat LNX L64 license=20081004V site=UV_Software load prodmas1 ISF file to tmp1 subdir y/n ? (via sys & uvcp) tmp1/prodmas1 loaded, will read with lock, & prompt for update

 HAM020   BALL PEEN HAMMER     0001200
 record read with lock, enter to update               <-- run ISFlock2 on screen2
 HAM020   BALL PEEN HAMMER     0001200   ISFlock1 121746
 record updated by ISFlock1
 081025:121746:ISFlock1: EOF filr01 rds=1 upds=1 size=729: tmp1/prodmas1
 081025:121746:ISFlock1: DISAMdat: recs=9,rcsz=80,keys=1; tmp1/prodmas1

console log - 2nd screen

 081025:121728:ISFlock2: uvcopy ver=20081004 pf=/home/uvadm/pf/demo/ISFlock2
 uvcopy DISAM ext=dat LNX L64  license=20081004V site=UV_Software
 record locked - enter to retry                    <-- allow 10 second timeout
                                                   <-- enter screen1 to proceed
 HAM020   BALL PEEN HAMMER     0001200   ISFlock1 121746     ISFlock2 121748
 record updated by ISFlock2
 081025:121748:ISFlock2: EOF filr01 rds=1 upds=1 size=729: tmp1/prodmas1
 081025:121748:ISFlock2: DISAMdat: recs=9,rcsz=80,keys=1; tmp1/prodmas1

test file results after demo

 BBQ010   BAR-B-Q              0019500
 CHR015   LAWN CHAIR           0004500
 HAM010   CLAW HAMMER          0000950
 HAM020   BALL PEEN HAMMER     0001200   ISFlock1 121746     ISFlock2 121748
 HAM035   JACK HAMMER          0029500
 SAW011   HAND SAW             0001975
 SAW012   RIP SAW              0002500
 SAW051   POWER SAW            0008500
 TAB012   LAWN TABLE           000850W

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

3C1. File & Record Locking provided by D-ISAM & uvcopy

uvcopy job#1 to demo Record Locking

 # ISFlock1 - test ISAM record lock (also see ISFlock2)
 #          - by Owen Townsend, UV Software, Oct 2008
 #*ISFlock1 - reads (with lock) record key 'HAM020' in tmp/prodmas1
 #          - pauses until operator reply
 #          - updates 41-57 with jobname & time
 # ISFlock2 - reads (with lock) same record key 'HAM020' in tmp/prodmas1
 #          - using options l4w2r5 (lock, wait 2 seconds, retry 5x)
 #          - updates 61-77 with jobname & time
 #          - report failure & prompt for retry
 #
 #     ** dat1/prodmas1 - copy to tmp/prodmas1 for test **
 #
 # BBQ010   BAR-B-Q              0019500
 # CHR015   LAWN CHAIR           0004500
 # HAM010   CLAW HAMMER          0000950
 # HAM020   BALL PEEN HAMMER     0001200 ISFlock1 HHMMSS     ISFlock2 HHMMSS
 # HAM035   JACK HAMMER          0029500
 # SAW011   HAND SAW             0001975
 #
 #                    ** Op. Instrns. **
 #
 # uvcp "fili1=dat1/prodmas1,rcs=80,typ=LST
 #      ,filo1=tmp1/prodmas1,rcs=79,typ=ISFl4,isk1=0(6)"
 #
 #*uvcopy ISFload1    <-- run job1 on 1st screen
 # ===============
 # uvcopy ISFload2    <-- run job2 on 2nd screen
 # ===============
 filr1=tmp1/prodmas1,rcs=79,typ=ISFl4
 @run
        msgwy  'load prodmas1 ISF file to tmp1 subdir y/n ? (via sys & uvcp)'
        skp!    man10
        sys    'uvcp "fili1=dat1/prodmas1,rcs=80,typ=LST,filo1=tmp1/prodmas1,typ=ISF,isk1=0(6)"'
        msg     'tmp1/prodmas1 loaded, will read with lock, & prompt for update'
 #
 man10  opn    filr1
        mvf    a0(80),'HAM020'
        redm5l4w1r2 filr1,a0(80)
        skp!   err1
        msg    a0(80)
        msgw   'record read with lock, enter to update'
        tim
        mvfv1  a40(20),'$jobname $time2'
        updl4  filr1,a0(80)
        msg    a0(80)
        msgv1  'record updated by $jobname'
        cls    filr1
        eoj
 #
 err1   can    'error on ISAM read attempt'

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

3C2. File & Record Locking provided by D-ISAM & uvcopy

uvcopy job#2 to demo Record Locking

 # ISFlock2 - test ISAM record lock (also see ISFlock1)
 #          - by Owen Townsend, UV Software, Oct 2008
 #
 # ISFlock1 - reads (with lock) record key 'HAM020' in tmp/prodmas1
 #          - pauses until operator reply
 #          - updates 41-57 with jobname & time
 #
 #*ISFlock2 - reads (with lock) same record key 'HAM020' in tmp/prodmas1
 #          - using options l4w2r5 (lock, wait 2 seconds, retry 5x)
 #          - updates 61-77 with jobname & time
 #          - report failure & prompt for retry
 #
 #     ** dat1/prodmas1 - copy to tmp/prodmas1 for test **
 #
 # BBQ010   BAR-B-Q              0019500
 # CHR015   LAWN CHAIR           0004500
 # HAM010   CLAW HAMMER          0000950
 # HAM020   BALL PEEN HAMMER     0001200 ISFlock1 HHMMSS     ISFlock2 HHMMSS
 # HAM035   JACK HAMMER          0029500
 # SAW011   HAND SAW             0001975
 # SAW012   RIP SAW              0002500
 # SAW051   POWER SAW            0008500
 # TAB012   LAWN TABLE           000850W
 #
 #                    ** Op. Instrns. **
 #
 # uvcp "fili1=dat1/prodmas1,rcs=80,typ=LST
 #      ,filo1=tmp1/prodmas1,rcs=79,typ=ISFl4,isk1=0(6)"
 #
 #*uvcopy ISFload1    <-- run job1 on 1st screen
 # ===============
 #
 # uvcopy ISFload2    <-- run job2 on 2nd screen
 # ===============
 #
 filr1=tmp1/prodmas1,rcs=79,typ=ISFl4
 @run
        opn    filr1
        mvf    a0(80),'HAM020'
 man20  redm5l4w2r5 filr1,a0(80)
        skp<   locked
        skp>   nofind
        tim
        mvfv1  a60(20),'$jobname $time2'
        updl4  filr1,a0(80)
        msg    a0(80)
        msgv1  'record updated by $jobname'
        cls    filr1
        eoj
 #
 locked msgw   'record locked - enter to retry'
        skp    man20
 nofind can    'record not found (cant happen)'
 #

Goto:   Begin this doc End this doc Index this doc Contents this library UVSI Home-Page

Visitor Counters for ThisYear and LastYear