Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
This blog is the follow-up on the blog How to enable clean code checks for ABAP, which describes how the code pal for ABAP checks can be used in the Code Inspector and ABAP test cockpit to check your code for the adherence to the Clean ABAP style guide.

Now there is a new free and open source version of code pal for ABAP cloud checks, which (as the name already states) is cloud-enabled, thus the checks can now be executed in SAP BTP ABAP Environment. Beyond this all checks are now remote-enabled and can be run in the remote ABAP test cockpit scenario. Additionally, to speed up your code adaptation to Clean ABAP for many findings quick fixes are provided in the ABAP development tools for Eclipse to automate your adjustment tasks.

Let’s take a look at how you can use code pal for ABAP cloud checks in your SAP BTP, ABAP environment system to check your code for Clean ABAP.

Technical Prerequisites


The code pal for ABAP cloud checks can be executed in SAP BTP, ABAP environment.

If you want to check your on-premise releases (or SAP S/4HANA Cloud, private edition systems) with code pal for ABAP cloud checks you can do it remotely from SAP BTP, ABAP environment, see also the blog ABAP Test Cockpit in the Cloud – What is already possible for more details.

You need abapGit to pull the checks from the Git repository into your system. For SAP BTP, ABAP environment systems install abapGit plugin for ABAP development tools for Eclipse.

Install code pal for ABAP cloud checks via abapGit


In the SAP BTP, ABAP environment system you will use ABAP development tools for Eclipse and abapGit plugin to install code pal for ABAP cloud checks.

Create a new package in the /CC4A/ namespace, and name it for example CODE_PAL. The source code of code pal for ABAP checks is located in the /CC4A/ (Clean Code for ABAP) namespace, so that collisions with Y*/Z* objects from other projects are avoided.

Open abapGit Repositories View in your ABAP development tools for Eclipse:


Click the „+“ button to link the new abapGit repository:


and enter the path to the GitHub repository https://github.com/SAP/code-pal-for-abap-cloud, containing the code pal for ABAP cloud checks:


In the next step enter the name of your newly created package /CC4A/CODE_PAL and check the Pull after link checkbox:


Finally, after completing the abapGit plugin wizard, the code pal for ABAP cloud checks repository will be linked:


and the source code of the check implementations pulled under your newly created package /CC4A/CODE_PAL:


Just activate all objects, and the code pal for ABAP cloud checks are ready to use.

Execute code pal for ABAP cloud checks


The check variant /CC4A/CODE_PAL_FULL contains all available code pal for ABAP cloud checks:


There is also the package /CC4A/CODE_PAL_TEST_OBJECTS, which you can use to see how the code pal for ABAP cloud checks work. Just select this package and use the context menu Run ABAP Test Cockpit With…


Enter the ATC check variant /CC4A/CODE_PAL_FULL and click the OK button to execute the ATC run:


The ATC Problems View provides the check results concerning violations of the Clean ABAP rules in the source code objects of the test package:


Now you can select your own development package(s) or set(s) of the development objects which you want to check and execute the code pal for ABAP cloud checks over these objects.

Use quick fixes


If you take a look at the ATC results, the yellow bulb icons before the ATC findings indicate that for these ATC findings the quick fixes in ABAP development tools for Eclipse are available, which allow to fix these findings in an automated way.


By navigating from an ATC finding to the corresponding source code line you can see the examples of the violations of the Clean ABAP rules and can try out the corrections, which are provided by quick fixes using the Ctrl + 1 shortcut.

In the following example the code pal for ABAP cloud check detects the unnecessary self reference, which can be removed via the quick fix:


In the next example the check finds a chain declaration, which can be replaced with separate declarations of the variables involved using the quick fix:


In the last example the values are allocated more than once within one statement and the quick fix will break the assignment chain into multiple statements:


You can also use mass-enabled quick fixes (context menu Recommended Quick Fixes will start the wizard) to adapt all ATC findings at once:



Further information


Further information on code pal for ABAP cloud checks, including how to contribute to this open source project, provide feedback or get support, is provided on the GitHub under https://github.com/SAP/code-pal-for-abap-cloud/. Use "Watch" button to get notified about changes (you get it if you log in to GitHub).

The check migration list shows the current migration status of checks from the legacy version.

What is next


We also plan to offer the code pal for ABAP cloud checks in the upcoming releases of SAP S/4HANA Cloud, private edition and SAP S/4HANA on-premise.

 

 

 

 
22 Comments
Sandra_Rossi
Active Contributor

Thanks. But I'm surprised to see that the first example of DATA is not Clean ABAP 😉

Clean ABAP: "No more than one statement per line".

ThFiedler
Product and Topic Expert
Product and Topic Expert
Hi Sandra,

that is currently a gap in Quick fix infrastructure that line breaks are not supported yet. For sure it is not the idea to code all DATA declaration into one single code line 🙂

Regards,

Thomas.
Ruthiel
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Olga!

I appreciate you sharing this solution.

I've been experimenting with ABAP Cleaner, and I must say I'm quite impressed with its customization options. It does indeed appear to align closely with your description.

I'm curious, do you have any thoughts or opinions on ABAP Cleaner?

Thanks,
Ruthiel
OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
Hi Ruthiel,

it's great, that you are using ABAP Cleaner!


Both tools (code pal and ABAP Cleaner) follow the same rules from the Clean ABAP guide, the difference is in the use case. If you want to convert existing code to clean code, then the ABAP test cockpit test mass run with code pal checks and quick fixes (as in the blog) is the way to go. Íf you write a new code and want to immediately comply with the Clean ABAP rules, then you would save the source in the editor and run the ABAP Cleaner over it because it is more effective as activating the code first and then using ABAP test cockpit with code pal checks and quick fixes. 


Kind Regards,


Olga.

Ruthiel
Product and Topic Expert
Product and Topic Expert
Hello Olga!

Thank you for the detailed explanation!

I realize now that I can use both of them!
There is no excuses for "unclean" code nowadays!!!


All the best,

Ruthiel
shasankgupta24
Discoverer
0 Kudos
Hi Olga,

Thank you for the information about this Eclipse tool for ABAP. When installing it, there is a warning that the content is unsigned and of unknown origin - is it safe to trust unsigned content -?

 

Regards, Shasank
OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Shasank,


if it happens at installation of the abapGit plugin, then it is ok to ignore the warning, because abapGit is a popular, well-known and old enough plugin (in a sense that if there had been security problems, other users would have reported them long ago).

Kind Regards,

Olga.

anuj_chawla
Explorer
0 Kudos
Hello Olga

Our infrastructure is on prem but we intend to use Code Pal via Remote system (our existing ATC + CVA checks happen via Remote - central hub system). I read a line on your blog that says all checks are now Remote enabled which were not before. Could we install Code Pal via AbapGit on our remote system and use it for connected system by integrating the checks on existing variant?

Our developers have also found an attribute on the source code where they can change the checks from local to remote enabled but by then we didn't see this blog. Is it recommended to change the attribute on Source code?

Regards

Anuj
ThFiedler
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Anuj,

currently the checks cannot be used on an-premise ATC system. The upcoming S/4HANA 2023 release will be supported.

Regards,

Thomas.
anuj_chawla
Explorer
0 Kudos
Hello Thomas

Just making sure I understand this correctly, we can use Code Pal locally on our S/4 HANA 2021 version locally as checks are not remote enabled but we won't be able to use them remotely.

Upcoming S/4 HANA 2023 release would bring support for Remote checks when Code Pal is installed.

Is the understanding correct?

Also, how about if we install the Code Pal on our ATC Remote check system and alter the attribute to have them remote enabled. Our developers have already done that and tested . Do you see any challenges with this approach?

Considering the program we are running we won't be looking at lastest upgrade for another couple of years.

Regards

Anuj
ThFiedler
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi Anuj,

if you want to use Code-PAL on S/4HANA 2021 you have to use this Github Repo: https://github.com/SAP/code-pal-for-abap/

But these checks are not remote enabled !

Just changing the flag does not mean that the checks are working remotely.

Regards,

Thomas.
ManojNachi
Discoverer
0 Kudos

Hello Olga, we are in the US region and could not find the Landscape Portal to create namespace /CC4A/ namespace. I understand Landscape portal only available for European region. In that case, how important is it to have the namespace? Could we create a ABAP Package in our BTP ABAP from ADT instead and link the code pal repo? Thank you

OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi @ManojNachi ,

yes, this should be possible. Just create a package /CC4A/CODE_PAL.

Kind Regards,
Olga.

Abdelmalk
Discoverer
0 Kudos

Hello @ThFiedler ,

Is Code Pal for ABAP - Cloud Edition available for On-premise S/4HANA 2023 release as you mentioned?

Thank you,

Abdelmalek

ThFiedler
Product and Topic Expert
Product and Topic Expert

Yes, the new Code pal for Cloud can also be used in 2023 on-premise Release. 

Regards.

Thomas.

scottlawton
Explorer
0 Kudos

Hi @ThFiedler,

If we want to install Code Pal for the Cloud in our on-premise central check system, do we have to install the ADT plugin of abapGit, or can we use the standalone version? Also, are there any differences from the installation process described in this blog if we were to use the standalone abapGit (or for any other reason)?

Thanks,
Scott

OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi @scottlawton ,

for installation of code pal checks into on-premise system you must use the standalone version of abapGit. abapGit ADT plugin works only for cloud ABAP systems. The installation procedure would be different (similar as described in the blog https://community.sap.com/t5/application-development-blog-posts/how-to-enable-clean-code-checks-for-...

Please be aware, that you can use code pal - cloud edition checks only in the S/4HANA 2023 on-premise system (lower releases are not supported), also you would need to use the SAP_BASIS 7.58-compatible version of code pal, where not all checks are available. 

Kind Regards,
Olga.

scottlawton
Explorer
0 Kudos

Hi @OlgaDolinskaja,

Thanks for your reply. I tried installing Code Pal for the Cloud today in our on-premise central check system (which was recently upgraded S/4HANA 2023 / 7.58). I was able to create the online repo and make the pull request okay, but when I try to activate the checks in SCI, I'm getting an error stating that "check category CL_CI_CATEGORY_WRAPPED is not yet active." From what I can see, these new checks are assigned to check category /CC4A/CODE_PAL, not CL_CI_CATEGORY_WRAPPED. CL_CI_CATEGORY_WRAPPED doesn't appear to exist in our system. Have you seen this error before or do you have any suggestions as to what the problem might be?

Thanks again for you help!
Scott

OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi @scottlawton,

you can use code pal checks - cloud edition only in new ATC check variants, which are created in ABAP development tools for Eclipse and not in SCI (see the blog how to do this: https://blogs.sap.com/2021/05/25/how-to-create-and-use-your-own-atc-check-variant-in-sap-btp-abap-en...).

Kind Regards,
Olga.

scottlawton
Explorer

@OlgaDolinskaja, thank you for your help! I didn't realize that there was a new way to create check variants that didn't involve SCI. Following those instructions, I was able to get a new check variant created in our central check system and the remote Code Pal checks are now working with our development systems.

Thanks again,
Scott

scottlawton
Explorer
0 Kudos

Hi @OlgaDolinskaja, I have one final question for you: Is there a way to adjust the severity of the ATC checks (i.e. whether they are errors, warnings, or informational)? That can be done in SCI for SCI-enabled checks, but so far I haven't seen a way to do that with the new checks created via ADT.

Thanks,
Scott

OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi @scottlawton,

you can do it in the ATC Configurator app, see the blog https://community.sap.com/t5/technology-blogs-by-sap/how-to-configure-abap-test-cockpit-atc-in-the-c....

Kind Regards,
Olga.