Skip to Content
Author's profile photo Lars Hvam

abapOpenChecks – Open source checks SAP Code Inspector / ATC

Over the last 6 months I’ve been working on a set of custom checks for code inspector, the project is available on github.

Currently it contains the following general purpose checks, some complex and some simple.

CHECK_01 – IF in IF

CHECK_02 – EXIT outside of loop

CHECK_03 – TRY without CATCH

CHECK_04 – Line length

CHECK_05 – 7 bit ASCII

CHECK_06 – Check for use of pretty printer

CHECK_07 – Functional writing style for CALL METHOD

CHECK_08 – Obsolete statement

CHECK_09 – Tab instead of spaces

CHECK_10 – Use icon_ constants

CHECK_11 – Max one statement per line

CHECK_12 – Specify SORT order

CHECK_13 – Sequential blank lines

CHECK_14 – Commented code

CHECK_17 – Definitions in top of routine

CHECK_18 – Empty branch

CHECK_19 – Use LINE OF

CHECK_20 – Bad indentation

CHECK_21 – Unused FORM parameter

CHECK_22 – Conditions contain identical code

CHECK_23 – CHECK outside of loop

CHECK_24 – Identical code blocks

CHECK_25 – Selection screen data not referenced statically

CHECK_26 – No direct changes to standard tables

You can configure code inspector or ATC to use these checks in your default variant.

/wp-content/uploads/2015/03/checks_660066.png

The checks are provided “AS IS”, some might not fit your development requirement, and some might be slow or not even work.

This is a box of chocolates; take the ones you like 🙂 . Some of the checks contains settings so it is possible to change to fit your requirements.

Feel free to submit pull requests or open issues. More checks will be added over time.

https://github.com/larshp/abapOpenChecks

Assigned tags

      27 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sergio Ferrari
      Sergio Ferrari

      Thanks for sharing Lars. I'll try as soon as a new inspection project will come.

      This is a great example of the value of our SCN.

      Author's profile photo Peter Inotai
      Peter Inotai

      Hi Lars,

      Thanks a lot for sharing these checks.

      I believe in SAP BASIS 7.02 CHECK_02 (EXIT outside of loop) and CHECK_23 (CHECK outside of loop) are part of the standard checks:

      Anyway in lower releases it might not be there, so it makes sense to implement there.

      Peter

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      Thanks, I've added your information in the Wiki page for CHECK_23, ZCL_AOC_CHECK_23 · larshp/abapOpenChecks Wiki · GitHub

      I'll delete the code sometime in the future if it turns out its available on most SAP versions.

      Author's profile photo Peter Inotai
      Peter Inotai

      Great, that was fast 🙂

      Peter

      Author's profile photo Peter Inotai
      Peter Inotai

      Found also an example for "EXIT statement outside a loop":

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      These 2 checks are part of "Extended Program Check" -> "Programming Guidelines".

      There are some of the checks in "Programming Guidelines" that I personally don't like, whereas I like the CHECK / EXIT checks. Having these checks in abapOpenChecks allows for enabling and changing the message priority, as changes of message priorities for "Extended Program Check" is not supported(see note 1887255). I'll keep the note on the wiki page for the 2 checks so people can choose the approach they like.

      Author's profile photo Peter Inotai
      Peter Inotai

      You're right. Changing priorities is not supported for "Extended Program Check" (not even in 7.40 system). I didn't notice it before. 🙁

      Peter

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      One note on message priorities for abapOpenChecks, the "Management of" -> "Message Priorities" is not supported. Instead its possible to define the message priority in the check variant, this allows users to have different variants with different message priorities for the same check.

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      Setting message priorities for extended check is now possible via ZCL_AOC_CHECK_31 · larshp/abapOpenChecks Wiki · GitHub

      Author's profile photo Florian Henninger
      Florian Henninger

      Nice one. I'll give it a shot in my testsystem and will report if there is something strange to me 😛

      ~Florian

      Author's profile photo Praveer Sen
      Praveer Sen

      nice post Lars, really help full and contains lots of information to reduce extra works after code writing.

      🙂 Happy Learning.

      Praveer.

      Author's profile photo Timo John
      Timo John

      Great Checks! Thanks a lot for providing them!

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      thanks, new checks has been added since the blog post, however there are still a lot of bugs, if you find any bugs feel free to add an issue on github

      see current list of checks at Home · larshp/abapOpenChecks Wiki · GitHub

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      oh, regarding clones, CHECK 24 can help finding identical code blocks within the same object(class/program), it does not compare across objects.

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      update, new feature to compare methods across classes to find cloned methods, see report ZAOC_CLONES

      abapOpenChecks/zaoc_clones.prog.abap at master · larshp/abapOpenChecks · GitHub

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author
      Author's profile photo Florian Henninger
      Florian Henninger

      It seems that there are some checks included, which need an additional product called CVA (SAP NetWeaver Application Server addon for code vulnerability analysis).

      Can you confirm it and if so, can I find a overview, what checks need this?

      Thank you

      ~Florian

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      It is intended to work as a standalone package without dependencies. Though it might use a few standard SAP function modules that are not available on all versions, I will try to rewrite logic if this is the case, minimum ABAP version requirement is 702.

      I don't have access to any systems with CVA, so I'm pretty sure it will work without. Do you get an error when installing/activating it? Please create an issue on github, then I'll try to help you out.

      Author's profile photo Florian Henninger
      Florian Henninger

      Hi Lars,

      thank you for your answer. I'll check on that tomorrow and open an issue.

      My system is a 7.40 SP8, so it should work fine.

      ~Florian

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      By the way, before the following commit, the code had security checks enabled for check 31,

      fix for 730 · larshp/abapOpenChecks@ccee468 · GitHub

      So it might be the reason you had some trouble?

      Author's profile photo Florian Henninger
      Florian Henninger

      I'll update the checks today before starting again. Thank you for this hint.

      ~Florian

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author
      Author's profile photo Kirill Gorin
      Kirill Gorin

      Lars Hvam  Loving this. Just installed and checking out.

      I just recently got a bug in code (not mine) due to not sorting table prior to binary search with a full list of fields. I tried standart check for read but it didn't react. I'd like to make myself a new one, probably by starting on your examples. Any tips where to start on writing your own?

       

      Author's profile photo Lars Hvam
      Lars Hvam
      Blog Post Author

      cool, I suggest start reading through some of the AOC checks plus standard code to get a feeling on how the CI checks work.

      And then just do it, start out with a simple example, ABAP is a crazy language so all scnearios are usually not covered in the initial implementation of a check.

      Author's profile photo Steve Chai
      Steve Chai

      Hi Expert,

      I trying to import the abapOpenChecks-master.zip (which downloaded from (https://github.com/larshp/abapOpenChecks) via offline option. The import was completed fine.

      But, In SCI, goto Management of, Tests, the openABAPcheck option was not there. And, in the check variant also not appear in the list.

       

      Any idea?

      Author's profile photo Ana Isabel García
      Ana Isabel García

      Hi Steve,

       

      I don´t know if you solved. The option is checks. In SCI, goto Management of, Checks.

       

      Best regards.

      Ana

      Author's profile photo Steve Chai
      Steve Chai

      Hi Ana Isabel,

      Yes, we had resolved the issue. Thanks

      Regards,

      Steve Chai