Use
You can call a main controller, sub-controller in two ways:
Option A is more flexible than Option B, especially if the sub-controller should be initialized once only in method
Procedure
Option A
... data: addresscontroller type ref to CL_C_MYPROJ_ADDRESS. * create the controller addresscontroller ?= create_controller( controller_name = 'address.do' component_id = 'ad' ). * set some attributes with a self defined method addresscontroller->Init_data( ... ). ... |
or
... data: subcontroller type ref to CL_BSP_CONTROLLER2. * create the controller subcontroller ?= create_controller( controller_name = 'address.do' controller_id = 'ad' ). * set some attributes with standard method subcontroller->set_attributes( name = 'address' value = ship_address ). ... |
COMPONENT_ID
identifies the controller. In method CREATE_CONTROLLER this is the parameter COMPONENT_ID, and in <bsp:call>-element this is the attribute COMP_ID:
<%@page language="abap"%> <%@extension name="htmlb" prefix="htmlb"%> <%@extension name="bsp" prefix="bsp"%> <htmlb:content id="ComponentTest" > <htmlb:tray id = "tray1" <htmlb:tray id = "tray2" |
Option B
In this option, you do not need to create the sub-controller in the coding of the main controller. Instead you should only add the parameters to the view call, which then creates and calls the controller. In the following example,
ship_address is an attribute of the view and is set by the controller:
<%@page language="abap"%> <%@extension name="htmlb" prefix="htmlb"%> <%@extension name="bsp" prefix="bsp"%> <htmlb:content id="ComponentTest" > <htmlb:tray id = "tray1" <htmlb:tray id = "tray2" |
Continue by
Determining Input Processing.