How to trigger Code Inspector checks during the release of a ‘task’?
Bugs in your custom ABAP code can be quite expensive when they impact critical business processes, which is why quality assurance of custom ABAP code is receiving more and more attention in business. Detecting bugs early in the development stages before they can be moved across the landscape ensure that the cost and risk impact is minimal. To reach this goal, SAP offers the ABAP Test Cockpit (ATC) and Code Inspector as quality assurance tools.
The ATC is available with EhP2 for SAP NetWeaver 7.0 support package stack 12 (SAP Basis 7.02, SAP Kernel 7.20) and EhP3 for SAP NetWeaver 7.0 support package stack 5 (SAP Basis 7.31, SAP Kernel 7.20).
General process for releasing a transport request
The transport organizer is a tool for managing the objects that gather the changes carried on during the development and configuration phases, and for transporting them across the landscape. The two kinds of objects used are the Request and the Task.
The Request is the main container, which contains zero to any number of Tasks.The CTS automatically creates one task for each user who adds objects to the Request. An ABAP transport request may contain many tasks that are assigned to different users.When you want to transport the Request, you have to first release all the tasks of the request, and then the request itself. When it is released, the transport is done automatically or manually by the administrator. The transport goes towards the systems and clients defined in the transport routes.
Current behavior of Code Inspector checks during the release of a transport request or a transport task
Releasing a transport request or a task can be considered as the first quality gate to ensure that poor quality custom code is not transported across the landscape. Currently, Code Inspector checks can be activated during the release of a transport request. To activate this feature, perform the following steps
- Go to transaction SE03
- Double click on the entry ‘Global Customizing’ (Transport Organizer)
- Under ‘Check Objects when Request Released’ , select the option ‘Globally Activated’.
Now this activates the check of a transport request. But there may be the requirement to check also the single ‘tasks’. Currently, automatically triggering Code Inspector checks during the release of a ‘task’ is not available as a standard. To address this requirement, SAP provides a standard BAdI ‘CTS_REQUEST_CHECK’, that can be implemented by customers to trigger code inspector checks during the release of a task.
In this blog, I will illustrate the steps required to implement the BAdI, which when activated will trigger the checks during the release of a task.
(please adapt the naming conventions, texts, badi names, class names etc as per your requirement)
Steps for triggering Code Inspector Checks during the release of tasks
- Go to transaction SE19
- At the create implementation box provide the name of the classic BAdI „CTS_REQUEST_CHECK‟ and click on the button „Create Impl.‟
3. Provide a BAdi implementation name
4. Provide a short text. Click on the „Save‟ button. Provide package details when prompted
5. Double clicking on the method ‚check_before_release„ of the BAdi interface takes you to the method implementation of the generated ABAP object class that was created during BAdi impl creation.
6. In the method „CHECK_BEFORE_RELEASE‟ first check if the release concerns a transport request or a transport task.Code the following portion in the method ‘CHECK_BEFORE_RELEASE’
7. For calling the actual Code inspector check itself create a new private method sci_check in the class „ZCL_IM__CTS_REQUEST_CHECK‟
Provide the following parameters for the method SCI_CHECK
create the method exception
8. The rest of the method SCI_CHECK contains the various steps of creating Code inspector check, assigning variants, object sets etc.It is sufficient if you copy the piece of code from the attachment ‘sci_check.txt.zip’
9. Finally create the message class „ZSCI‟ with the following values
10. Save and activate all your changes. Do not forget to activate the BAdI implementation in transaction SE19.
* Deactivate the BAdI in SE19, if you do not wish to use this feature
Thkanks for sharing this. Shouldn't it it have been better to use function module TR_INSPECT_OBJECTS for doing the ATC check? In this case even the ATC exemption routines and the settings in ATC and SE03 would be valid.
TR_INSPECT_OBJECTS is exaclty what i was looking for - thx
Great advices. I have a further question. How can I propagate my error message to the user interface. How can I make the user know why his transport was not executed and display the message in the logger window for errors and warnings.
ideal would be that you first turn on the standard Code Inspector integration in SE03 and there you will see how it works as an example. Then you can mimic that behaviour or change the behaviour but already knowing what you don't want and where you are heading next.
We are using the function module TR_INSPECT_OBJECTS for performing the checks. This raises the same type of message popup as in releasing the whole transport.
I succeded to do my task as follows:
DATA: LS_LOG TYPE SPROT_U,
LT_LOG TYPE STANDARD TABLE OF SPROT_U,
LT_LINES TYPE TABLE OF TRLOG INITIAL SIZE 0.
* add your logs to lt_log table
LS_LOG-LEVEL = '02'.
LS_LOG-AG = 'EU'.
LS_LOG-MSGNR = '901'.
LS_LOG-NEWOBJ = ABAP_FALSE.
LS_LOG-LANGU = 'EN'.
LS_LOG-VAR1 = 'some important information here'
LS_LOG-SEVERITY = 'S'.
APPEND LS_LOG TO LT_LOG.
*then call some transform function - I don't know exactly what it does 🙁
CALL FUNCTION 'TRINT_CONVERT_LOG'
IT_MSGS = LT_LOG
ET_LINES = LT_LINES.
*and then show the error messages
CALL FUNCTION 'TRINT_DISPLAY_LOG'
IV_TITLEBAR = 'your title here.'
CT_LINES = LT_LINES
CV_WITH_LONG_TEXT_ICON = LV_WITH_LONG_TEXT_ICON
OTHERS = 0.
I could not find the attachment for 'sci_check.txt.zip' in your blog. Can you show me where should i get the the file?
Thanks and Regards
I also could not find the attachment for ‘sci_check.txt.zip‘ in your blog.
meanwhile it is also possible to release tasks/requests from Eclipse/ADT. Is there a way to integrate the CTS_REQUEST_CHECK BAdI also with ADT? I’d like to see the SCI results in Eclipse when releasing a task/request from ADT – ideally I’d like to choose to cancel or continue the release in case of SCI messages.
The BAdI is called when you release a TR via ADT.
The ATC is integrated with the ADT and you can trigger it for a TR as well.
Context Menu > Run As > ABAP Test Cockpit
Yes, I'm aware of this, but I'd like to also see the Code Inspector results (from the BAdI call) when I release a task automatically in Eclipse (without separately executing ATC) - or at least a message displaying that errors / warnings did occur. That's the benefit when implementing the BAdI: you can enforce executing the checks on task release.
So may question is how to transfer result data from the BAdI to ADT?
Then, the second step would be to popup a dialog if the release should be continued or not.
I also could not find the attachment for ‘sci_check.txt.zip‘. Would you be so kind to indicate where this can be obtained as I have already done most work and now I am stuck at the step to add the code to the SCI_check method.
I will be appreciated.
Hi Mahadevan Venkata.
Could you attach the file sci_check.txt.zip.
Hi Mahadevan Venkata
Can you please add the file sci_check.txt.zip.
Hi Mahadevan Venkata
I agree with the other comments - with the attachment sci_check.txt.zip the blog would be really helpful. Can you please add the file sci_check.txt.zip?
Isn't it same as note: 2495410. ?
The blog is slightly outdated and further the text file containing the code got deleted during migration(to community) of the website.
However, the good news is that this feature is now available as an SAP standard.
Please read the note 2495410 to get more information on how to activate this.
Happy releasing more tasks/requests 🙂