Exercise # 6: Objectives: Develop a web dynpro application to populate default values in the selection screen & display the label using the text objects from the OTR (Online Text Repository). Tasks required to be performed for developing the application: 1. Create Web dynpro component. 2. Create Web dynpro window. 3. Create a view with two input fields (Ex: Destination from & Destination To). 4. Select the labels of the input fields and modify the properties of the same on the screen by selecting the object from the OTR.
Click on the Value Help of the property text, to select the existing OTR texts, whose creation is already shown in the previous exercise.
2. Implement method WDDOINIT of the view controller.
Press WebDynpro code wizard button
Select read context node / Attribute and use the input help to choose the context node.
Replace the method call and modify the code as below. METHOD WDDOINIT. DATA: NODE_BAPI_FLIGHT_GETLIST TYPE NODE_IMPORTING TYPE NODE_DESTINATION_FROM TYPE ELEM_DESTINATION_FROM TYPE STRU_DESTINATION_FROM TYPE IF_INPUT_VIEW=>ELEMENT_DESTINATION_FROM.
REF REF REF REF
TO TO TO TO
IF_WD_CONTEXT_NODE, IF_WD_CONTEXT_NODE, IF_WD_CONTEXT_NODE, IF_WD_CONTEXT_ELEMENT,
* navigate from to via lead selection NODE_BAPI_FLIGHT_GETLIST = WD_CONTEXT->GET_CHILD_NODE( NAME = IF_INPUT_VIEW=>WDCTX_BAPI_FLIGHT_GETLIST ). * navigate from to via lead selection NODE_IMPORTING = NODE_BAPI_FLIGHT_GETLIST->GET_CHILD_NODE( NAME = IF_INPUT_VIEW=>WDCTX_IMPORTING ). * navigate from to via lead selection NODE_DESTINATION_FROM = NODE_IMPORTING->GET_CHILD_NODE( NAME = IF_INPUT_VIEW=>WDCTX_DESTINATION_FROM ). * get element via lead selection ELEM_DESTINATION_FROM = NODE_DESTINATION_FROM->GET_ELEMENT(
).
STRU_DESTINATION_FROM-CITY = 'FRANKFURT'. CALL METHOD ELEM_DESTINATION_FROM->SET_STATIC_ATTRIBUTES EXPORTING STATIC_ATTRIBUTES = STRU_DESTINATION_FROM. DATA: NODE_DESTINATION_TO TYPE REF TO IF_WD_CONTEXT_NODE, ELEM_DESTINATION_TO TYPE REF TO IF_WD_CONTEXT_ELEMENT, STRU_DESTINATION_TO TYPE IF_INPUT_VIEW=>ELEMENT_DESTINATION_TO .
* navigate from to via lead selection NODE_BAPI_FLIGHT_GETLIST = WD_CONTEXT->GET_CHILD_NODE( NAME = IF_INPUT_VIEW=>WDCTX_BAPI_FLIGHT_GETLIST ). * navigate from to via lead selection NODE_IMPORTING = NODE_BAPI_FLIGHT_GETLIST->GET_CHILD_NODE( NAME = IF_INPUT_VIEW=>WDCTX_IMPORTING ). * navigate from to via lead selection NODE_DESTINATION_TO = NODE_IMPORTING->GET_CHILD_NODE( NAME = IF_INPUT_VIEW=>WDCTX_DESTINATION_TO ). * get element via lead selection ELEM_DESTINATION_TO = NODE_DESTINATION_TO->GET_ELEMENT(
).
STRU_DESTINATION_TO-CITY = 'NEW YORK'. CALL METHOD ELEM_DESTINATION_TO->SET_STATIC_ATTRIBUTES EXPORTING STATIC_ATTRIBUTES = STRU_DESTINATION_TO. ENDMETHOD.
6
Activate the component and create an Application and test the same.
7
The output appears as below with the default values: