BSP Application using MVC Architecture - Displaying Business Partner data using a BAPI


Enter the name of the controller class that you want to create as shown in the above screen.   

Double click on the controller class to enter into it. Give the attributes of the class as shown. 


_ Redefining The Controller Class Methods

to use our model and views in controller class, we have to redefine some of the methods inherited from base class cl_bsp_controller2 using the class builder’s redefine function.

The redefinition steps automatically add commented coding (shown in bold in the do_init example below:

method do_init .
* call method super->do_init.
* .

If you uncomment those lines, you would execute the method implementation of the parent class. this is helpful when you want to carry out the parent logic and some additional custom logic. we don’t want to reuse functionality of the parent class in the example, however, so be sure to delete the commented code before adding the new code.  

Redefine the methods i.e. do_init, do_request, do_handle_event.   

After that double click on the method do_init to implement it (write the code in the method). 


method DO_INIT.
   BUPAOBJ ?= me->create_model(
                             class_name = 'ZBUPA_MODEL'
                             model_id = 'BUPAOBJ' ).
Follows the same procedure for the ‘do_request’, ‘do_handle_event’.  


method DO_REQUEST.
*    .
* Define a variable for the view we are about to create
 data view type ref to if_bsp_page.
* Dispatch the input so that the event handler can process
* events like when the agent clicks on the Search button
 me->dispatch_input( ).
* The attribute me->view_name can be set by the event handler
* to change navigation to the flights display
 if me->view_name is initial.
 me->view_name = 'input.htm'.
* Create the response view
 view = me->create_view( view_name = me->view_name ).
 if view is bound.
* Add a reference to the model instance to the view,
* so that the view can access the model
 view->set_attribute( name = 'BUPAOBJ' value = me->BUPAOBJ ).
 me->call_view( view ).




* Check that the event has been triggered by the search button
if htmlb_event is bound and
htmlb_event->server_event = 'myclick1'.
* Execute the search implemented in the query model
* Flights have been found, new target is the hit list display
if not me->BUPAOBJ->SEARCHRESULT[] is initial.
 me->view_name = 'output.htm'.
 elseif not me->BUPAOBJ->RETURN[] is initial.
   me->view_name = 'output.htm'.

Save, check and activate the application. 

Testing the application. 


Input the user name and password for the authentication and click on ‘ok’ button. 

The View is displayed in the browser window as shown below.


Provide the information to get business partner data. 

Click on the GET DATA button. 

Then business partner information gets displayed as follows 


Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image