Skip to Content

Caffeine in Action

In my [previous blog post | Caffeine – ABAP to Go – The Motivation] I described the motivation and scope of the Caffeine project. This time I will get into a little more detail and explain some inner workings at concrete examples. As mentioned in the previous blog post, Caffeine is about implementing libraries in ABAP that can then be executed on multiple platforms. Since we are talking about libraries only and are expecting the actual application to be written in the native language on the target platform, the integration and usability of the generated libraries are very important factors to the success of the approach.* * I’d like to point out that Caffeine is currently a prototype project “fresh from the labs” and is not related to any current or future SAP product.   h2. The Language   Caffeine supports a subset of ABAP, but also added some extensions that come in handy for the new tasks it handles. I’d like to point out that the definition of the subset is still evolving and that I intentionally started with a rather small subset, which can be extended in case important use cases would require it. ABAP OO, for instance, is not part of it.    One of the few new keywords introduced in “Caffeine ABAP” is the “service”. In the Caffeine world, everything is a service. In ABAP terms, a service is pretty much the same thing like a “function module”, but we decided to give it a different name to point out that it is not 100% the same. The remaining “ABAP subset” is corresponding 100% to the exact ABAP semantics as the section “Runtime” will elaborate on further down in this text.    The currently supported ABAP subset goes back to ABAP’s roots and is based on functional programming paradigm and internal tables. This seems appropriate for the current focus of client side validation and business logic as well as for backend adaptation logic. The idea is to use ABAP as it was designed initially: A “business DSL” to read, manipulate and compose table oriented data.    Let’s explain some aspects of the language at the example of some simple code snipplets. I assume the average reader of this blog to be somewhat ABAP savvy and will thus not explain the ABAP code semantics in detail but will focus on the additions.  imageA service is defined using the “define service” keywords and follows the well-known ABAP syntax for method definitions. A service can have any number of importing and exporting parameters but does not know the concept of “changing” parameters. There is also a possibility to call services of course:imageAs you can see, calling a service works the EXACT same way as calling methods or functions in ABAP. Only the keyword is different.    The following code snipplet is obviously not the most effective way of implementing the factorial operation, but is supposed to demonstrate some simple internal table operations at work:   image    These are only a few example code snipplets; Caffeine supports more than the ABAP keywords you have seen so far. If you are curious about the details or just want to get your hands on and try it out, then you can download and test it yourself. You will find the instructions and a link further down in this text.   h2. The Type System   Caffeine currently supports a small set of primitive ABAP data types such as i (64 bit integer), f (double precision float),  string and date. It also supports structure definitions ( “types:”) and internal tables which can each contain nested structures and tables. The question of the type system as a whole is not yet fully answered by Caffeine. ABAP invented the Data Dictionary for persistent and reusable type definitions and currently Caffeine does not provide such a concept. Instead, it reuses and maps existing backend type systems to local internal tables and structures. It thus creates a common type system in which a developer can use, combine and modify data from different sources in a uniform way. I implemented a demo integration using this approach for the last TechEd in Las Vegas using the River platform as backend. The following example demonstrates the implications on the syntax:   image
You must be Logged on to comment or reply to a post.
  • Hi Daniel,
    Thanks for this blog and for this downloadable version. I've managed to install it, but I need some time to get familiar with it...everything looks a little bit strange after SE80 😉
    Best regards,
    • Hi Peter,

      admitted, the usability is probably more intuitive to Java/Eclipse developers than SE80 users. Try the "getting started" docs, I explained everything click by click so it should be easy even to "Eclipse newbies".

      Happy hacking! 🙂


      • Hi Daniel,
        Indeed the getting started doc is very useful.
        I found the included scr/*.abap files also quite helpful.
        I have to admit I'm so much addicted to the SAPGUI/SE80, that I created my first file in the Z* namespace :)))
  • Hi,

    I would propose to find a better name for your project. "Caffeine" can be easily mixed with "Kaffeine" which denotes a quite famous KDE media player in the Linux world. In opposite to "Caffeine", "Kaffeine" has been around for some years.

    Best regards,

  • Hi Daniel,

    An interesting project, though like others, I wonder why the ABAP developer wouldn't just implement an RFC-enabled function or web service to do any processing suitable for the ABAP language. I wonder if there is an underestimation of the target developer to learn a new development environment if they are unwilling to learn a new language.

    I guess the benefits might become more apparent when we start see how data binding to the SAP-backend might be realised.

    Is there any chance that you'll take the opportunity to deliver some things that ABAP has never had? I'm looking at you missing boolean and datetime fundamental data types...


    • Hi Scott,
      sometimes you can't (missing rights) or don't want to develop on the server side. Think about validation code for instance (waiting for a server roundtrip each time makes your app unnecessarily unresponsive and slow).
      I agree that an SE80 integration would be neat and probably preferred by many hardcore ABAP developers. Due to the big effort of such a project this could not be realized as part of this prototype project, but maybe once this project gets productized we should think about it.

      As a matter of fact I am taking this opportunity to add some missing functionality to ABAP. I am currently working on integrating concurrency and multithreaded programming without bloating the language (I will probably go into more detail in the next blog post). In general I feel that I need to be careful with changing or adding to the language since the whole point is to attract ABAP developers and make them "feel like home" instantly (and I'm not sure whether changing the primitive type system crosses a line although I agree that boolean is hurtfully missing).