Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
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!

Installation

         
  1. Unzip the package into your web folder (httpd), so that it's for example in http://localhost/abap_console
  2.      
  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.
  4.      
  5. Open the script model/business.php and edit the SAP connection information - username, password, etc.
  6.      
  7. Point your browser to the little app, ex. http://localhost/abap_console
  8.      
  9. Code away

Todos

         
  • 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.
4 Comments