Welcome to SAP Wiki SDN.
This Wiki is about how to protect a Program or a Object which is developed by you from copying or Changing by other SAP Users of Same Environment. Generally when we develop a program which has given a big Value Add to the Client or to the Company, The Properietary of that Object is either the Programmer who developed it (Incase if he is a Freelancer kind of role) or when he is working for a Client or any Orgranisation then that particular entity/organisation Holds the Copy Right. As we all know SAP supports good Security Levels on the Authorization checks and other Business Roles with Authorization Objects developed via SU20/SU21 by SAP Security or SAP BASIS Consultants and Later the Authorization Object will be used by ABAP Consultant called in the Program for the Authorization check with Syntax AUTHORITY-CHECK OBJECT 'objectname' etc... A Authorization Object will give a Knock In or Knock Out Access as per the requirement(In our case requirement is Hold Copying or Changing the Object). Here comes the question, To achieve this, What if I dont have a Authorization Object and still want to do the restriction?. The Answer is simple, when we want to achieve the same thing, we can use the BADI "CTS_CURRENT_PROJECT" to perform this operation. So when you want to restrict the Object from copying or changing by other SAP Users of same System or Environment. You need to Implement a BADI where you can write your custom Code that stops others to Copy or Change the Program/Object. Though an ABAPer can do anything in the debugging this document tells you the Basic level of holding the Copy right. Remember the cautious note is it will stop other persons to do any activity on the Objects.
What needs to be done to achive this. These are the steps below.
1. Goto SE18 and check the BADI "CTS_CURRENT_PROJECT". Enter this BADI Name in the "Definition Name" and Navigate to Menu Path Implementation->Create.
2. After Clicking on the Create Button On the Pop-Up enter the Below Implementation Name as shown below.
3. Give the Short Description and Package Details as shown in the below screen shot.
Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
4. Once Saved, Now Double Click on the Interface Method "GET_CURRENT_PROJECT" and write the Code shown below.
DATA : X_OBJECTS LIKE LINE OF IT_OBJECTS, X_USER TYPE SYST-UNAME VALUE 'YOURSAPUSERID'. "-->You might have thought on Length of Sy-Uname :). This should be your SAP Logon User ID. CONSTANTS : C_SE38 TYPE SYST-TCODE VALUE 'SE38'. READ TABLE IT_OBJECTS INTO X_OBJECTS WITH KEY OBJ_NAME = 'YOUR_REPORT_PROGRAM'. IF SY-SUBRC = 0 AND SY-UNAME <> X_USER. "X_USER Will be YOURSAPUSERID MESSAGE ' Hahaha You cannot change my Object' TYPE 'S'. SET PARAMETER ID 'RID' FIELD X_OBJECTS-OBJ_NAME. CALL TRANSACTION C_SE38 AND SKIP FIRST SCREEN. ELSEIF SY-SUBRC = 4 AND SY-UNAME <> X_USER. "---------------------------> This Else Part is for Copying the Program. "This will create PROBLEMS FOR OTHER TO CREATE THEIR OWN PROGRAMS ALSO. MESSAGE ' Hahaha You cannot copy my Object' TYPE 'E' DISPLAY LIKE 'I'. SET PARAMETER ID 'RID' FIELD X_OBJECTS-OBJ_NAME. CALL TRANSACTION C_SE38 AND SKIP FIRST SCREEN. ELSE. "Do Nothing. ENDIF.
5. Activate the Method and Activate the BADI and now time to do testing. Goto SE38 and enter the Program name that you have given in the BADI Interface Method. (YOUR_REPORT_PROGRAM assuming you have this program in your system). Logon with other SAP User ID(Should not be the same which you have given in the BADI Interface Method) and Try to change(F6) or Copy(Ctrl+F5) the Program from the transaction SE38 and see the result.
Note: When you implement this BADI It will be effective for the other Users and their programs. This is because of the ElseIF Part which is highlighted in the above mentioned code. So before you implement this code, You need to check whether you want to stop everyone for copying or changing the program.If you want to allow some users to have give access to those users for copying or changing the program. For this you need to add those User IDs also and compare them with the Current User ID similarly as you did with X_USER.
Thanks & Regards,