Skip to Content

BSP Programming: Writing a Pattern Engine

Employee Self Services (ESS) is one of the hottest new developments in the intranet. Most companies attempt to streamline processes, and have employees complete simple administrative processes directly themselves. Typical examples are booking holidays, address changes, or ordering office utilities. These processes are all targeted at occasional use, and must be simple to use. The typical approach is to use a fixed pattern, which all ESS applications follow, so that the casual user will be able to complete the process relatively easily.    For this weblog, we would like to write an ESS application for holiday (vacation) booking. First, we will write a pattern engine that does all of the generic work and handles the overall layout. Thereafter, we will write our small ESS application.     Product remark: The work presented here does not come from any SAP product. The words ESS and pattern engine are used here in a generic way, and do not reflect any product development work that I am aware of. For this weblog, my favorite search engine was used to obtain one or two screen shots of a typical ESS application from a website in the Internet.    For all our ESS applications, we would like to have the same layout. At the top should be the title. A roadmap will be used to give an overview of all the steps to be followed, plus the current active step. Navigation buttons must be at the bottom of the page. All ESS processes will have at a minimum: an introduction page to explain how to complete the process, the actual work pages, a save page giving a summary of the entered data, plus a final confirmation page.       After the weblog that showed how to write composite elements  (BSP Programming: Writing Composite Elements), the first idea was to use a composite element to handle the complete layout, wrapped around the body of the ESS application. However, BSP elements are excellent at handling rendering, but not good for complex logic.In this case, we would have required additional data structures to hold configuration information and extra classes to handle events.     It was then that the plan for using a BSP controller as a pattern engine was hatched. Using a controller has many benefits. The code for the controller is placed in a separate class. Adding the controller into a BSP application is just one data entry. The same controller can be used many times within one BSP application. As a controller is effectively a normal ABAP class, it is possible to place all the type declarations, data and event handling into this class. Furthermore, it is possible to use the same techniques that are used in composite elements, also in controllers. Thus, the controller can contain rendering code, and is quite capable of processing BSP elements.    For our design, we have one controller that will be the pattern engine. The pattern engine is responsible for handling the complete layout, deciding what the current active step is, and displaying it. In addition, the pattern engine will offer a number of events (mapped onto method calls) to help the ESS application, for example: next, previous, confirmed and finished.      The ESS application will consist of a controller that inherits from the pattern engine, a model class, and all the views that are required for rendering each step. Because the ESS application inherits from the pattern engine, it is very easy to complete the configuration data about the pattern and to overwrite any events of interest. Furthermore, the ESS application will contain all the business logic.    The use of a model class is optional. For the ESS application it is used, as the model binding makes it easier to have the data from the incoming request placed automatically back in the model. The model class also handles the conversion between internal and external representation. A typical example is the conversion of a date from ‘YYYYMMDD’ into my preferred version ‘YYYY-MM-DD’ and to ‘MM/DD/YYYY’ for our stateside colleagues.    For each step in the ESS application, one view is written. The view itself will only contain the BSP elements that represent that actual ESS application. Everything else will be done by the pattern engine.  h3. The Final ESS Application   Before looking at the actual code, let us first look at what we want to achieve. This will make the actual code much easier to understand.    Our small ESS application will have five steps. The first is an introduction page, which explains the complete process quickly. The second step will give an overview of the holidays that have been taken this year, and list the available holidays.         The next step will be to enter the data for the next holiday! After the data has been verified as correct, it will be presented in read-only mode in step four, with a confirm button. Up to this step, it’s always possible to navigate back to the previous steps, or to cancel the process.      In the last step, a final confirmation shows that the holiday has been booked. Now the only navigation option is to press the finish button. For typical ESS applications, this exit URL will be configured to return to a small “portal” that contained all the different ESS applications.  h3. Writing the ESS Application   Before looking at the more complex pattern engine, let’s first look at the work required to develop the ESS application. We create a new BSP application that has one controller and five views.  
You must be Logged on to comment or reply to a post.
  • Brian

    While learning BSP, there is a lot of ABAP code in it. While I can read it and make some sense of it. Could you please provide some pointers to nice concise introduction of ABAP and then may be a complete reference.


  • Hi Brian,

    thanks for this great WebLog. As I am currently developing some sort of big application within BSP your approach definitly helped me much.

    After trying your example I am now in the process of customizing it to fit into my app and adding more functonality to your Pattern Engine…


  • Hi Brian,
    Your Blog is really good. My best compliments.
    Just a question. Perhaps you could give me an answer.
    Why didn’t SAP developed a HTMLB inputfield with a Matchcode like a normal ABAP input Field?.
    I’ve developed one and it works pretty well specifing in its layout properties the corresponding SAP data element. This is a feature that every customer ask and is something that really I miss in the SAP’s BSP Extension.
    • Hallo Fabio,<br/><br/>You ask why the <htmlb:inputField> does not support natively F4 help. There is no real technical reason. In summary, one can probably say it has a lot to do with hysterical reasons (not historical:). At the time we did the work, we were under pressure to complete the library for a very large project in-house. A quick agreement was reached: we supply the hooks and they do their own help. We never got round to doing this again. For my next weblog, I am planning an example an example of how to do this. There are already some good bits and pieces in the BSP forum.<br/><br/>However, why wait on me. SDN is about community: about give and take. Maybe a small group feels like building and making it available via the download area. Especially when people write, “After trying your example I am now in the process of customizing it to fit into my app and adding more functionality…”, I think we are getting close to making that final jump in getting community developed building blocks available. The expertise is already available. You can consider polling the BSP forum to pull a group together if you wish (a cheer-leader is always required).<br/><br/>regards, brian<br/>

      • I have a solution for F4 help that I have been working on for a while as well.  I was planning on having a weblog for it in the next few weeks.  However since there is interest, I might be able to move it up to sometime this week.  It might have some ideas that can get things started. 
  • Hi Brian.

    We use, on 4.7 version, the “old style” ESS, not the new one.

    Question: is it possible to write BSP application for this old version ? If yes, how to integrate our BSP application in the ESS ?



    • Pierre,
      No idea. As far as I know old style ESS is ITS applications. Would not know how an integration would is done. But in principle, there is nothing that prevents you from writing BSP against same data and just using it. Why not discuss question in BSP forum.