Hi All,
I recently joined as mainframe analyst .
I had developed below program,but it is getting failed in writing/rewritimg the record in VSAM/KSDS file.
My requirement: With reference to one file i am updating adding a new record or updating the existing record in another file
Please find the code below what i am implementing:
PROCEDURE DIVISION.
PERFORM 101-INIT THRU 101-EXIT.
101-INIT.
MOVE LOW-VALUE TO FILE-KEY-LW
PERFORM 911-STARTBR-LWFILE
THRU 911-EXIT
PERFORM 921-READNEXT-LWFILE
THRU 921-EXIT
PERFORM UNTIL WS-EOF-LW-YES
PERFORM 201-PROCESS
THRU 201-EXIT
PERFORM 921-READNEXT-LWFILE
THRU 921-EXIT
END-PERFORM
PERFORM 961-ENDBR-LWFILE THRU 961-EXIT.
101-EXIT.
EXIT.
201-PROCESS.
IF WORKUNIT-STATUS-LW-COMPLETE
IF WORKUNIT-STATUS-LW-COMPLETE
CONTINUE
ELSE
GO TO 201-EXIT
END-IF
IF TYPE-LW= '2'
CONTINUE
ELSE
GO TO 201-EXIT
END-IF
ORE TEMPORARY LOCATIONS.
IF TO-SLOT-LW(1:1) = '*'
OR TO-SLOT-LW(1:3) = 'HAL'
OR TO-SLOT-LW(1:3) = 'HRH'
GO TO 201-EXIT
END-IF
MOVE LOW-VALUE TO PN-RECORD
MOVE CENTER-LW TO DISTRIBUTION-CENTER-PN
DISTRIBUTION-CENTER-PN-NDX1
MOVE WAREHOUSE-LW TO WAREHOUSE-PN
WAREHOUSE-PN-NDX1
MOVE WORKUNIT-LW TO WORKUNIT-PN
* MOVE TO-SLOT-LW TO LOCATION-ID-PN-NDX1
* MOVE PRODUCT-ID-LW TO PRODUCT-ID-PN
* MOVE SHIPPING-UNITS-LW TO PALLET-QUANTITY-PN
PERFORM 912-READ-PNFL
THRU 912-EXIT.
201-EXIT.
EXIT.
911-STARTBR-LWFILE.
EXEC CICS STARTBR
FILE (LWFILE)
RIDFLD (FILE-KEY-LW)
GTEQ
RESP (FILE-STATUS-DB)
END-EXEC.
EVALUATE TRUE
WHEN FILE-STATUS-DB-GOOD
CONTINUE
WHEN FILE-STATUS-DB-NOT-FOUND
WHEN FILE-STATUS-DB-EOF
SET WS-EOF-LW-YES TO TRUE
WHEN OTHER
MOVE FILE-STATUS-DB TO MSG-11-STATUS
FAILDATA-FILE-STATUS
MOVE 'LW' TO MSG-11-FILE
FAILDATA-FILE-ID
MOVE FILE-KEY-LW TO MSG-11-KEY
MOVE MSG-11 TO ERROR-MSG
FAILDATA-PGM-COMMENT
MOVE '910-STARTBR-LWFILE' TO FAILDATA-PGM-LABEL
GO TO 650-ABNORM-END
END-EVALUATE.
911-EXIT.
EXIT.
921-READNEXT-LWFILE.
EXEC CICS READNEXT
FILE (LWFILE)
INTO (LW-RECORD)
RIDFLD (FILE-KEY-LW)
RESP (FILE-STATUS-DB)
END-EXEC.
EVALUATE TRUE
WHEN FILE-STATUS-DB-GOOD
WHEN FILE-STATUS-DB-GOOD-WITH-DUPS
CONTINUE
WHEN FILE-STATUS-DB-NOT-FOUND
WHEN FILE-STATUS-DB-EOF
SET WS-EOF-LW-YES TO TRUE
WHEN OTHER
MOVE FILE-STATUS-DB TO MSG-13-STATUS
FAILDATA-FILE-STATUS
MOVE 'LW' TO MSG-13-FILE
FAILDATA-FILE-ID
MOVE FILE-KEY-LW TO MSG-13-KEY
FAILDATA-FILE-KEY
MOVE MSG-13 TO ERROR-MSG
FAILDATA-PGM-COMMENT
MOVE '920-READNEXT-LWFILE' TO FAILDATA-PGM-LABEL
GO TO 650-ABNORM-END
END-EVALUATE.
921-EXIT.
EXIT.
961-ENDBR-LWFILE.
EXEC CICS ENDBR
FILE (LWFILE)
RESP (FILE-STATUS-DB)
END-EXEC.
961-EXIT.
EXIT.
912-READ-PNFL.
EXEC CICS READ
FILE (PNFILE)
INTO (PN-RECORD)
RIDFLD (FILE-KEY-PN)
RESP (FILE-STATUS-DB)
END-EXEC.
EVALUATE TRUE
WHEN FILE-STATUS-DB-GOOD
* MOVE CENTER-LW TO DISTRIBUTION-CENTER-PN
* DISTRIBUTION-CENTER-PN-NDX1
* MOVE WAREHOUSE-LW TO WAREHOUSE-PN
* WAREHOUSE-PN-NDX1
* MOVE WORKUNIT-LW TO WORKUNIT-PN
PERFORM 913-READ-PNF-UPDATE
THRU 913-EXIT
MOVE TO-SLOT-LW TO LOCATION-ID-PN-NDX1
MOVE PRODUCT-ID-LW TO PRODUCT-ID-PN
MOVE SHIPPING-UNITS-LW TO PALLET-QUANTITY-PN
SET AUDITED-NO-PN TO TRUE
PERFORM 915-REWRITE-PNFL
THRU 915-EXIT
WHEN FILE-STATUS-DB-NOT-FOUND
WHEN FILE-STATUS-DB-EOF
*PLEASE WRITE THE MOVE COMMANDS BEFORE WRITE
* MOVE CENTER-LW TO DISTRIBUTION-CENTER-PN
* DISTRIBUTION-CENTER-PN-NDX1
* MOVE WAREHOUSE-LW TO WAREHOUSE-PN
* WAREHOUSE-PN-NDX1
* MOVE WORKUNIT-LW TO WORKUNIT-PN
MOVE TO-SLOT-LW TO LOCATION-ID-PN-NDX1
MOVE PRODUCT-ID-LW TO PRODUCT-ID-PN
MOVE SHIPPING-UNITS-LW TO PALLET-QUANTITY-PN
SET AUDITED-NO-PN TO TRUE
PERFORM 914-WRITE-PNFL
THRU 914-EXIT
WHEN OTHER
MOVE FILE-STATUS-DB TO MSG-12-STATUS
FAILDATA-FILE-STATUS
MOVE 'PN' TO MSG-12-FILE
FAILDATA-FILE-ID
MOVE FILE-KEY-PN TO MSG-12-KEY
FAILDATA-FILE-KEY
MOVE MSG-12 TO ERROR-MSG
FAILDATA-PGM-COMMENT
MOVE '912-READ-PNFL' TO FAILDATA-PGM-LABEL
GO TO 650-ABNORM-END
END-EVALUATE.
912-EXIT.
EXIT.
913-READ-PNF-UPDATE.
EXEC CICS READ
FILE (PNFILE)
INTO (PN-RECORD)
RIDFLD (FILE-KEY-PN)
UPDATE
RESP (FILE-STATUS-DB)
END-EXEC.
EVALUATE TRUE
WHEN FILE-STATUS-DB-GOOD
CONTINUE
WHEN OTHER
MOVE FILE-STATUS-DB TO MSG-14-STATUS
FAILDATA-FILE-STATUS
MOVE 'PN' TO MSG-14-FILE
FAILDATA-FILE-ID
MOVE FILE-KEY-PN TO MSG-14-KEY
FAILDATA-FILE-KEY
MOVE MSG-14 TO ERROR-MSG
MOVE '913-READ-PNF-UPDATE' TO FAILDATA-PGM-LABEL
FAILDATA-FILE-STATUS
GO TO 650-ABNORM-END
END-EVALUATE.
913-EXIT.
EXIT.
915-REWRITE-PNFL.
EXEC CICS
REWRITE
FILE (PNFILE)
FROM (PN-RECORD)
RESP (FILE-STATUS-DB)
END-EXEC.
EVALUATE TRUE
WHEN FILE-STATUS-DB-GOOD
CONTINUE
WHEN OTHER
MOVE FILE-STATUS-DB TO MSG-16-STATUS
MOVE 'PN' TO MSG-16-FILE
FAILDATA-FILE-ID
MOVE FILE-KEY-PN TO MSG-16-KEY
FAILDATA-FILE-KEY
MOVE MSG-16 TO ERROR-MSG
FAILDATA-PGM-COMMENT
MOVE '915-REWRITE-PNFLE' TO FAILDATA-PGM-LABEL
GO TO 650-ABNORM-END
END-EVALUATE.
915-EXIT.
EXIT.
914-WRITE-PNFL.
EXEC CICS
WRITE
FILE (PNFILE)
FROM (PN-RECORD)
RIDFLD (FILE-KEY-PN)
RESP (FILE-STATUS-DB)
END-EXEC.
EVALUATE TRUE
WHEN FILE-STATUS-DB-GOOD
CONTINUE
WHEN OTHER
MOVE FILE-STATUS-DB TO MSG-15-STATUS
FAILDATA-FILE-STATUS
MOVE 'PN' TO MSG-15-FILE
FAILDATA-FILE-ID
MOVE FILE-KEY-PN TO MSG-15-KEY
FAILDATA-FILE-KEY
MOVE MSG-15 TO ERROR-MSG
FAILDATA-PGM-COMMENT
MOVE '914-WRIT-PNFL' TO FAILDATA-PGM-LABEL
GO TO 650-ABNORM-END
END-EVALUATE.
914-EXIT.
EXIT.
650-ABNORM-END.
EXEC CICS
SYNCPOINT ROLLBACK
END-EXEC.
MOVE MY-PROG TO FAILDATA-PGM-ID
PERFORM 887-CSMTBLD
THRU 887-EXIT
PERFORM 888-CSMT-WRITE
THRU 888-EXIT
PERFORM 887-CSMTBLD-2
THRU 887-EXIT-2
PERFORM 888-CSMT-WRITE
THRU 888-EXIT
EXEC CICS
RETURN
END-EXEC.
COPY CSMTBLD.
COPY CICSCSMT.
Error i am getting is :
FS99 00 111102 05:29:56 914-WRIT-PNFL PN 0206583224
FS99 00 111102 05:29:56 15:ERROR WRITE PN , 21, 02065
But when i try to insert the this record manually by using XPED option it got inserted.
Can some one please help in getting this resolved.
Please let me know if u need any more information.