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: 
MarcelloUrbani
Active Contributor
A few months ago GitHub released Copilot, an AI to help you write code by guessing what you will type next. It’s ‘powered by’ OpenAI and was trained on public GitHub repositories.

At the moment it only works in Visual Studio Code but it’s pretty effective for mainstream languages like JavaScript, where all I need to do is write a function’s name and press tab twice to include code written by the AI system.

For example, the light gray text here is code proposed by Copilot (generated automatically as I type):


If I press tab it’s inserted. Then Copilot suggests how the function should look:


Which means when I hit tab a second time I get a working factorial function in two keystrokes.

Of course this really works with popular function names like GetUserAddress or ConnectToPostgress, not a or supercalifragilisticexpialidocize.

What about ABAP?


Well, copilot is completely language-agnostic, so it works for that too as long as you edit with visual studio code, either using my extension to edit code on your server as I'm doing here, or edit files on your laptop (perhaps to transpile to js or sync with your server using abapgit)

But like most AI it gets more accurate when it has more data to train on.  I understand JavaScript has several hundreds of thousands of projects on GitHub; ABAP has only a few hundred (209 that I know of, and I guess maybe a few dozen others). The end result is that ABAP suggestions offered by Copilot are generally much worse than for, say, JavaScript.

the good news


Still manages the factorial pretty well:


…except for the all-important missing spaces (added here by me):


I’d find it more useful for your typical ABAP boilerplate, though. For example:


Mmmh, not really. Let's see with a little help:


I like seeing all the strings and values here but it’s not valid ABAP, and I have no idea where system_status comes from. Also with 17 exceptions I’d rather have a case statement.

Let’s try this bit again. I had to write all the code up to the first ‘when’, but now it’s starting to work:


Valid, sensible ABAP and reasonable text. But why stopping at 2 out of 17???


On the plus side,if I change the code in the first 2 cases it does get reflected in the proposal:




the bad ones


With less regular code Copilot really struggles.


Ok for guessing the variable name, but then wants to call gui_upload for every loop iteration...


 

...and concatenation doesn't work like this




Some Encouragement...


As the training data for ABAP is really scant, what the system learns from the current code gets  more important. Editing a big file with several loops already gets you more sensible results. It suggested this to me, for example:



Conclusions


On top of the dummy code using for this article, I've been using copilot for a while in several languages, mostly ABAP and typescript but also CDS, haskell and F#

It usually provides a good scaffold for what I want - often good enough to be left alone for the most tedious boilerplate. ABAP performance is by the far the worst of the languages I’ve tried, but even there I still find it useful at times. Definitely something to keep an eye on