SAPmvc Documentation

Interaction Between SAPmvc Components

Once the model, view and controller objects are instantiated, the following occurs:

The view is registered as a Model's listener. Any changes in model's data result immediately in a broadcast change notification( Optional ), which the view receives.

Note that the model is not aware of the view or the controller, it simply broadcasts change notifications to all views interested listeners or just allows controllers and/or view to access its data.

The controller is bound to the view. This typically means that any user actions that are performed on the view will invoke a registered listener method in the controller class. The controller is given a reference to the underlying model.

Interaction Between SAPmvc Components and User

Once a user interacts with the view, the following actions occur:

The view recognizes the dynpro action ( e.g. pushing a button, request match code or request field help ) in PAI and trigger the appropriate event, thus all event handlers in controller that are listening this event are executed.

The controller access/update the model and call next view if it's necessary. If the model has been modified, it notifies interested views of the change. During the PBO the view trigger the appropriate events and all event handlers in controller that are listening this event are executed. In this moment the controller update the dynpro accessing the data in the model.

SAPmvc Classes

SAPmvc Classes contains all main Attributes, Methods, Events necessary. SAPmvc has four Classes:

ZCX_SAPMVC - This Exception Class is used to handle all SAPmvc errors.

ZSAPMVC_MODEL - It contains atributes, methods and events necessary to use MODEL in SAPmvc.

ZSAPMVC_VIEW - It contains atributes, methods and events necessary to renders the contents of ZSAPMVC_MODEL and trigger the events that ZSAPMVC_CONTROLLER will handle.

ZSAPMVC_CONTROLLER - It contains atributes, methods and events necessary to handle the ZSAPMVC_VIEW events and Control the ZSAPMVC_MODEL instances.

ZSAPMVC_MODEL

It contains atributes, methods and events necessary to use MODEL in SAPmvc. It contain the data and the application rules.

SAPmvc supports nested and compound Models. A compound Model contains one or more Models as component Models. These may contain further Models as components. A number of levels of nesting are therefore possible.
Models that do not contain other Models are referred to as simple Models.

If one or more models has been changed, it notifies interested views of the change. Several Models can notifies the same view and several Views or Controller can access the same Model.

Information

All Model class should be create inheriting from Global class ZSAPMVC_MODEL that contains Attributes, Methods and Events important to the processing. Others components can be added to the class.

All Model Instance must be created thru the static method CREATE_MODEL as described in USE section.

The Static method CREATE_MODEL should be called by method CREATE_MODEL of class ZSAPMVC_CONTROLLER.

All Exceptions in class ZSAPMVC_MODEL must be handled thru the Exception class ZCX_SAPMVC.

VIEW_NOTIFICATION - Setup the Data Change Condition, It will be called automatically after the notification through zsapmvc_view=>activate_change_notification. The implementation must be made in subclass method if necessary !

ZSAPMVC_VIEW

It contains atributes, methods and events necessary to renders the contents of ZSAPMVC_MODEL and trigger the events handled by ZSAPMVC_CONTROLLER.

Each View has its own instance and can access one or more Model and can be accessed by one or more Controller.

The View methods are called within Modules in PAI and PBO.

The View methods trigger the events handled by event handler of Controller.

Information

The class ZSAPMVC_VIEW contains all Methods and Events important to the processing, but if you need to add more components or functionality you should create a new class inheriting from Global class ZSAPMVC_VIEW.

All View Instance must be created thru the static method CREATE_VIEW as described in USE section.

All Exceptions in class ZSAPMVC_VIEW must be handled thru the Exception class ZCX_SAPMVC.

Methods

- SET_VIEW_REFERENCE - Register the Class View name and link to program and Dynpro. This information is used by method CREATE_VIEW during the View instance creation. This method is optional, we can inform the view class reference directly to method CREATE_VIEW.

Use this method only if you have a class inheriting from "ZSAPMVC_VIEW" or its subclasses. Otherwise use the method CREATE_VIEW without view reference thus a new instance of "ZSAPMVC_VIEW" is created.

ZSAPMVC_CONTROLLER

It contains atributes and methods necessary to handle the user's interactions with the view (ZSAPMVC_VIEW) and get and perform data to model (ZSAPMVC_MODEL).

The Controller methods handle the events of View.

Information

The class ZSAPMVC_CONTROLLER contains all Methods to handle the View events, we should inherit the class and implement all necessary methods also we can to add more components or functionality to the inherited class.

All Controller Instance must be created thru the static method CREATE_CONTROLLER as described in USE section.

All Exceptions in class ZSAPMVC_CONTROLLER must be handled thru the Exception class ZCX_SAPMVC.

Methods

- SET_CONTROLLER_REFERENCE - Register the Class Controller name and link to Program and Dynpro. This information is used by method CREATE_CONTROLLER during the Controller instance creation. This method is optional, we can inform the Controller class reference directly to method CREATE_CONTROLLER.