cobol - File status 23 on READ after START -


my question pertaining file status 23, according microfocus means upon attempt read .dat file:

"indicates no record found."

or

"indicates duplicate key condition. attempt has been made store record create duplicate key in indexed or relative file or duplicate alternate record key not allow duplicates."

i have eliminated fact latter issue because i'm allowing duplicates in case.

the reason i'm stumped i'm using start navigate record inside of .dat file, , when execute read after start has positioned file pointer, file status 23.

here code:

900-get-inst-id. open input inst-mst. move fall-in-inst inst-name-rec.    start inst-mst         key equal inst-name-rec            invalid key                display "record not found"            not invalid key                read inst-mst                move inst-id-rec ws-inst-id    end-start.    close inst-mst. 

so when running code start runs , goes not invalid key block, , next line executes , read null. how can if alternate key (inst-name-rec) found inside .dat?

i have ensured fd picture clauses match in isam build program , in program (the reading program).

the second reason show excluded not because allow duplicate keys, because error message file-status write, , failure on read.

here's problem:

read inst-mst 

here's how fix it:

read inst-mst next 

in cobol 85, read statement has 2 formats. format 1 sequential read , format 2 keyed (random) read.

unfortunately, minimum read syntax both sequential , keyed reads is:

read file-name 

which means if use read file-name compiler implicitly treat format 1 or format 2 depending on select statement.

read file-name next record identical read file-name next.

consult actual documentation full explanation , discovery of possible language extensions vendor. if consult closely, behaviour of read file-name no further option depends on type of file. keyed file, default keyed read. key field (luckily) not contain key exists, 23.

even if didn't work that, point of not using word next? compiler knows tell (which not think tell it), in situation this, human reader can unsure. last thing want when bug-hunting break off @ manual discover how behaves, , try work if behaviour 1 sought original coder. bug? bug? intended, sloppy, code? no-one wants spend time, , look, now, you.

a couple of comments on code.

look file status clause of select. use it. 1 field per file. check after each io. it'll save grief.

once using file status, ditch imperative parts of io statements (the something/not something) , replace tests of file-status field (using 88s).

it looks opening , closeing look-up file time. please don't. open , close can heavy , time-consuming, them once per program per file. if you've done because of problem, find correct resolution problem, don't use hack.

drop full-stops/periods except needed. cobol 85, means 30 years number of full-stops/periods required in procedure division have been reduced. modern, , take advantage of that, it'll save gotcha!s copy/paste code, leaving 1 shouldn't there , changing way program behaves.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -