Show TOC

Part 4: Implementing the Data TransportLocate this document in the navigation structure

Procedure

To make the value of the CARRID attribute visible in the context of the Search view for the context of the Display view, first you need to create a cross-view context.

  1. In the object list, double-click on the ComponentController object.

    The Editor displays the context of the component controller.

  2. Select the root node of the context that is still empty.

  3. Use the context menu entry Create Using a Wizard to copy the data node from the Search view (or from Display ) to the root node of the context of the component controller.

  4. Save your entries.

  5. Switch to the object list by double-clicking on the display of the Search view, located on the Context tab page.

    The Editor, which is divided into two, displays the context of the component controller on the right-hand side.

  6. Define a mapping for the DATA node of the view context to the node with the same name of the component controller context:

    To do this, select the DATA node of the component controller and hold down the mouse button to drag it to the DATA node of the view context. When you let go of the mouse button, the mapping that was defined by this operation is displayed by a small black arrow in the icon for the view context node. The mapping path to the node of the component controller is also specified in the properties table for this node.

    The value that the CARRID attribute obtains at runtime can be passed forwards to the component controller using the mapping.

    Save the view.

  7. Open the DISPLAY view by double-clicking on it in the object list and switch to the Context tab page.

  8. Define mapping for the DATA node of the view context to the node of the component controller context with the same name.

    The value for the CARRID attribute, which the component controller receives from the Search view, can be passed to the context of the Display view in this way.

    Next, you have to equip the flights context node with a supply function.

  9. Select the flights node and enter in the Supply Function line in the properties table getflights .

    The required method is created automatically during the save.

  10. By double-clicking on the name of the function, branch to the ABAP Editor to program the method getflights (see source code below).

You have now designed the layout of the two views and implemented the data transport.

To complete the application, continue with Part 5: Setting Up Navigation .

Source Code for the GETFLIGHTS Method

Caution

In this example, the programming of the data retrieval has been shortened considerably so that Web Dynpro is easier to understand. In a real application, a select call to a database table should never be implemented within a method of the Web Dynpro framework, for example. Create a separate class to retrieve the data, for example.

method GETFLIGHTS.
  data:         datanode type ref to if_wd_context_node,
                value type string,
                flighttab type standard table of sflight.
* Einlesen der Referenz auf den Knoten des lokalen Contextes:
  datanode = wd_context->get_child_node( name = 'DATA' ).
* Auf Grund des Mappings auf den Knoten 'DATA' des Component-Controllers
* enthält dieser Knoten den vom Benutzer eingegebenen Wert für das Attribut
* 'CARRID'.
* Dieser Wert wird dann folgenden Schritt ausgelesen:
  datanode->get_attribute( exporting name = 'CARRID' importing value = value ).
* Jetzt kann die interne Tabelle 'flighttab' gefüllt werden:
  select * from sflight into table flighttab
  where CARRID = value.
* Die interne Tabelle muss nun noch an den aktuellen Context-Knoten gebunden
* werden:
  node->bind_elements( flighttab ).
endmethod.