Rick,

We are using an indexed file for the opnqryf, but output to a sequential file:

OPNFLE: OPNQRYF FILE((MARGE/MISCHL0)) + QRYSLT(' + (PROC99 *NE ''Y'' *AND + PROC99 *NE ''X'') + ') + OPNID(MISCWK) CPYFRMQRYF FROMOPNID(MISCWK) TOFILE(MARGE/MISCNU) + MBROPT(*REPLACE) FMTOPT(*NOCHK) CALL MARGE/CRTMSBAT + PARM(&USERID) CLOF OPNID(MISCWK) DLYJOB DLY(1800) GOTO ALCOBJ

In the CRTMSBAT COBOL program:

* OPNQRYF OUTPUT: RECORDS NOT YET PROCESSED ONLY
SELECT FILE-IN ASSIGN TO DATABASE-MISCNU FILE STATUS IS FILE-STAT.


After the sequential MISCNU file is read in and processed, the original, indexed MISCHL0 records are randomly accessed and updated and processed, so that the opnqryf will not pull them in again the next time:

UPDATE-MISC-CHARGE-HIST-REC. MOVE NMIDIN TO NMID99. MOVE YEARIN TO YEAR99. MOVE TERMIN TO TERM99. MOVE CODEIN TO CODE99. MOVE DATEIN TO DATE99. MOVE TIMEIN TO TIME99. MOVE 'N' TO MISCHL0-REC-FOUND-SW. PERFORM READ-MISC-CHARGE-HIST-FILE. IF MISCHL0-REC-FOUND IF VALID-AMT MOVE 'Y' TO PROC99 ELSE MOVE 'X' TO PROC99 END-IF PERFORM REWRITE-MISC-CHARGE-HIST-REC ELSE DISPLAY 'MISC CHARGE HIST REC NOT FOUND '
NMID99 ' ' YEAR99 ' ' TERM99 ' '
CODE99 ' '
DATE99 ' '
TIME99.


Hope this helps.

Marge Rozmarynowycz
rick.baird@xxxxxxxxxxxxxxx wrote:


Just another quick question from a guy who'd really rather not have to fart
around with this stuff.... :)   I'm converting a bunch of flat file FMTDTA
stuff to use OPNQRYF instead.

when reading a file in cobol that's been sorted via opnqryf, is there
anything I need to worry about as far as COBOL syntax?

this is what I have:

OVRDBF     FILE(HISTRY4) SHARE(*YES)
OPNQRYF    FILE((HISTRY4)) QRYSLT( +
                 'HPEROD *EQ ' *CAT &PERIOD *BCAT  +
            '*AND LMRKTC *NE "00" +
             *AND HITEM  *NE 0')   +
            KEYFLD((HITEM) (LMRKTC))

and in my cobol:

SELECT HISTRY4 ASSIGN TO DATABASE-HISTRY4
    ORGANIZATION IS INDEXED
    ACCESS MODE IS SEQUENTIAL
    RECORD KEY IS EXTERNALLY-DESCRIBED-KEY
    FILE STATUS IS FILE-STATUS-01.

OPEN INPUT HISTRY4

READ HISTRY4 AT END
 MOVE "Y" TO EOF-HISTRY4.

CLOSE HISTRY4

If I'm missing something obvious, I'd appeciate the heads up - I'm
particularly concerned about the ACCESS MODE and RECORD KEY clauses of the
SELECT Statement.  - indexed, sequential with external key - (not the
file's natural key)

I'm changing a ton of these, and I won't have a chance to test till I'm
done, and I'd like to get it right the first time.

Thanks a ton,

Rick


_______________________________________________ This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing list To post a message email: COBOL400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/cobol400-l or email: COBOL400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/cobol400-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.