Skip to Content
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.do (list.htm) and controller details.do (details.htm) displays the details of selected customer.

Controller Design Highlevel

image

Account List

image

Account Details

image

Main.do (main.htm) is the parent controller which has List.do and details.do as it’s children. When a record in the list got selected, the details.do 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. Main.do ZCL_MYAPPL_MAIN List.do ZCL_MYAPPL_LIST Detail.do 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 details.do controller, there is no direct way of accessing the instance of this controller from List.do but through the parent controller main.do

1. Create an attribute CUSTOMERID in main.do
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 details.do, 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 details.do can be set during the row select event in the list by referencing the parent’s subcontrollers with component id of details.do

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

Method 3. (Pull Method).

This is implemented in DO_INIT_ATTRIBUTES of details.do

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 details.do from another application’s (say , Contact. Do) controller, this approach generates a runtime error as the parent is not main.do 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.

To report this post you need to login first.

1 Comment

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

  1. gaurav anand
    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 .

    Thanks.

    (0) 

Leave a Reply