Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
The Open Source contribution Clean ABAP style guide for ABAP coding offers best practices and set of rules for you as developers to enable you to write more efficient, easier to understand and maintainable code. Having a common understanding of the code style enhances consistency of the code base and thus significantly improves your developer experience enforcing to work more quickly with even unfamiliar code and speed up the ramp up of new developers in your environment.

The style guide allows to enforce rules with static code checks. Based on the Clean ABAP, the free and Open Source code pal for ABAP tool contains a set of checks to support the Clean ABAP adherence. Code pal for ABAP checks can be used in Code Inspector and ABAP Test Cockpit.

Install code pal for ABAP via abapGit


In order to install code pal for ABAP you need to pull the Git repository using abapGit. If you don’t have abapGIT in your system then just install standalone abapGIT version.

Start abapGIT


and select New Online:



Enter the link to the code pal Git repository https://github.com/SAP/code-pal-for-abap.git  along with a package name e.g. ZCODE_PAL_FOR_ABAP. This package will be created automatically when pulling from the Git repository. Alternatively, you can select Create Package to create the package manually with your own settings. Use Folder Logic Prefix and enter Display Name e.g. code-pal-for-abap. Select Create Online Repo.


Select Pull to copy all objects from the Git repository into your SAP system:



Configure code pal for ABAP checks


Start Code Inspector (transaction SCI)  and activate code pal for ABAP by using the menu Code Inspector->Management of->Checks


and by selecting all code pal for ABAP checks and clicking the Save button:


After that create a new global check variant, e.g. ZCLEAN_ABAP. Select the code pal for ABAP checks group and save it:


You can also use the „Attributes“ button



to configure the applicability of a check for example according to the object‘s creation date or severity of an ATC message:



For advanced users: You can also use the code pal profile management tool to configure the code pal checks behavior for your individual needs (e.g. check filter on object creation date, validity period etc.). But please be aware, that if you assign a profile to your user, it will overwrite the Code Inspector variant.

Execute clean code ABAP checks


Congratulations! Now you are able to execute your clean ABAP (abap code pal) checks over your code. Just select the package in your project in the ADT in Eclipse (ZCLEAN_ABAP_DEMO in our example), use the context menu Run As -> ABAP Test Cockpit With…


and choose ZCLEAN_ABAP as a check variant:


The result list with the ATC findings from clean code checks will be displayed in the ATC Problems View and you can navigate to the details of each finding and process the list to fix the issues in order to make your code adherent to Clean ABAP.



What is new?


Now there is a new free and open source version of code pal for checks. In this version code pal checks can be executed on SAP BTP, ABAP environment and are remote-enabled. Additionally we provide quick fixes to automate and thus speed up the adaptation to Clean ABAP. For more details see this blog Clean code checks for ABAP – Cloud Edition.
26 Comments
larshp
Active Contributor
guarantee the Clean ABAP adherence

Note that it does not guarantee adherence to Clean ABAP, checks are both non-exhaustive and some not relevant for Clean ABAP
OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
Hi Lars,

thanks, changed it!

Kind Regards,

Olga.
alejiandro_sensejl
Active Participant

Hi Olga,

thank you for sharing that blog! We are actually using Code Pal for quite some time and I can also confirm that it allows some checks that are very helpful to introduce Clean Code rules to ABAP. 👍

I am wondering about status of Code Pal for ABAP project. There is hardly any activity in Code Pal on Github since release 1.17 was withdrawn in February and it looks like (from the outside..) that development only continues at SAP internally. 😟 Can you share some insights on that? -- Thank a lot!

Cheers,
Alej

hardyp180
Active Contributor
0 Kudos
Is the Code Pal really open source?

Open source implies if I find a bug and/or have an improvement I can submit this via GitHub?

Is this the case or can only SAP employees suggest changes?

Cheersy Cheers

Paul
BaerbelWinkler
Active Contributor
0 Kudos
Thanks for this helpful blog post, Olga!

I immediately followed the outlined steps (just used the ZIP-File option to grab the checks from Github) and successfully added the CodePal checks in one of our sandbox systems. But, when I then run ATC Checks with the new check variant I don't get any findings, just the message "The objects passed the chosen checks without any finding". Considering that I tried with a complex old procedural ABAP program which contains many MOVE-statements, it seems as if the checks haven't actually been executed as it should have found "something". The check also runs fairly quickly as it's not really doing much of anything. Other checks are running and produce results.

I'm working in a NW7.50 system with SP 22.

Do you have an idea what the issue could be and/or where I could look for the root cause?

Thanks much and cheers

Bärbel
OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert

Hi Alej,

Code Pal is open source, here you can see the commits, which have happened lately, e.g. in March 2022. This improvement for example was done by a non-SAP employee.

Kind Regards,

Olga.

 

OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
Hi Paul,

yes, the Code Pal is really open source. Here you can see for example the small improvement, which was contributed recently by the non-SAP employee. Feel free to submit your improvements or detected bugs :-).

Kind Regards,

Olga.
OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
Hi Bärbel,

if it's just about the Code Pal  checks - other ATC checks returning results on the same objects - then the best way to get support for this is to open an issue in the CodePal repo. If other ATC checks do not deliver anything either, then a normal customer message is appropriate.


Best Regards,


Olga.

BaerbelWinkler
Active Contributor
Thanks, Olga!

Other checks produce the expected results. It's just as if the CodePal checks are completely ignored which seems to be corroborated by SAT-checks I just ran: none of the new Y_CHECK-classes makes an appearance in the results if I either run the CodePal check variant or if I add the CodePal checks to an existing check-variant.

As I try this in a sandbox system I put the checks into a $-package. But this shouldn't have a bearing on them getting executed or not, I hope?

I'll open an issue in the repo to see what's what!

Cheers

Bärbel
OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
Hi Bärbel,

just one idea: have you actually activated the Code Pal checks in SCI (as described in the blog)?

Thanks!

Olga.
BaerbelWinkler
Active Contributor
0 Kudos
Hi Olga,

yes, I checked all the boxes and saved the setting:



When I hit save, a transport request pop-up was displayed and I had to click <Enter> multiple times, i. e. once for each of the checks (which was a bit weird, to be quite frank!) and they now show up in the transport:



I can also include them in an existing check variant:


Really not sure what's "happening" here to make them not getting executed...

Cheers

Bärbel

 
BaerbelWinkler
Active Contributor

olga.dolinskaja

Hi Olga,

I think I narrowed down the reason why the checks don't find anything: it seems to have to do with when a program was created. Here is why I think that: the program I tried with was created several years ago and even though the checks seem to get accessed when I run it in debugging, no issues are found. I just now copied the whole program into a new local copy and ran the checks again and now it produces the expected long list of issues.

This "cut-off" date seems to be definied in the select-options for each check:

So, it can be manipulated there for each check which is just a wee bit tedious. Some questions:

  • is a cut-off date like this really needed?
  • instead of querying the creation date of a program, how about making it dependent on last update?
  • If the date is needed, is there a central point somewhere in the check-code where it can be updated?

I also headed over to Github to add this as an update to the issue I created on Github: https://github.com/SAP/code-pal-for-abap/issues/560

While there, I noticed an update from Björn pointing to the solution as well as the profile management tool where the settings like the cut-off date can be tweaked. How about adding this to your blog post to make others aware of it and to avoid them running into the same situation I did?

Thanks much and cheers

Bärbel

 

OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
Hi Bärbel,

thanks for your investigations and effort! I've updated the blog according to your suggestion.

Best regards,

Olga.
former_member803233
Discoverer
Great post
alejiandro_sensejl
Active Participant
Hi Olga,

thank you for yor response. I was aware of that improvement from community, but there were no commits from SAP since February - although being a very frequent contributor in the past.

That's why I was wondering whether SAP may have dropped that project (or does not make updates public on Github)?

Cheers,
Alej
Attila
Active Participant

Hi All,

thanks for sharing.The findings are cool, however I recognized reading the Clean ABAP/Code Pal reference docs in more detail is still a must. Some of the ATC finding descriptions are short, or at least not trivial what to do with them for the first time without background information / further searching.

I remember one of the great bfeeb8ed7fa64a7d95efc21f74a8c135s books with a link to abapOpenChecks. Are the checks complementing or covering each other ? Should we use both ?

I am trialing this at the moment and noticed that the new variant is not showing up in ADT, but in case I manually input the name and execute, then it works fine actually. I am running the 1909 developer edition on docker, so no official SAP support is possible, but this can be a good hint for others.

 

 

Best regards, Attila

 

POV8FE
Explorer
Hallo Olga,

as I saw all checks are for local scenario, not remote enabled.

Is it planned to add this checks to SAP Standard as remote enabled checks or will they only be available as Open Source on GitHub ?

Thanks a lot,

Volker
OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
Hi Volker,

the code pal checks will stay Open Source, we don't have any plans to add them to SAP standard checks. Please address your improvement request about the remote enabling via GitHub.

Best regards,

Olga.
BaerbelWinkler
Active Contributor
olga.dolinskaja

Hi Olga,

I'm currently re-starting an implementation of the CodePal-Checks and am wondering what exactly this update at the end of your blog post means:

"Code pal checks can now be executed on SAP BTP, ABAP environment and are remote-enabled."

Are now all CodePal checks remote-enabled or does this only apply to the Cloud version described in the linked blog post about "clean code checks for ABAP in the Cloud"?

If they are remote enabled, I'd only need to go through the motions once to add them to our central ATC-system (which is now on S/4HANA 7.56) instead of in 3 systems separately. This would also make it a lot easier to get internal approval as no actual development systems would be impacted.

Could you please clarify?

Thanks much and cheers

Bärbel
OlgaDolinskaja
Product and Topic Expert
Product and Topic Expert
Hi Bärbel,

it applies only to the cloud version of the clean code checks as described in the blog https://blogs.sap.com/2023/09/11/clean-code-checks-for-abap-cloud-edition/.

I have just updated the "What is new?" chapter to explain it more clearly.

Thank you for the notice!

Best Regards,
Olga.
BaerbelWinkler
Active Contributor
Thanks for the clarification and update, Olga!

Cheers

Bärbel
ThFiedler
Product and Topic Expert
Product and Topic Expert
Hi Bärbel,

if you update your central ATC to 7.58 (2023 version) you can also use the new remote enabled Code pal Checks on-premise.

Regards,

Thomas.
BaerbelWinkler
Active Contributor
Thanks, Thomas!

I'm however not aware of any plans to upgrade the system as it was only set up last year. But I'll check with my colleagues.

Cheers

Bärbel
WandersoWcs
Discoverer
0 Kudos

Hi,

    After selecting the items and clicking save, I receive the attached error.error1.pngerror2.png

Sandra_Rossi
Active Contributor
0 Kudos

@WandersoWcs Apply the procedure.

WandersoWcs
Discoverer
0 Kudos

Thank´s @Sandra_Rossi