TL;DR: ChatGPT has huge potential as an SAP development and learning tool. Unfortunately, the language model database is not yet sufficient to be of use to ABAP developers. However, it is very likely that this will be improved in the near future.
After the launch of the public beta of the ChatGPT chatbot in November 2022, the news spread that this AI was not only convincing and competent as an assistant, but could also write meaningful working code in several programming languages. Some people have gone so far as to say that this AI marks the beginning of the end of programming as we know it today.
As an ABAP beginner, I considered ChatGPT as a learning assistant. By simplifying the search for SAP-specific questions and providing meaningful examples, it might be able to help me on my learning journey. To find out if this was possible, I asked the bot about its APAP programming capabilities. The ChatGPT release I used was dated 9 January 2023.
That was a humble answer. Now I wanted to put its ability to the test.
As is tradition, I began with a “Hello World” program, or in this case, “Hello Person”.
This looked promising. The AI gave the code and then explained how it worked and how to use it on an SAP system. The syntax highlighting is spotty, but this would not be a problem after copying the code into a real ABAP editor. It even paid attention to naming conventions such as all keywords being capitalised, prefixes for variable names and the z-namespace.
A sharp-eyed ABAP programmer might notice that this code has invalid syntax. The “TO OUTPUT” statement makes no sense at this point and will produce a syntax error. I went ahead and told the AI the error message given by the editor.
The AI was very polite and corrected its mistake. Now it was a working ABAP report.
First Programming Steps: Fibonacci
The first exercise was very simple, but the AI still had a rough start with the syntax. I then asked it to calculate the Fibonacci series to see how competent it is with more sophisticated problems.
Again, the chatbot seems to have an idea of how the program should work, but could not produce a report with valid syntax. The loop statement is incorrect. After this was pointed out, the AI tried to replace it with a do statement, which also has the wrong syntax.
Even after telling the AI multiple times where the syntax error was, it was unable to create a working program. This was very disappointing. Also, the naming convention for variables is missing here.
(Before writing this blog, I tried this exercise on an older version of ChatGPT from 15 December and it was able to generate a working report. The ABAP programming capabilities seem to fluctuate from version to version instead of improving each time.)
Knowledge Test: HCM and Infotypes
Human Capital Management (HCM) is a major cornerstone of SAP and ABAP. As a beginner, it can be difficult to understand all the things you need to know to manage administrative tasks, for example. I wanted to see if ChatGPT knows about infotypes and the corresponding structures and tables:
The AI seemed confident in its answer, but infotype 0001 is not for storing personal data, but for organisational assignment. Nevertheless, it is possible to get the name from it.
The AI continued to give incorrect answers with confidence. This is not helpful and would confuse beginners rather than educate or inform them.
I tried other HCM related questions but most answers were flawed with many wrong facts.
More modern Paradigms: Object Orientation and ADT
After the AI struggled with the last task, I was not sure if it can cope with some of the newer features of ABAP, but I wanted to see if it knows how to write ADT-specific, object-oriented code.
Unfortunately, this code does not solve the problem. The bot wrote that this class should be instantiated and the run method should be called in a report. The AI seems to know how a class is structured in ABAP, but lacks knowledge of ADT, its functions, classes and interfaces. I tried to specify the task more precisely:
It tried to make the changes I requested, but at the same time introduced new mistakes. It also insisted that the main method had to be called from a report in order to use this class. At this point, it would have made more sense to just write the code myself, so I moved on to something else.
The AI seems to still need some improvement in its programming capabilities,but I thought it might be able to help a beginner to understand the code he or she might be confronted with. To test this, I wrote a simple report that uses a circle class to calculate the area and circumference for a given radius.
The AI misunderstood my request and just explained the given code snippet. The explanations are good, so I asked it to add them as comments within the code. This resulted in the AI copying the full texts as comments, but I expected them to be more compact and readable:
The result was the typical redundant comments that a senior developer would probably frown upon, but which might be helpful to a novice faced with a new language element. I think this is a valid use for the chatbot.
Creating practice Excercises
Sometimes I get tired of the sample exercises from the SAP Learning Journeys and try to come up with more interesting tasks to try to get a better understanding of ABAP and SAP systems. This can be difficult when you don’t really know how it all works and it consists of trial and error exercise definitions. Sometimes this can get a bit frustrating, so I thought maybe the chatbot could give me some interesting exercises.
This all makes sense, but there are no concrete tasks.
The MARA table is not maintained on every system and the ALV function module is, to my knowledge, out of date, but for a complete beginner this could be a useful exercise. After completing the task, a sample solution would be helpful.
As expected, the AI was unable to generate working ABAP code. The function call is wrong and will result in a runtime error. I think we should just let ChatGPT create the task description and evaluate the solutions ourselves.
Virtual ABAP Runtime
I was surprised by ChatGPT’s ability to pretend to be a Linux command line (https://www.engraved.blog/building-a-virtual-machine-inside/). Not all ABAP beginners have a working ABAP environment to play and test with. Perhaps this could be an alternative to a trial cloud environment. I have tried to create a virtual ABAP environment based on the Linux terminal example.
This was a very disappointing answer, but I have heard that you can trick the bot into answering you by hiding your request in a what-if question.
This seemed to work, so I tried a more complex program. I used a modified version of the sample report from a future blog post on this website, which is a work in progress (link to the post here when available), to calculate the prime factors of a given number:
It worked, but the output was wrong (the correct numbers are 3,3,7,13,23,41,61). The chatbot warned about its inability to run ABAP code, so this was no surprise. A virtual ABAP environment in ChatGPT seems to be impossible for now.
As it turns out, ChatGPT is not yet the almighty tool that will disrupt the programming industry, at least in the ABAP space. Its capabilities in other programming languages do not translate to ABAP, probably because the reach of ABAP on the Internet is not even close to that of more popular languages. However, this does not mean that it can never achieve this goal. The potential for language models to take care of mundane and repetitive programming tasks can be seen. Sooner rather than later, a new language model specifically trained for this purpose will emerge. Then programmers will need to shift their attention from repetitive coding to more conceptual or design work.
For ABAP beginners like me, the assumption that ChatGPT could be a valuable help in its current state seems far-fetched. The chatbot can give example exercises and comment code, but it is tedious to get it to do this correctly. I still believe that the chatbot will get better at this in the future and change the way we learn programming. Until then, we ABAP beginners should stick to our books, learning journeys and asking seniors for a meaningful learning experience.
Image was synthesized by the AI Stable Diffusion