Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
I don't believe there is a way to do this, but I thought I'd run it by all you gurus anyway.
I have a really strange problem where the program is writing 3 records to a control file, one right after the other with type codes I, T, and G. The key to the control file is vendor, PO# and backorder#, so these records should stay in the order written. Well, occassionally for no reason that I can deduce, they get out of order.
I was wondering if there is anyway in the file definition that I can say that they have to be in I, T, and G order? If not, can anyone think of any way these could randomly get switched.
What's weird is that we reran the same PO thru again with the same results. It just makes no sense. A way of ordering the record types would be the ideal solution.
Thanks!
Maybe you're reusing deleted records...?
Hi Viking. Yes the file is set to reuse deleted records. That might be the issue. I didn't even think of that! I'll change it back and watch it.
Thanks!
Not to state the obvious, but if you're using RPG "F" specs, do you have the "K" for Keyed Access on the File spec? That's the only way to insure the records are read in keyed sequence, even if the file has a primary key.
Since all three records have the same composite "key" value, you can't guarantee what sequence the records will be returned in- the presentation order might change after a rgzpfm- unless you introduce another value to sequence the file. If you've got a timestamp field to track last change on the table, that might be suitable. You could add numeric field that contains 1 for "I" records, 2 for "T", and 3 for "G" records, and add that field two your key.
We've decided all new tables will include surrogate values as primary keys, and are retro-fitting them to existing tables as needed. For our shop, this would be a candidate for retrofitting.