Personal Insights
My sort of fun activitiy: Exercism for ABAP
The blog post about Abap on Exercism published by Lars Hvam couldn’t have come at a better time for me as I had a week off from work shortly afterwards! This gave me ample time to explore this new and rather intriguing offering which the team introduced in a YouTube livestream on April 1. If – like me – you’ve never heard of Exercism before, watching the 1 hour video is time well-spent to get an idea of what it is and how it works – not to mention the amount of work put into it to make it available by (at least) Lars, DJ Adams, Mike Pokraka, Marc Bernard, Marian Zeis, Thomas Jung and Rich Heilman.
After reading Lars’ blog post and watching the live-stream, I quickly created an account on Exercism and started to familiarize myself with the platform and how it works. As of right now, there are 24 ABAP exercises available, most of which are categorized as “easy”.
For each of these exercises, you’ll get a description of what should be programmed and you can then get started right away in the browser to tackle one of them in the built-in editor (or install Exercism locally). You don’t have to start from scratch but instead get the bare-bones class definition and methods as a starting point.
Instead of executing the class, you run the provided test cases to find out if your code works. You can do this even before adding some code yourself to get a better idea of what is expected. Not too surprisingly, most tests will then fail but some might already work, perhaps simply because they expect “0” or “space” as a result. For each of the failed tests, you’ll see the expected and the actual result which work as pointer of what you might need to tweak.
Once your code passes all the tests, you can publish your solution for others to take a look at and you also get access to the community solutions already out there which you can compare with your own solution. If you don’t quite get why something for example works and something else you tried didn’t work as expected, you can also request mentoring to initiate a discussion about your solution with one of the volunteer mentors.
My take-aways
It can be surprisingly tricky to get the syntax right for the needed (and often even rather simple) ABAP statements without code-completion or syntax checks readily available in the GUI or ADT. This made me realize just how spoiled we are when working within an SAP-system on ABAP code as I had to refer to the ABAP online documentation more than once to get the syntax right because I didn’t have a system readily available when I first tackled some of the exercises.
Not yet being well-versed with the (actually not so) new ABAP syntax available since NW 7.40, I often came up with a solution which passed all the tests but was much more involved than it needed to be with the “new” syntax. This is where the community solutions can provide quite a neat learning experience by comparing my own to others’ solutions and trying out some of the other options in a 2nd or 3rd iteration.
Something else I like about the exercises are the test cases provided for each of them. These provide simple to follow and understand examples of how to go about coding a local test class, something which I’m sure will come in handy later when an opportunity presents itself to make use of test cases myself.
I did run into some issues I couldn’t really make heads or tails of where I was wondering what I was missing and/or getting wrong (always a distinct possibility!). Following Lars’ suggestion in response to my comment on his blog post, I started to create issues in the related Github repository whenever I hit a roadblock (and was fairly certain that it wasn’t a “PEBKAC“!) and these were then tackled very quickly by him and Mike Pokraka.
Up to now, I’ve worked through 8 exercises and hope to tackle more as time allows.
And, as hard to believe as it is, there is no actual SAP/ABAP system behind all of this and I don’t even dare imagine how many hours the team spent to create these ABAP exercises with something called “abaplint” and “transpiler” in the background.
Big Thanks to everybody involved for making this available!
thanks for trying it out, and the blog post
still lots of things that can be improved, but it has to start somewhere 🙂
Good blog and thanks for the kind words. I agree with the missing syntax help, it's how I feel when having to switch from Eclipse to the SapGUI editor 🙂
Jokes aside though, this is the case in all tracks, there's no syntax help for JavaScript or C++ either.
The web editor is really for the more basic exercises or for tweaking your solution. The 'work locally' feature works well for most languages that can be run from the command line. If anyone wants to use that for ABAP, I recommend using Visual Studio Code with the abaplint plugin.
But the best solution is to do the exercise in a developer/trial system. Marc is working on making the Exercism repo directly downloadable via abapGit, but this has some technical challenges due to the way abapGit and Exercism structure their content differently. In the meantime I have created a repository exercism-abap-local as an abapGit-friendly copy that will download all exercises with their test classes into a single package. Then you can code and run the tests, and when they all pass paste the solution into the website.
Thanks for the abapGit repo. There seems to be an issue with test includes of some classes. Not sure what the problem is. Opened an issue here https://github.com/abapGit/abapGit/issues/5454.
Interesting, the reason is that I created the repo classes by hand and not via abapGit and was not aware of the
with_unit_tests
class flag. Updated in the abap-local repo, should all pull fine now.Mike Pokraka
Hi Mike,
I'm trying to get your repository (thanks for creating it!) into a sandbox system but get a dump when using the latest ABAPGit program via the ZIP-file route.
In ABAPGit I chose "Import" where I can select a ZIP-file:
The dump happens deep inside ABAPGit:
I grabbed the latest version of ABAPGit before trying: * abapmerge 0.14.3 - 2022-04-11T14:35:10.954Z
This version of ABAPGit should work within a NW 7.50 system, I guess? As always, there's a chance that I'm doing something wrong!
Anything I can do to get this to work? I get the same error when I try with the "official" ABAP Exercism repository.
Cheers
Bärbel
Hi Bärbel,
you did an 'Import' on the marked repository AbapLogger (dark grey) in the repository list. These functions are shortcuts for the selected existing repo.
Instead you have to use 'New Offline' to create a new repository and then inside that repo 'Import Zip' and 'Pull Zip'.
BR
Christian
Thanks, Christian! I had an inkling that I might be doing this wrong! I'll give it another try tomorrow when I have access to the system again.
Cheers
Bärbel
Update: I was now able to import the code into a sandbox system via the ZIP-file.