Search This Blog

Friday, August 12, 2011

Sample Code to Lock / Unlock Program Editor


Program to Lock / Unlock program editor. The SAP Standard Table TRDIR has a field called EDTX which is basically the EDITOR lock field. Edit Lock facility is given in the PROGRAM ATTRIBUTES. The EDITOR LOCK is a check box given in the PROGRAM ATTRIBUTES. If this field is SET then the program gets locked and if this is Unchecked the program is unlocked.


If the EDITOR lock is ON then only the user who created the program can edit it.
REPORT  ZXXXX.
TABLES : TRDIR.

PARAMETERS : PROG_NAM LIKE TRDIR-NAME,
             EDTX 
LIKE TRDIR-EDTX.

SELECT SINGLE * FROM TRDIR WHERE NAME = PROG_NAM.

  
IF SY-SUBRC = 0.
    
IF TRDIR-EDTX = EDTX AND EDTX = ' '.
      
MESSAGE 'Already Unlocked' TYPE 'I'.
    
ELSEIF TRDIR-EDTX = EDTX AND EDTX = 'X'.
      
MESSAGE 'Already Locked' TYPE 'I'.
    
ELSE.
    TRDIR-EDTX = EDTX.
    
MODIFY TRDIR.
        
IF EDTX = ' '.
          
MESSAGE 'Program Successfully Unlocked' TYPE 'I'.
        
ELSE.
          
MESSAGE 'Program Successfully Locked' TYPE 'I'.
        
ENDIF.

    
ENDIF.
  
ELSE.
    
MESSAGE 'Program Not Found' TYPE 'I'.
  
ENDIF.