Skip to Content

How to build a SE16 Emulator in Blue Ruby

Following the example set by famous SDN Mentor Blag, I decided to demonstrate some of the capabilities of Blue Ruby along Blag’s favourite smoke test for SAP Connectivity: the SE16 Emulator, a tool to display the content of an SAP DDIC table.

Now, Blag has already shown a version that prints the content of a table to STDOUT – check out his blog The specified item was not found.. To demonstrate some more features available in our Blue Ruby environment, I am going to extend his example by adding HTTP access to the table content and some basic HTML generation – and all of that in no more than 50 lines of code.

So, without further hesitation – let’s jump right to the code:



The source code should be easy to understand – but I guess that’s what developers always think about their own code, so here is a short explanation of the pieces we had to put together for this Blue Ruby SE16 Emulator:

Call an ABAP function module to retrieve DDIC table content

As you can see, we are using the Blue Ruby ‘rfc’ library to call function module RFC_READ_TABLE. The function takes the name of a DDIC table and returns the content of the table along with some metadata. The result of the call is not structured, so we will have to split the content of the returned rows at the delimiter character.

Generate the HTML output

We are showing two ways here:

For the input form, we just use a string that contains the HTML. We could also merge Ruby expressions into that string to make it more dynamic.

Remark: A future version of Blue Ruby might also be able to deal with the *.erb files used in Ruby on Rails.

The HTML table that shows the DDIC table content is rendered via the (standard Ruby) library ‘xml_builder’, which allows to generate XML (or in our case HTML) output in a pretty declarative and self-explaining way.

Make the program callable via HTTP

Blue Ruby doesn’t work like the “standard” web servers known in the Ruby community. As we are getting so much for free in the ABAP environment (the web server is always running), it’s even simpler. We just have to follow some naming conventions – we must use the same name for the file and the class we define in the file and we need to define a do_get (or do_post, do_put, …) method that takes the HTTP request and response objects as parameters. Then we just drop that file into a special folder on our file system (the /Handlers folder) and we’re ready to call our SE16 servlet.




Remark: For compatibility reasons, we are also implementing a Rack-compliant alternative – when it’s finished, we can try to run these nifty web frameworks that keep on evolving in the Ruby community.


So what happens when we call our SE16 Emulator from the Web Browser? At first, it prompts us to enter a table name (and kindly suggests the SPFLI table).




We press the “Go” Button, and the browser will display the table content in a nice, yet puristic, HTML table.



Easy, wasn’t it?

If you want to learn more about Blue Ruby, check out the following links:

And if you want to see more SE16 Emulators, follow Blag’s blogs: for “tasting the mix”)

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

    So glad to see that you post this -:) And gotta admit...I didn't knew how to launch the example LOL I knew I needed a browser, but wasn't sure about the web address -;)

    Blue Ruby is such an amazing tool and I can't wait for the Rack Sinatra or Camping on top of Blue Ruby? That would be magical -:D


    • Hi Blag

      Glad you like the example - can't even remember where I found it 😉

      Regarding Sinatra - we got some first Rack examples (the Lobster) working and will play around with Sinatra next week. If everything goes fine, we'll have it in the trial system end of next week. Keep your fingers crossed...

      Once all the trial users are on board, we wanted to offer webcasts for Q&A (like "What is the web address?", "What needs to be done to get library xyz working?", ...). What do you think about that? What would be a good frequency?

      cheers, Juergen

      • Juergen:

        Sinatra! Yeah man I would love that! -:D
        And it's true...must put myself on board soon...Hopefully this weekend -;)

        Eagerly waiting for that Q&A...would be great I'm sure -:D