Skip to Content
Here’s this little project of mine, it’s called “ABAP Console” and is a web interface to type in some code in ABAP and execute it to see what it does. It’s meant to be a way to learn ABAP or just quickly try out little snippets of code.

How does it work

The web interface part is written in PHP, using the open-source SAPRFC extension to be able to connect to an SAP system, where the ABAP code you type will be executed. I’m also using some AJAX calls to execute the code and display results, without reloading the page. There is also a bit of animation, done using Yahoo UI libraries, just to change the color of the result area, signaling to the user, that the code is executed. The overall code/directory structure is built upon this little AXAJ MVC idea, I came up with not so long ago.

In addition to executing the code, it’s also displayed highlighted (different colors for keywords and so on). This part was done by another AJAX call using the PEAR::Text_Highlighter package plus my additions to it – JSON renderer and ABAP language definition.

JSON is used for both server-client data transfters done after the AJAX calls.

The actual execution of the ABAP code is handled by a new ABAP function module I created and RFC-enabled, so that it’s accessible by PHP. This function module creates an ABAP report on the fly, using the code you typed, executes the report and scraps the output of this report. This means you can type in the ABAP console anything you would normally execute in a report. The result you get is whatever you decided to write: /. Since I’m new to ABAP (that’s why I came up with this console idea in the first place), the ABAP part is probably not the best solution to the problem at hand, but hey, it worked.

Installation pre-requisuites

As you can see from the paragraph above, this code scratches quite a few programming itches – PHP+SAPRFC, PEAR, AJAX, YUI, JSON, ABAP, so there are a quite some pre-requisites. To make it easier, I took the liberty of including the YUI and PEAR libs I need, as part of the download. The only thing you need to make sure is that your PHP environment includes the SAPRFC extension. If you’re using Craig Cmehil‘s Scripting In A Box army of tools, you’re good to go.

One important security reminder:
Be careful with my ABAP function module (ZSTOYAN_RFC_EVAL), I mean be careful on which system you install it. Having an RFC module is a security concern in itself, but having an RFC module that executes arbitrary code, passed to it, that’s no different than having a Trojan Horse in your system. So be aware of that and probably just install it locally or on a training system, no production servers!



  1. Unzip the package into your web folder (httpd), so that it’s for example in http://localhost/abap_console

  3. Install ZSTOYAN_RFC_EVAL on the (non-production!) SAP system. This means create a function group and a function module with this name and paste the code you’ll find in _extras/ZSTOYAN_RFC_EVAL.abap. The function module works with two tables – SOURCE and RESULT. Don’t forget to Remote-enable the module.

  5. Open the script model/business.php and edit the SAP connection information – username, password, etc.

  7. Point your browser to the little app, ex. http://localhost/abap_console

  9. Code away



  • Implement user log-in, so that the username/pass are not hardcoded

  • Improve the ABAP part, the RFC module that executes the code

  • Implement syntax check for the typed-in code (I know I saw somewhere that such functions exist in ABAP)

Thanks for reading, any comments are appreciated.

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Former Member
    Nice Stoyan:

    But why create a new function when you can use “RFC_ABAP_INSTALL_AND_RUN”? The code is almost the same…I used it in my blog with no problems The specified item was not found.

    Still, the AJAX and JSON additions are just great! -;) And I had a nice interface.



    1. Former Member Post author
      Thanks Blag!

      Wow, I didn’t know this RFC function existed. Wicked, so I can modify my little app to use this RFC instead. You’re right, the code is very simlar in how a report is created, executed and its result is retrieved. But this function is better than mine as it does some auth checks and also a syntax check on the code you pass. So I’ll have less todos now ๐Ÿ™‚

      You know what I thought would be cool for the console to do – to store (selectively) the source code you execute, once you like the result. This way you can build your own tips/tricks little collection of ABAP examples. Maybe then share it with other ABAPers from th community. So they can tag you code, add to favourites, subscribe to your ABAP RSS feed, display it on their blog… OK, I’m daydreaming now – ๐Ÿ˜€

      1. Former Member
        >You know what I thought would be cool for the >console to do – to store (selectively) the source >code you execute, once you like the result. This >way you can build your own tips/tricks little >collection of ABAP examples. Maybe then share it >with other ABAPers from th community. So they can >tag you code, add to favourites, subscribe to >your ABAP RSS feed, display it on their blog… >OK, I’m daydreaming now – ๐Ÿ˜€

        Actually…I think is a great idea -:D SapLink works great for code sharing…But your idea could work better for ABAP snippets…Please let me know if you get into something -;)



        1. Former Member Post author
          But I guess it’s kind of tough to throw a free-for-all SAP system out there and let anyone execute any code, potentialy deleting anything deletable ๐Ÿ™‚

Leave a Reply