Skip to main content

Problem:

Exec Cics Rewrite fails with Eibresp=16

Resolution:

The failing test case also received an EIBRESP2 code of 30 indicating that the UPDATE flag was not set for the REWRITE. This sample program ilustrates how to ensure UPDATE is used on an

EXEC CICS READ DATASET prior to the REWRITE:

       Identification Division.

       Program-Id.  LORINCE.

       Environment Division.

       Data Division.

       Working-Storage Section.

       1   Data-Record.

        2   Data-Key         Pic X(8).

        2   Data-Fld         Pic X(32).

        2   Data-Spare       Pic X(40).

       1   Ctrs.

        2   Abstime          Pic S9(15) Comp-3.

        2   Eof-Sw           Pic S9(8) Comp.

        2   Key-Count        Pic 9(8).

        2   Rec-Key          Pic 9(8).

        2   Resps.

         3   WrResp          Pic S9(9).

         3   RdResp          Pic S9(9).

         3   RduResp         Pic S9(9).

         3   RwResp          Pic S9(9).

         3   SeResp          Pic S9(9).

       1   Log-Time.

        2                    Pic X(1).

        2   Status-Mess      Pic X(20).

        2   Out-Time         Pic X(8).

        2                    Pic X(51).

       1   Log-Position.

        2                    Pic X(1).

        2   Loc              Pic X(10).

        2   Location         Pic X(10).

        2                    Pic X(59).

       1   Error-Message.

        2   Mess             Pic X(10).

        2   Resp             Pic X(9).

        2                    Pic X(61).

       Procedure Division.

       P1.

      * Be sure to define the FCT for CICS as 'Ltlstar' for this pgm

      * Fixed 80, KSDS VSAM key 1->8

      * start enabled/backward recovery, name file path in FCT

           Initialize  Data-Record   Ctrs  Log-Time

                       Log-Position  Error-Message

           Move 'Eibresp = ' to Mess

           Move 'Start Write' to Status-Mess

           Perform Logit

           Move 'Loop 1' to Loc

           Move ' This Record is Reserved for Me ' to Data-Fld

           Perform 10 Times

             Add 1 to Key-Count

             Move Key-Count to Data-Key  Rec-Key

             Exec Cics Write Dataset('Ltlstar') Ridfld(Rec-Key)

                  From(Data-Record) Resp(Eibresp) End-Exec

             Move Eibresp to WrResp

             If Eibresp Not Equal Zero then

                Move 'Write Failed' to Mess

                Perform Error-Routine

             End-If

             Move Data-Key to Location

             Exec Cics Send Text From(Log-Position) Length(80)

             End-Exec

             Move Eibresp to SeResp

           End-Perform

           Move 'Start Read' to Status-Mess

           Perform Logit

           Move 1 to Key-Count

           Move Key-Count to Rec-Key

           Move 'Loop 2' to Loc

           Perform 10 Times

             Exec Cics Read Dataset('Ltlstar')

                  Into(Data-Record) Ridfld(Rec-Key) Resp(Eibresp)

             End-Exec

             Move Eibresp to RdResp

             If Eibresp Not Equal Zero then

                Move 'Read Failed' to Mess

                Perform Error-Routine

             End-If

             Add 1 to Key-Count

             If Key-Count = 5 then

                Move Key-Count to Rec-Key

                Exec Cics Read Dataset('Ltlstar') Update

                     Into(Data-Record) Ridfld(Rec-Key) Resp(Eibresp)

                End-Exec

                Move Eibresp to RduResp

                Move ' This Record Has Been Updated ' to Data-Fld

                Exec Cics Rewrite Dataset('Ltlstar')

                     From(Data-Record) Length(80) Resp(Eibresp)

                End-Exec

                Move Eibresp to RwResp

                If Eibresp Not Equal Zero then

                   Move 'ReWrite Failed' to Mess

                   Perform Error-Routine

                End-If

             End-If

             If Key-Count > 10 then

                Compute Key-Count = Key-Count - 10 1

             End-If

             Move Key-Count to Rec-Key

             Move Data-Key to Location

             Exec Cics Send Text From(Log-Position) Length(80)

             End-Exec

           End-Perform

           Perform Logit

      *   Use Error Message Area for final output message

           Move Eibresp to Resp of Error-Message

           Move ' Finished ' to Mess of Error-Message

           Exec Cics Send Text From(Error-Message) End-Exec

           Exec Cics Return End-Exec.

            Goback.

       Logit.

           Exec Cics Asktime Abstime(Abstime) End-Exec

           Exec Cics Formattime Abstime(Abstime) Time(Out-Time)

                Resp(Eibresp) End-Exec

           Exec Cics WriteQ TS Queue('Doa') From(Log-Time)

                Resp(Eibresp) End-Exec.

       Error-Routine.

           Move Eibresp to Resp of Error-Message

           Exec Cics Send Text From(Error-Message) End-Exec

           Exec Cics Return End-Exec.

Old KB# 6715

#EnterpriseDeveloper
#MFDS