How to debug ATC Check - abap

i have to make a modification in ATC checks, but i don't know the class where the checks start.
Im talking about the check you start from SE80 -> rightclick on an object -> check (ATC) with...
i need the object set so i can delete some unwanted objects manually before the other checks start.
Does someone know the class or place where those checks start? Or where i can modify the object set before those checks?
greetings
What i've tried so far:
/h debug right before exceute the check
have a look at SATC_AC__UI_ONLINE_CHECK
some various way to dive into the code of the checks
tried this How do I debug SAP ATC (ABAP Test cockpit) test runs? but thats already after the point where i want to modify the object set.
all without success.

You can open your variant by going to T-code SCI. When you double-click on a configured check, the class responsible for that check will be opened.

Related

Change RZ11 Profile parameters programmatically

I was asked by the IT Department to write an ABAP program that switches the profile parameter login/server_logon_restriction from 0 to 1 and back automatically triggered (time etc) on all of our SAP servers.
I am not very familiar in the SAP environment yet and until now I managed to get the wanted parameter by using:
RSAN_SYSTEM_PARAMETERS_GET
and
RSAN_SYSTEM_PARAMETERS_READ
But I cannot find anything to change and save them dynamically. Is this even possible?
Cheers, Nils
login/server_logon_restriction parameter dynamic so you can change it via cl_spfl_profile_parameter=>change_value class method.
You can configure background job for automatically trigger it in t-code SM36.
The method don't save the given value to profile file, so the parameter turn back profile value after system restart.
Current logged-in users can continue to use system. May be you can want to inform them with TH_POPUP function then kick from the system.

How do I debug SAP ATC (ABAP Test cockpit) test runs?

I am running ATC (ABAP test cockpit) tests from SE80 ABAP workbench.
It is not the first time that I do not understand an ATC test result. (SAP standard check)
(I am a developer, without experience as ATC administrator)
What are good breakpoints to see how SAP tests ABAP code and/or emits test result to the ATC result list?
I find it hard to start an ATC test in the debugger from SE80, since the right mouse click to start ATC already invokes the debugger.
I have no rights for transaction ATC.
You need to know which check is making you trouble. If you know, you can either find it via the classes ( CL_CI_* ) - which is kinda hard or you access the transaction "SCI".
In this transaction you go "Code Inspector" ->"Management Of" -> "Tests" and you should get the following screen:
Here you can find any check and category ( unfortunately I don't know how it is ordered ). Then you find your check, which is making you problems. For example: "Recognizing Dead Code" and you get the class ( in this case "CL_CI_TEST_CROSSREF" ).
Then you go into the method, which is called "run", and set a breakpoint there. The Run method is the one which gets called at the start of the test.
Then, when you check your code with ATC or SCI ( sci is the base of atc ) you will get into the debugger.
Start with the accepted answer. It is correct and good.
If the debugger doesn't stop where you expect:
In an environment with a central ATC server, the tests are done with two different users: your own user and an RFC user.
To find out which RFC user, open two windows.
- start a longer running test in the first window
- open transaction SM50 to se which users are performing the tests.
Then set a breakpoint for the RFC user
In addition, in our system I experience the following:
If a check is performed by the RFC user, then a break point works for exactly one ATC run.
At the second run, it won't stop at the breakpoint. Remove and set the breakpoint, then it is good for one more ATC run.

Check original language of repository objects at creation?

In our company, repository objects must be created with original language EN.
Is there a way to check the logon language in case of creating a new object in the ABAP repository?
Desired behaviour:
SE80 - Create program/class/data element/table/....
==> user exit/badi checks the logon language. When it is not 'EN', the creation will be refused.
regards,
Umar Abdullah
I know there is a exit for this but I haven't remember exact name. You can use general purpose for finding exit. Go to SE24 and open CL_EXITHANDLER class, find GET_INSTANCE method and add break point. Then start creating item, it will pause on debugger multiple times, try to find suitable one.
As #mkysoft suggested, you may implement a check in the BAdI CTS_REQUEST_CHECK, method CHECK_BEFORE_ADD_OBJECTS, which is invoked when the object is about to be attached to a transport request. Raise the exception CANCEL to make the attachment fail (and so the object is not created too).
EDIT: sorry, ignore my answer, "this method is NOT released for Customer usage" as said in note 2150125 - Method CHECK_BEFORE_ADD_OBJECTS not triggered
DISCLAIMER: THE METHOD DESCRIBED HERE IS ABSOLUTELY NOT RECOMMENDED.
As correctly pointed out by the other members there is no standard and customer-exposed method to achieve your requirement, but if you absolutely must enable this check during creation you can use the below method. As well as the previously offered to you, it also involves modification of SAP standard.
There is a system BAdi CTS_TADIR_SUBSCREEN that is located inside enhancement point CTS_ES_TADIR_POPUP. They are SAP internal and not released for customer usage, so do this at your own risk.
Implementation procedure:
Step 0. First thing you need to change is a SAP internal usage flag, for which you need Object Access key which can be obtained from SAP or from SAP partner that made the implementation in your org. In virgin state this BAdi throws the error if you try to implement it
So hereinafter we assume that you already ticked off this checkbox in BAdi settings
Step 1.
In order to implement the BAdi one need to implement enhancement spot prior to that. This is the most complicated part, because despite we disabled internality flag the SAP-namespaced enhancements must be stored only in SAP-namespaced objects. By SAP namespace I mean non-Z, non-Y and non-T (Test). This means to implement this enhancement, besides modifying the enhancement definition, one need to create, for example, CTS_ES_TADIR named enh.impl., and save it to non-Z package, which you also need to create. Your enhancement implementations selector should look somehow like this
On the above screen only the second will work, all the rest Z will not.
Every non-Z object need Object Access Key, remember? Too bad. But just to show the proof-of-concept, I will proceed.
Step 2. After you created the enh. implementation in SAP-namespace it will propose you to create the BAdi implementation. The same principle applies here: only SAP-namespaced container for SAP-namespaced objects, hence CTS_TADIR_SUBSCREEN should have implementing class for example CL_TADIR_SUBSCREEN. During the creation of enhancement you will see many warnings
but finally you should have something like this, where all system-named objects are created and the enhancement/BAdi is activated.
Step 3. In order to get the BAdi working we need to enable this subscreen processing
during the playing with enhancement I found out that BAdi class is not being triggered standalone, without screen events not enhanced, so to make it work you need to touch a screen enhancement for screen 100
If you do not wanna modify screen elements logic, just put the dummy enhancement in SHOW_TADIR dialog module in the end of the include LSTRDO18
PROCESS BEFORE OUTPUT.
MODULE SHOW_TADIR. "<-- create the dummy enhancement here
CALL SUBSCREEN subs_info INCLUDING gv_badi_prog gv_badi_dynnr.
for example declaration statement like I did
Step 4. Activate your created BAdi class and put the necessary logic there. I wasn't able to trigger method GET_DATA_FROM_SCREEN, but PUT_DATA_TO_SCREEN worked fine
If we put this simple processing for your requirement
METHOD cts_if_tadir_subscreen~get_data_from_screen.
IF object_data-l_mstlang <> 'E'.
MESSAGE 'Objects in non-English languages are not allowed!' TYPE 'A'.
ENDIF.
ENDMETHOD.
it will not allow creating objects in languages other than English.
The check in method get_data_from_screen is being done before showing the screen so language is determined from system logon settings. If to play more with this BAdi, I suppose the method GET_DATA_FROM_SCREEN can also be enabled, which will make it possible to check user input, i.e. the case when the user gonna change the default language.

Correct terminology for Dead Man Switch

I've implemented a Dead Man Switch this way:
A script can be fired by an event. When the script starts it looks for a specific object on an S3 bucket. If that object can't be found for any reason (be it network issues to access the bucket, lack of permissions, the object was removed or any other reason) then the script will abort before doing any other actions.
I suppose this is a classic Dead Man Switch.
The idea is to let us remove this object in case we need to stop the script in an emergency.
My question is about terminology - I also supply a script to our team to create or remove that S3 object. I want it to be clear which actions means what (remove object - stop script from doing anything, create object - let the script continue with its work). I used "removed" and "reinstate" and was told this is too ambiguous. I now contemplate about "pushed" and "enabled" but this too sounds too vague. I'm also thinking about "pulled" (object removed) vs. "rearmed" (object created).
It's important that the terminology will be clear since if this script is used then this is expected to happen during emergency, so we want to minimize confusion as much as possible.
I suppose the problem is the inherent "double negative".
So far I didn't find any common name used to describe these actions. Wikipedia and other places describe what the switch is, but not actions of enabling or disabling it.
Any ideas?
I would say that the system would be:
Enabled if the object is present
Disabled if the object is absent
Placing the object would enable the script.
Removing (deleting) the object would disable the script.
You could even call the file enable-xxx-script to make it more obvious.

Run code when user deletes module from a page

I'm currently developing a DNN module. It would be nice if we were able to run custom code whenever a module is deleted from a page by the user, and also when a module gets restored from recycle bin.
I haven't found any examples on how this could be done, so I'm not sure if this is possible? Any ideas?
I am unaware of any event mechanism inside DNN where you could set your hooks. You could probably debug the DNN code and trace the call stack until you find a usable spot where you can inject some code (which would likely be destroyed after the next DNN update), or maybe detect a way that was intended to be used by the core team.
However, if a module is deleted from a page, the IsDeleted field in the Modules table is set to true. If it gets restored from the bin, it is again set to false.
You can use a TRIGGER in your Sql Server that fires when the Modules table is updated, checks if the update refers to an IsDeleted field, write stuff into a Notification table, and use Sql Query Notification based on SqlDependency to run some code (see http://www.codeproject.com/Articles/144344/Query-Notification-using-SqlDependency-and-SqlCach for an introduction).
Some steps to go, but it should work (and be less exhausting than climbing the Matterhorn :-) ).
There is absolutely hooks in DNN Platform (DotNetNuke) that a developer can attached C# code to.
While there isn't a turn key example that I can provide at the moment, check out the following:
https://github.com/dnnsoftware/Dnn.Platform/blob/c35fdc7fb75db0438f3b872ce4e279e3ea73e7c2/DNN%20Platform/Library/Entities/EventManager.cs
You are looking to hook onto the ModuleRemoved event by the sounds of it.
Here is an example for the user logging in that you could adapt to your event:
Does DNN fire an event when a user logs in?
I hope this helps in the future.