Locked Records

5 pts.
Tags:
AS/400
RPGLE
Is there an easy way to trap a Record Lock in RPGLE
ASKED: November 14, 2007  10:42 PM
UPDATED: September 11, 2013  4:31 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Use %Status built in Function or File Information Data Structure to check record lock.
You can use it like -:

If %Status(EMP) = 1217
Errmsd = Record Lock
EndIf

Where EMP is Physical File name.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Doc13
    Thanks for the help. I have captured the *status, however, I need the Program & User that initially read the record first.
    5 pointsBadges:
    report
  • bvining
    When a record lock conflict occurs the system sends message CPF5027 and %status is set to 1218. The first level text of CPF5027 is also made available to your program through the Program Status Data Structure (PSDS). This message text includes the job holding the record lock, but not the program which originally locked the record. Here is a small example of how to display this text, which does provide the job name.
    fPLClaim   uf   e             disk                                
                                                                      
    dPSDS            sds                                              
    d MsgDta                 91    170                                
                                                                      
    dWait             s              1                                
                                                                      
     /free                                                            
      read(e) PLClaim;                                                
      select;                                                         
      when %status(PLClaim) = 0;                                      
           dsply Data ' ' Wait;                                       
      when %status(PLClaim) = 1218;                                   
           dsply %subst(MsgDta :1 :51) ' ' Wait;                      
      other;                                                          
           dsply ('Unexpected error ' + %char(%status(PLClaim)) +     
                  ' found.') ' ' Wait;                                
      endsl;                                                          
                                                                      
      *inlr = *on;        
      return;             
     /end-free            
    
    As this is the actual first level text you could use this for display or logging purposes, but you would not want to parse through the text to find the job name as the location could change in the future and across national language versions of i5/OS. If you did want to explicitly determine the job name within your application you could receive the corresponding message from your program message queue. In this case the replacement data (job identification information) would be returned at fixed locations. Hope this helps, Bruce Vining Bruce Vining Services
    6,240 pointsBadges:
    report
  • Doc13
    Bruce, thanks for you help.
    5 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following