EXTFH-compatible COBOL-callable IO
P3/COBOL provides the ability to invoke IO functions via the industry-standard Extended File Handler (EXTFH) interface originally defined by Micro Focus1. P3/COBOL supports both the FCD-2 and FCD-3 form of that interface as follows:
extfh-2
USING extfh-opcode, extfh-fcd-2 returning return-statusWhere:
01 extfh-opcode.
10 op-value pic xx comp-x.01 extfh-fcd-2.
10 fcd-file-status.
20 fcd-status-key-1 pic x.
88 is-successful value "0".
20 fcd-status-key-2 pic x.
10 pic x(3) comp-x value 0.
10 fcd-organization pic x comp-x value 2.
88 is-line-sequential value 0.
88 is-sequential value 1.
88 is-relative value 3.
88 is-indexed value 2.
10 fcd-access-mode pic x comp-x value 0.
88 is-sequential value 0.
88 is-random value 4.
88 is-dynamic value 8.
10 fcd-open-mode pic x comp-x value 128.
88 is-open-input value 0.
88 is-open-output value 1.
88 is-open-io value 2.
88 is-open-extend value 3.
88 is-closed value 128.
10 pic x(3) comp-x value 0.
10 fcd-name-length pic 9(4) comp-x.
10 fcd-reladdr-big pic x(8) comp-x.
10 pic x(3) comp-x value 0.
10 fcd-lock-mode pic 9(2) comp-x.
10 fcd-other-flags pic 9(2) comp-x.
10 pic x(2).
10 fcd-handle pointer.
10 fcd-handle-number redefines fcd-handle
pic x(pointer-size)
usage comp-x.
10 pic x comp-x value 0.
10 fcd-status-type pic 9(2) comp-x.
10 fcd-file-format pic 9(2) comp-x.
10 pic x(3) comp-x value 0.
10 fcd-max-rec-length pic 9(4) comp-x.
10 pic x(2) comp-x value 0.
10 fcd-file-sescriptor pic x comp-x value 0.
10 fcd-relative-key pic 9(9) comp-x.
10 fcd-recording-mode pic 9(2) comp-x.
10 fcd-cur-rec-length pic 9(4) comp-x.
10 fcd-min-rec-length pic 9(4) comp-x.
10 fcd-key-id pic 9(4) comp-x.
10 fcd-line-count redefines fcd-key-id
pic 9(4) comp-x.
10 fcd-key-length pic 9(4) comp-x.
10 fcd-record-address usage pointer.
10 fcd-filename-address usage pointer.
10 fcd-key-def-address usage pointer.
10 pic x(4) comp-x value 0.
10 fcd-reladdr-offset pic 9(9) comp-x.
10 pic x(2) comp-x.
10 fcd-data-compression pic 9(2) comp-x.
10 fcd-session-id pic x(4) comp-5.
10 fcd-file-id pic 9(4) comp-x.
10 pic x(6) comp-x value 0.
10 fcd-int-lang-lock pic 9(2) comp-x.
10 fcd-fs-ta-lock pic 9(2) comp-x.
10 fcd-config-flags pic 9(2) comp-x.
10 pic x comp-x value 0.
10 fcd-misc-conf pic x comp-x.
10 fcd-idx-cache-size pic x comp-x.
10 fcd-idx-cache-area pic x comp-x.
10 pic x(2) comp-x value 0.01 extfh-key-definition-block.
10 kdb-global-information-area.
20 gia-kdb-length pic xx comp-x.
20 pic x(4) comp-x value 0.
20 gia-number-of-keys pic xx comp-x value 0.
20 pic x(6) comp-x value 0.
10 kdb-key-definition-area occurs 1 to 256 depending on gia-number-of-keys indexed by k.
20 kda-component-count pic xx comp-x value 0.
20 kda-first-cda-offset pic xx comp-x value 0.
20 kda-flags pic x comp-x value 0.
20 kda-compression-flags pic x comp-x value 0.
20 kda-sparse-character pic x display value 0.
20 pic x comp-x value 0 occurs 9.
10 kdb-component-definition-area occurs 256.
20 cda-flags.
30 pic x comp-x value 0.
30 pic x comp-x value 0.
20 cda-offset pic xxxx comp-x value 0.
20 cda-length pic xxxx comp-x value 0.01 component-definition-array.
10 occurs 256 indexed by p.
20 cda-flags.
30 pic x comp-x value 0.
30 pic x comp-x value 0.
20 cda-offset pic xxxx comp-x value 0.
20 cda-length pic xxxx comp-x value 0.01 extfh-file-name.
10 pic x(200).01 record-area.
10 pic x occurs 1 to 32768 times depending on fcd-cur-rec-length.01 return-status pic xx comp-x.This program implements the EXTFH external file handler capabilities for a 4 byte pointer (32-bit address) environment according to the semantics of the Micro Focus1 specification of this capability as it applies to the P3/COBOL indexed organization file system. Detailed information regrading this should be found in the corresponding Micro Focus1 documentation.
extfh-3
USING extfh-opcode, extfh-fcd-3 returning return-statusWhere:
01 extfh-fcd-3.
10 fcd-file-status.
20 fcd-status-key-1 pic x.
88 is-successful value "0".
20 fcd-status-key-2 pic x.
10 fcd-length pic xx comp-x.
10 fcd-version pic x comp-x value 1.
10 fcd-organization pic x comp-x value 2.
88 is-line-sequential value 0.
88 is-sequential value 1.
88 is-relative value 3.
88 is-indexed value 2.
10 fcd-access-mode pic x comp-x value 0.
88 is-sequential value 0.
88 is-random value 4.
88 is-dynamic value 8.
10 fcd-open-mode pic x comp-x value 128.
88 is-open-input value 0.
88 is-open-output value 1.
88 is-open-io value 2.
88 is-open-extend value 3.
88 is-closed value 128.
10 fcd-recording-mode pic x comp-x value 0.
88 is-fixed value 0.
88 is-variable value 1.
10 fcd-file-format pic x comp-x value 0.
88 is-default value 0.
88 is-c-isam value 1.
88 is-idx3 value 3.
88 is-idx4 value 4.
88 is-idx8 value 8.
88 is-mainframe-print value 11.
88 is-heap-file value 14.
88 is-esds-file value 15.
10 fcd-device-flag pic x comp-x value 0.
88 is-normal value 0.
88 is-device value 1.
88 is-stdin value 2.
88 is-stdout value 3.
88 is-stderr value 4.
88 is-bad-name value 5.
88 is-input-pipe value 6.
88 is-output-pipe value 7.
88 is-io-pipe value 8.
88 is-library value 9.
88 is-disk-file value 10.
88 is-null value 11.
88 is-disk-redir value 12.
88 is-no-map value 13.
10 pic x comp-x.
10 fcd-data-compression pic x comp-x value 0.
88 is-no-ompression value 0.
88 is-mf-compression value 1 through 127.
88 is-user-defined value 128 through 255.
10 fcd-blocking pic x comp-x value 0.
88 is-system-default value 0.
88 is-512 value 1.
88 is-1024 value 2.
88 is-4096 value 4.
88 is-16384 value 6.
10 fcd-idxcache-size pic x comp-x value 0. *> number of index nodes held in cache
10 fcd-percent pic x comp-x value 0.
10 fcd-block-size pic x comp-x value 0.
88 is-no-blocking value 0.
88 is-4096 value 12.
88 is-8192 value 13.
88 is-16384 value 14.
88 is-32768 value 15.
88 is-65536 value 16.
10 fcd-flags-1 pic x comp-x value 0. *> see documentation for values
10 fcd-flags-2 pic x comp-x value 0.
88 is-convert-dbspace value 1 false 0.
10 fcd-mvs-flags pic x comp-x value 0.
10 fcd-status-type pic x comp-x value 128.
10 fcd-other-flags pic x comp-x value 0.
10 fcd-trans-log pic x comp-x value 0.
10 fcd-locktypes pic x comp-x value 0.
10 fcd-fs-flags pic x comp-x value 0.
10 fcd-config-flags pic x comp-x value 0.
10 fcd-misc-flags pic x comp-x value 0.
10 fcd-config-flags-2 pic x comp-x value 0.
10 fcd-lock-mode pic x comp-x value 0.
10 pic x comp-x value 0.
10 fcd-idxcache-buffs pic x comp-x.
10 filler pic x(19).
10 fcd-fs-file-id pic xx comp-x.
10 pic xx comp-x.
10 fcd-name-length pic xx comp-x value 0.
10 pic xx comp-x value 0.
10 fcd-retry-count pic xx comp-x value 0.
10 fcd-key-id pic xx comp-x value 0. *> key of reference (primary = 0)
10 fcd-line-count pic xx comp-x value 0. *> line skip count (sequential)
10 pic xx comp-x value 0.
10 fcd-key-length pic xx comp-x value 0. *> effective key length
10 pic x(20).
10 fcd-cur-rec-length pic xxxx comp-x value 0. *> FCD3 only
10 fcd-min-rec-length pic xxxx comp-x value 0. *> minimum record length
10 fcd-max-rec-length pic xxxx comp-x value 0. *> maximum record length
10 pic xxxx comp-x value 0.
10 pic x(24).
10 fcd-reladdr-offset pic xxxxxxxx comp-x value 0. *> FCD3: relative byte address (undefined following open)
10 fcd-reladdr-big pic xxxxxxxx comp-x redefines fcd-reladdr-offset.
10 fcd-max-rel-key pic xxxxxxxx comp-x value 0. *> maximum relative key
10 fcd-relative-key pic xxxxxxxx comp-x value 0. *> relative key
10 fcd-handle pointer.
10 fcd-handle-number redefines fcd-handle
pic x(pointer-size)
usage comp-x.
10 fcd-record-address pointer.
10 fcd-filename-address pointer.
10 fcd-idxname-address pointer.
10 fcd-key-def-address pointer.
10 fcd-col-seq-address pointer.
10 fcd-fildef-address pointer.
10 fcd-dfsort-address pointer.
10 fcd-end.This program implements the EXTFH external file handler capabilities for an 8-byte pointer (64-bit address) environment according to the semantics of the Micro Focus1 specification of this capability as it applies to the P3/COBOL indexed organization file system. Detailed information regrading this should be found in the corresponding Micro Focus1 documentation. Data structures other than the extfh-fcd-3 structure above are the same as the extfh-2 program interface.
Some of the parameters and fields within the extfh structures do not apply to the P3/COBOL environment. When this is the case, this program will typically ignore the parameter or field and it will have no effect on program operation. If the field cannot be implemented in the P3/COBOL environment an error status will be returned.
1 Micro Focus is trademark of Micro Focus Group, Ltd.