Professional Documents
Culture Documents
Contents:
The Context At Runtime Understand the controller methods that are available to you for application coding The Context API
After completing this topic, you will be able to: Understand how to access nodes and attributes in the context using the context API.
Other WD Controllers
Custom Controller
Component Usage
Other WD Components
All controllers have these two standard hook methods. The method will only be called during the controllers lifecycle if they contain coding.
Other WD Controllers
Custom Controller
Component Usage
Other WD Components
WD_COMP_CONTROLLER
present in any WD controller. reference to the component controller with access to all public methods and attributes. Attribute will automatically assigned to all view controllers when a view is created. For all other controller the WD_COMP_CONTROLLER attribute will be assigned, when the properties of the controller the component controller is used.
SAP AG 2005, Title of Presentation / Speaker Name / #
WDDOBEFORENAVIGATION
It is executed before the navigation stack is processed
WDDOPOSTPROCESSING Data from multiple components can be validated before the next step is
execute
Flights
CARRID CONNID CARRID 2 CONNID CARRID 1 CONNID
..n
data: Node_Flights
* navigate from <CONTEXT> to <FLIGHTS> via lead selection Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ). * @TODO handle not set lead selection if ( Node_Flights is initial ). endif.
Flights
CARRID CONNID CARRID 2 CONNID CARRID 1 CONNID
..n
* navigate from <CONTEXT> to <FLIGHTS> via lead selection Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ). * get element via lead selection Elem_Flights = Node_Flights->get_Element( * @TODO handle not set lead selection if ( Elem_Flights is initial ). endif.
).
Flights
CARRID CONNID CARRID 2 CONNID CARRID 1 CONNID
..n
* navigate from <CONTEXT> to <FLIGHTS> via lead selection Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ). * get element via lead selection Elem_Flights = Node_Flights->get_Element(
).
* get single attribute Elem_Flights->get_Attribute( exporting Name = `CARRID` importing Value = Item_Carrid ).
SAP AG 2005, Title of Presentation / Speaker Name / #
Flights
CARRID CONNID CARRID 2 CONNID CARRID 1 CONNID
..n
* navigate from <CONTEXT> to <FLIGHTS> via lead selection Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ). * get element via lead selection Elem_Flights = Node_Flights->get_Element(
).
Flights
CARRID CONNID CARRID 2 CONNID CARRID 1 CONNID
..n
Itab
* navigate from <CONTEXT> to <FLIGHTS> via lead selection Node_Flights = wd_Context->get_Child_Node( Name = `FLIGHTS` ). * @TODO handle not set lead selection if ( Node_Flights is initial ). endif. * get all node element Node_Flights->GET_STATIC_ATTRIBUTES_TABLE( importing table = lt_Flights ).
FLIGHTS
* navigate from <CONTEXT> to <FLIGHTS> via lead selection node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ).
FLIGHTS
data: Node_Flights type ref to If_Wd_Context_Node, First_flight_Elem type ref to If_Wd_Context_Element. * navigate from <CONTEXT> to <FLIGHTS> via lead selection node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ). * create new element for node FLIGHTS First_flight_Elem = Node_Flights->create_element(
).
FLIGHTS
CARRID
CONNID
data: Node_Flights type ref to If_Wd_Context_Node, First_flight_Elem type ref to If_Wd_Context_Element. * navigate from <CONTEXT> to <FLIGHTS> via lead selection node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ). * create new element for node FLIGHTS First_flight_Elem = Node_Flights->create_element(
).
* set attributes First_flight_Elem->set_attribute( name = 'CARRID' value = 'LH' ). First_flight_Elem->set_attribute( name = 'CONNID' value = '400' ).
FLIGHTS
CARRID CONNID
data: Node_Flights type ref to If_Wd_Context_Node, First_flight_Elem type ref to If_Wd_Context_Element. * navigate from <CONTEXT> to <FLIGHTS> via lead selection node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ). * create new element for node FLIGHTS First_flight_Elem = Node_Flights->create_element(
).
* set attributes First_flight_Elem->set_attribute( name = 'CARRID' value = 'LH' ). First_flight_Elem->set_attribute( name = 'CONNID' value = '400' ). * bind first element to node Node_Flights->bind_element( new_item = First_flight_Elem SET_INITIAL_ELEMENTS = abap_false ). SAP AG 2005, Title of Presentation / Speaker Name / #
data: Node_Flights type ref to If_Wd_Context_Node, Stru_flights type If_Componentcontroller=>Element_flights. * navigate from <CONTEXT> to <FLIGHTS> via lead selection node_flights = wd_context->get_child_node( Name = 'FLIGHTS' ).
* set values to node->attributes Stru_flights-carrid = 'AA'. Stru_flights-connid = '017'. * bind new element to node Node_flights->bind_structure( new_item = Stru_flights SET_INITIAL_ELEMENTS = abap_false ).
FLIGHTS
CARRID
CARRID CONNID
1
Itab
data: Node_Flights type ref to If_Wd_Context_Node, lt_flights type If_Componentcontroller=>Elements_flights, Stru_flights like line of lt_flights.
* append values to local table Stru_flights-carrid = 'LH'. Stru_flights-connid = '400'. append Stru_flights to lt_flights.
Stru_flights-carrid = 'AA'. Stru_flights-connid = '017'. append Stru_flights to lt_flights. * get node reference Node_Flights = wd_context->get_child_node( 'FLIGHTS' ). * bind local table Node_Flights->bind_table( lt_flights ). SAP AG 2005, Title of Presentation / Speaker Name / #
You should now be able to: Understand how to access nodes and attributes in the context using the context API