Skip to Content

BSP: Data Exchange between (Sub)Controllers – Part I

It has been a while since I wrote a weblog due to lack of time. I planned to write couple of them during my free time but I never got to that free time at all till now, flying 36,000 feet above Alps Mountains. Yes, I am on my trip to India on vacation, relaxed and thinking about the challenges faced in the past months on our project. I thought I should share some of my experiences with my fellow SDN members and started writing this web log.

Let us design a Customer BSP application at high level(from 36,000 feet) as shown in the picture below, which has three controllers and corresponding views. Customer list is handled by controller (list.htm) and controller (details.htm) displays the details of selected customer.

Controller Design Highlevel


Account List


Account Details

image (main.htm) is the parent controller which has and as it’s children. When a record in the list got selected, the controller should get the selected record and fetch the details for display on the page. I am sure there are many ways to exchange information between two subcontrollers, I would like to mention the two methods I have used their advantages and disadvantages.

While developing complex BSP applications that are built with many discrete components (controllers) designed for greater flexibility and reuse, exchanging parameters between controllers becomes crucial and complex. I have seen many asking questions in SDN forums about exchanging data between the controllers. ZCL_MYAPPL_MAIN ZCL_MYAPPL_LIST ZCCL_MYAPPL_DETAIL
Method 1.
Assume that Customer id is the key to get customer details, which is available as part of the row in the list.
When a record is selected, the selection event of the table control is used to capture the selected record and corresponding customer id. Now, this customer id need to be passed to the controller, there is no direct way of accessing the instance of this controller from but through the parent controller

1. Create an attribute CUSTOMERID in
2. In DO_HANDLE_EVENT of LIST.Do capture the row selected event and set the parent controllers attribute CUSTOMERID with customer id of selected row.

3. In DO_INIT_ATTRIBUTES of, get the customer id from parent controller that was set by the list selection event.

Get the customer details based on me->customerid to display in the page. Make sure to clear the parent attribute as soon as you fetched it in detail.

Method 2. (Push Method)

In this method the customerid attribute in can be set during the row select event in the list by referencing the parent’s subcontrollers with component id of

There is an issue with this method, when the application is started for the first time, only list is displayed and the is not displayed as there is no detail to be displayed(unless it is coded to display blank details page below the list), is not registered as the subcontroller of main and the row selection event will not be able to set the customerid in

Method 3. (Pull Method).

This is implemented in DO_INIT_ATTRIBUTES of

All these above methods can be used to exchange data between parent and subcontrollers, but it is not the best approach as the implementation classes are referred (hard coded) , which is against the basics of Object Oriented Design Patterns .

If I were to call the from another application’s (say , Contact. Do) controller, this approach generates a runtime error as the parent is not which was hard coded in the above three methods (lo_main type ref to ZCL_MYAPPL_MAIN).

Part II of this weblog uses Object Oriented Design patterns that gives more flexiblity.

1 Comment
You must be Logged on to comment or reply to a post.
  • This article regarding exchanging parameters between controllers was very good . And that too it has been explained how to achieve the same in 3 diffener ways.
    I would appreciate a lot if you could give some insite of using Interfaces to achieve the same .