6
Here is the shopping cart application developed in SRM system. Old application was in ITS which was not user friendly…lot of screen navigations. So we developed the BSP application in SRM with only one page with multiple views. Each section on the screen is one view. There are two kinds of approaches in BSP, one is Page with Flow Logic and other is MVC. We have used the MVC (Model View Controller) Model – It is a class where we write the business logic and populate the data so that it is displayed on the Front end. It uses the Data binding concept for populating data. Generally we will create one model class. View – Which is used to display the front end element like tabs, links, tables, text editor…….SAP has provided tags for each of them which are called as BSP tags which is similar to HTML tags. We can have multiple views on single page.

BSP Experience

Embed Size (px)

DESCRIPTION

BSP Experience

Citation preview

Page 1: BSP Experience

Here is the shopping cart application developed in SRM system. Old application was in ITS which was not user friendly…lot of screen navigations. So we developed the BSP application in SRM with only one page with multiple views. Each section on the screen is one view. There are two kinds of approaches in BSP, one is Page with Flow Logic and other is MVC. We have used the MVC (Model View Controller)

Model – It is a class where we write the business logic and populate the data so that it is displayed on the Front end. It uses the Data binding concept for populating data. Generally we will create one model class.

View – Which is used to display the front end element like tabs, links, tables, text editor…….SAP has provided tags for each of them which are called as BSP tags which is similar to HTML tags. We can have multiple views on single page.

Controller – It is a class again……which is used to call the corresponding view. It is interface between the View and Model Class. For example – When the button is clicked on the view then it will go to controller class methods where we write the logic to call the corresponding business logic in the model class.

The important controller class methods are…….

Page 2: BSP Experience

DO_INIT - This method will trigger only one time when the application is called.

Example code – We are creating the instance of the class.

METHOD do_init. DATA: lr_model TYPE REF TO zcl_model.

lr_model ?= get_model( 'm' ).

IF lr_model IS INITIAL. lr_model ?= create_model( model_id = 'm' class_name = 'ZCL_SC_MONITOR_MODEL' ). ENDIF.

ENDMETHOD.

DO_REQUEST - This application will be called for each server input including first time when the application is called – Like PBO in ABAP.

This is used for displaying the corresponding view- like calling screen in ABAP. And also sends the model instance to the View so that it can use the data populated on model access class. And also if we modify the data on the view then it will reflected back in controller class and model class. This is due to data binding.

method DO_REQUEST.data: lr_model TYPE REF TO ZCL_MODEL, lv_main_view TYPE REF TO if_bsp_page. " View for main page.

dispatch_input( ).

IF is_navigation_requested( ) IS NOT INITIAL. RETURN. ENDIF.

lr_model ?= get_model( 'm' ).

* Output the main view lv_main_view = create_view( view_name = 'main.htm' ). lv_main_view->set_attribute( name = 'gr_model' value = lr_model ). call_view( lv_main_view ).

endmethod.

DO_HANDLE_EVENT – For each input – Like PAI.

Example Code in the this method……….here we are handling the button click and calling the method of the Model class to populate some data.

DATA: lr_model TYPE REF TO zcl_model.

Page 3: BSP Experience

IF htmlb_event IS INITIAL AND htmlb_event_ex IS INITIAL. RETURN. ENDIF.

* Get the instance of the model access class. lr_model ?= get_model( 'm' ). IF lr_model IS INITIAL. RETURN. ENDIF.

* Buttton IF htmlb_event IS NOT INITIAL AND htmlb_event->if_htmlb_data~event_name = 'button' AND htmlb_event->if_htmlb_data~event_type = 'click'. DATA lr_button_event TYPE REF TO cl_htmlb_event_button. lr_button_event ?= htmlb_event. CASE lr_button_event->if_htmlb_data~event_server_name. WHEN 'getItems'. lr_model->gv_screen = lr_model->gc_det. lr_model->GET_DETAILS( ).

ENDCASE. ENDIF.

We are having other methods also……like get_model…set_model…do_handle_data ………………………..

Page 4: BSP Experience

Overall Design –

Main View – Which divided the view/page into multiple sections….and each section is a view.

When we activate BSP application it generates the URL which can be given on internet explorer.

We can do client side validation using Javascripts ………. We can develop our own BSP tags