PHP ABAP console v.2
What is it?
In case you’ve missed the previous post, this little piece of code that I did is a web interace for you to type in some ABAP code and watch it execute. I did it with the idea that it could be useful for learning ABAP of just quickly trying out little code snippets.
How it’s done?
In the previous version I’ve created an RFC function that takes an internal table containing ABAP code, executes it as a report and returns the screen result. Thanks to Blag, who pointed out in his comment that such an RFC already exists, I deprecated mine and used RFC_ABAP_INSTALL_AND_RUN instead. It’s definitelly better, because it does auth checks on the user executing it, also a syntax check on the ABAP code passed to it and finally it cleans up the temp report created to execute the code.
The only problem with this RFC is that when it does the syntax check, it returns only a cut-off error message (50 chars) and no details on the line of code that contained an error and the string (word) that causes the error. So I went ahead and created a very simple RFC that only calls SYNTAX-CHECK FOR statement and returns everything this statement gives – full text of the error message, line of code and word. So now the way the console works is:
- Call RFC_ABAP_INSTALL_AND_RUN.
- If there is an error message, call ZSTOYAN_RFC_SYNTAX_CHECK to get the full details of the syntax error, then highlight the error.
Screenshots and code download
Here are two screenshot, one with code executed OK and one with code with a syntax error.
The code is here (the custom RFC’s source can be found in the _extras/ folder).
If you want to try the console out, you need to create the ZSTOYAN_RFC_SYNTAX_CHECK function module and then to edit /model/business.php changing the credentials to access your SAP system.
Thanks for reading, any comments are appreciated. And thanks again to Blag, please give this guy all SDN points he deserves 🙂