I have looked at the other record lock questions/answers on this board but have been unable to find an answer to this problem.
I am trying to capture a record lock error in a submitted program. The program is coded to capture the File Status as shown below.
I have tested this same record locking capture code in an interactive program and it works with no problems. But for some reason the submitted program doesn't not work the same way.
FSRBNAM UF E K DISK infds(SRWNAM)
D SRWNAM DS
D Status *Status
C DOU Status <> 1218
C EVAL EVENT = 1
C EVAL FMCUST = '000016'
C*
C* Read the Customer Master Record
C FMCUST CHAIN(E) SRBNAM 99
C*
C* Check the File Status, if record was locked, execute subroutine
C* IF %Status(SRBNAM) = 1218
C* Execute Subroutine to handle record lock
C EXSR SR90
C* ENDIF
C*
C ENDDO
My problem is that the subroutine SR90 is not being executed, although I have verified that the Customer Record for 000016 is locked by another program.
When this program is actively running in batch I've looked at the job log and see these entries:
>> CALL PGM(A3DEVSRA/RCDLCKTST2)
Record 26603 in use by job 245024/KLM/QPADEV0149.
? C
Record 26603 in use by job 245024/KLM/QPADEV0149.
? C
No one is manually answering the message, I've looked at the system reply list and don't see a "1218" auto message reply entry.
When I cancel the batch job and look at the job log I see these entries:
00 11/26/08 09:15:43.725168 QWTPCRJA QSYS 010F *EXT
Message . . . . : Job 246458/KLM/RECORDLOCK submitted.
11/26/08 09:15:43.725624 QWTSCSBJ *N QCMD
Message . . . . : -CALL PGM(A3DEVSRA/RCDLCKTST2)
30 11/26/08 09:16:46.741920 QDBSIGEX QSYS 01EA QDBSIGEX
Message . . . . : Record 26603 in use by job 245024/KLM/QPADEV0149.
30 11/26/08 09:16:46.741936 QDBSIGEX QSYS 01EA RCDLCKTST2
To module . . . . . . . . . : RCDLCKTST2
To procedure . . . . . . . : RCDLCKTST2
Statement . . . . . . . . . : 141
Message . . . . : Record 26603 in use by job 245024/KLM/QPADEV0149.
11/26/08 09:16:46.742104 QMHCHGEM QSYS 0146 RCDLCKTST2
To module . . . . . . . . . : RCDLCKTST2
To procedure . . . . . . . : RCDLCKTST2
Statement . . . . . . . . . : 141
Message . . . . : C
11/26/08 09:16:46.742112 QMHCHGEM QSYS 0146 QDBSIGEX
Message . . . . : C
What do I need to change to get my submitted program running in batch to capture the record lock status and allow the subroutine to handle the situation.
Kevin
Software/Hardware used:
ASKED:
November 26, 2008 2:50 PM
UPDATED:
November 28, 2008 10:12 AM
I looked at the Job Definition Attributes of the submitted job, it is set to *RQD.
Job: RECORDLOCK User: KLM Number: 246458 Default output queue . . . . . . . . . . . . . . : QPRINT Library . . . . . . . . . . . . . . . . . . . . : QGPL Job date . . . . . . . . . . . . . . . . . . . . : Date format . . . . . . . . . . . . . . . . . . . : *MDY Date separator . . . . . . . . . . . . . . . . . : / Time separator . . . . . . . . . . . . . . . . . : : Time zone . . . . . . . . . . . . . . . . . . . . : QN0500EST3 Decimal format . . . . . . . . . . . . . . . . . : *BLANK Job switches . . . . . . . . . . . . . . . . . . : Inquiry message reply . . . . . . . . . . . . . . : *RQDHi Kevin,
The job is set to *RQD and it still auto replies to the locked record messages in the joblog? Which column is your indicator 99 in for your CHAIN opcode?
Regards,
Martin Gilbert.
Hi Gil, it is in the HI position to check if the record is not found.
Kevin
I tested your code on my system, using the following two programs (file changed to suit our database) :
TSTLCK1 program….
FCUSTL1 UF E K DISK infds(SRWNAM) D SRWNAM DS D Status *Status D Response S 1 Inz('A') C K_CS KLIST C KFLD CSSTAT C KFLD CSCUST C EVAL CSSTAT = 0 C EVAL CSCUST = 'GBSIMON1' C DOU Status <> 1218 C* Read the Customer Master Record C K_CS CHAIN(E) CS 99 C* Check the File Status, if record was locked, execute subroutine C IF %Status(CUSTL1) = 1218 C Status DSPLY 'BLECMD' Response C ENDIF C ENDDO C EVAL *INLR = *ONTSTLCK2 program….
FCUSTL1 UF E K DISK infds(SRWNAM) D SRWNAM DS D Status *Status D Response S 1 Inz('A') C K_CS KLIST C KFLD CSSTAT C KFLD CSCUST C EVAL CSSTAT = 0 C EVAL CSCUST = 'GBSIMON1' C* Read the Customer Master Record C K_CS CHAIN(E) CS 99 C Status DSPLY Response C EVAL *INLR = *ONRunning TSTLCK2 interactively holds the record lock until a reply is entered.
Sending TSTLCK1 to run in batch results in a wait on the locked record (1 minute), then the DSPLY operation sends its message to my message queue requiring a response.
In the batch job, Inquiry Message Reply is *RQD.
So; I can’t see any reason why your code should not work in batch. Try using the DSPLY or DUMP operations to see the contents of the STATUS variable; and make sure that there really IS a lock on the record you expect.
Regards,
Sloopy