The problem might be a duplicate key on one of the secondary (logical) files
pointing to the same physical file.  Do a DSPDBR on the physical file and
check out the logical files for a unique key conflict.

> -----Original Message-----
> From: cobol400-l-bounces@xxxxxxxxxxxx
> [mailto:cobol400-l-bounces@xxxxxxxxxxxx]On Behalf Of Diane Nott
> Sent: Thursday, April 17, 2003 8:54 AM
> To: cobol400-l@xxxxxxxxxxxx
> Subject: Cobol Write Statement Status Error 22
>
>
> I have racking my brain yesterday on how to use the WRITE statement with
> getting the Status 22 Write Error. What I am trying to do is to read a
> record. Do a small calculation on it and then use the results of that
> calculation to write a brand new record in the same file. When I run the
> program it gives me the Status 22 error that I am trying to write a
> duplicate record. If anyone can help, that would be great.
> Thanks!
> Diane
>
> Here is part of my code:
> This is what I have in the Input-Output Section:
> SELECT STUDENT-HISTORY-FILE
>               ASSIGN TO DATABASE-STCHSL0
>               ORGANIZATION  INDEXED
>               ACCESS IS DYNAMIC
>               RECORD KEY IS EXTERNALLY-DESCRIBED-KEY
>               FILE STATUS IS DBSTATUS.
>
> Data Section:
> OPEN I-O STUDENT-HISTORY-FILE.
>            IF DBSTATUS NOT = ZERO,
>               DISPLAY 'UNABLE TO ACCESS STCHSLT-FILE; '
>                    'STATUS IS ' DBSTATUS
>                    PERFORM 999-STOP-RUN.
>
> Starting the file:
> MOVE 0 TO R9NMID
>            MOVE 'COMP' TO R9CQAA.
>            MOVE 'XX' TO R9CMAA.
>            MOVE 2 TO R9KHAA.
>            MOVE 'MPRQ' TO R9B1AA.
>            MOVE '171' TO R9B2AA.
>            START STUDENT-HISTORY-FILE KEY NOT LESS THAN
>                       EXTERNALLY-DESCRIBED-KEY
>                       INVALID KEY
>                          CONTINUE.
>            IF DBSTATUS NOT = ZERO,
>               DISPLAY 'UNABLE TO ACCESS STCHSLT-FILE; '
>                    'STATUS IS ' DBSTATUS
>                    PERFORM 999-STOP-RUN.
>
> Procedure Division:
> 622-CREATE-031-RECORD.
>            MOVE R9NMID TO WS-ID.
>            PERFORM 630-CREATE-RECORD.
>            DISPLAY R9CQAA ' ' R9CMAA ' ' R9KHAA ' ' R9B1AA
>                    ' ' R9B2AA.
>               WRITE STUDENT-HISTORY-REC
>                  INVALID KEY
>                      DISPLAY 'DBSTATUS IS ' DBSTATUS.
>                    CONTINUE.
>               EVALUATE DBSTATUS
>                   WHEN "22"
>                 DISPLAY "DUPLICATE PRI KEY: ", STUDENT-HISTORY-REC
>            ADD 1 TO WS-COUNT-3.
>
>        630-CREATE-RECORD.
>
>            MOVE SPACES TO STUDENT-HISTORY-REC.
>            MOVE WS-ID TO R9NMID.
>            MOVE 'COMP' TO R9CQAA.
>            MOVE spaces  TO R9KUAA.
>            MOVE 'XX' TO R9CMAA.
>            MOVE spaces TO R9KVAA.
>            MOVE 3 TO R9KHAA.
>            MOVE 'MPRQ'  TO R9B1AA.
>            MOVE RPT-COURSE-NUMBER TO R9B2AA.
>            MOVE SPACES TO R9BWAA.
>            MOVE 'E' TO R9B3AA.
>            MOVE SPACES TO R9K2AA.
>            MOVE SPACES TO R9KIAA.
>            MOVE SPACES TO R9KJAA.
>            MOVE SPACES TO R9KKAA.
>            MOVE SPACES TO R9CIAA.
>            MOVE SPACES TO R9CAAA.
>            MOVE SPACES TO R9CEAA.
>            MOVE ZERO TO R9J2AA.
>            MOVE SPACES TO R9I8AA.
>            MOVE SPACES TO R9I9AA.
>            MOVE SPACES to R9MLAA.
>            MOVE SPACES TO R9K5AA.
>            MOVE SPACES TO R9MWAG.
>            MOVE SPACES TO R9PTAA.
>            MOVE 'DIANE' TO R9LRAZ.
>            MOVE ZERO TO R9KLAA.
>            MOVE ZEROES TO R9ZZAD.
>            MOVE ZERO TO R9KWAA.
>            MOVE ZERO TO R9LXAA.
>            MOVE ZEROES TO R9KQAA.
>            MOVE ZEROES TO R9KRAA.
>            MOVE ZEROES TO R9KXAA.
>            MOVE ZEROES TO R9KYAA.
>            MOVE ZERO TO R9KSAA.
>            MOVE ZERO TO R9KTAA.
>            MOVE ZERO TO R9NTAA.
>            MOVE ZERO TO R9JIAB.
>            MOVE ZERO TO R9LIAG.
>            MOVE ZERO TO R9LKAG.
>            MOVE ZERO TO R9LLAG.
>            MOVE ZERO TO R9LJAG.
>            MOVE ZERO TO R9XPAK.
>            MOVE ZERO TO R9XMAK.
>            MOVE ZERO TO R9V5AP.
>            MOVE ZERO TO R9V6AP.
>            MOVE ZERO TO R9V7AP.
>            MOVE ZERO TO R9V8AP.
>            MOVE ZERO TO R9JYAU.
>            MOVE ZERO TO R9NNAZ.
>            MOVE ZERO TO R9NOAZ.
>            MOVE ZERO TO R9NPAZ.
>            MOVE ZERO TO R9NQAZ.
>            MOVE ZERO TO R9N0AZ.
>            MOVE ZERO TO R9N1AZ.
>            MOVE ZERO TO R9QQAK.
>            MOVE ZERO TO R9QMAK.
>            MOVE ZERO TO R9QNAK.
>            MOVE ZERO TO R9QOAK.
>            MOVE ZERO TO R9QPAK.
>            MOVE ZERO TO R9Q3AD.
>            MOVE ZERO TO R9Q7AD.
>            MOVE 'INM009    ' TO R9USR.
>            MOVE 'COMPASS3  ' TO R9JOB.
>            ACCEPT RUN-DATE FROM DATE.
>            MOVE RUN-DATE TO DATE-CCYYMMDD.
>            IF DATE-YY-1 > 90
>               MOVE 00 TO DATE-CC
>            ELSE
>               MOVE 01 TO DATE-CC.
>            MOVE DATE-CCYYMMDD TO R9JDT.
>            ACCEPT RUN-TIME FROM TIME.
>            COMPUTE TIME-HHMMSS = RUN-TIME / 100.
>            MOVE TIME-HHMMSS TO FORMATTED-TIME.
>            INSPECT FORMATTED-TIME
>                REPLACING ALL '/' BY ':'.
>            MOVE FORMATTED-TIME TO R9JTM.
> _______________________________________________
> 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.cgi/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-2024 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.