You are on page 1of 4

Exercise # 8:

Objectives: Develop a web dynpro application with a view that displays two tables: a list of
flights and a list of bookings. The data displayed in the second table should depend on the
selected row in the first table.
Note: Supply function is used to make sure that the data in the second table is changed
whenever the user selects a different row in the first table.

Tasks required to be performed for developing the application:

1. Create Web dynpro component.


2. Create Web dynpro window.
3. Create two views one for accepting the user inputs as selection criteria and the other
view with two tables one for displaying the data in the table based on the selection
criteria and the other for displaying the data based on the record selected from the
first table.
• Use the web dynpro code wizard to create a table display with binding to the
context node FLIGHTTAB for the first table and BOOKINGTAB for the second table.
4. In the component context create node FLIGHTTAB with reference to SFLIGHT and a
sub-node of context node FLIGHTTAB (Suggested name: BOOKINGTAB) with reference
to the ABAP dictionary structure SBOOK and cardinality 0…n.
5. Make sure that the context node BOOKINGTAB also exists in the view OUTPUT_VIEW
and that this node is mapped to the BOOKINGTAB node of the component controller
context.
6. Create and implement a supply function to fill sub-node BOOKINGTAB according to the
lead selection of node FLIGHTAB.
• In the component context, double click the subnode.
• Enter the name for the supply function as attribute of property Supply Function
and double –click on the name.
• Remove the comment signs for the generated code.
• Declare a structure where the components correspond to the attributes of the
parent node (Suggested name: STRU_FLIGHTTAB).
• Add the code as shown below:
method BOOKINGS_READ .
* General Notes
* =============
* A common scenario for a supply method is to aquire key
* informations from the parameter <parent_element> and then
* to invoke a data provider.
* A free navigation thru the context, especially to nodes on
* the same or deeper hierachical level is strongly discouraged,
* because such a strategy may easily lead to unresolvable
* situations!!
* data declaration
data:
Itab_Bookingstab type
IF_COMPONENTCONTROLLER=>Elements_Bookingstab,
Stru_Bookingstab like line of Itab_Bookingstab,
Stru_flighttab type IF_COMPONENTCONTROLLER=>Element_flighttab.

CALL METHOD PARENT_ELEMENT->GET_STATIC_ATTRIBUTES


IMPORTING
STATIC_ATTRIBUTES = Stru_flighttab.

types:begin of ty_Bookingstab ,
CARRID type sbook-CARRID,
CONNID type sbook-CONNID,
FLDATE type sbook-FLDATE,
BOOKID type sbook-BOOKID,
CUSTOMID type sbook-CUSTOMID,
CLASS type sbook-CLASS,
FORCURAM type sbook-FORCURAM,
FORCURKEY type sbook-FORCURKEY,
ORDER_DATE type sbook-ORDER_DATE,
AGENCYNUM type sbook-AGENCYNUM,
CANCELLED type sbook-CANCELLED,
PASSNAME type sbook-PASSNAME,
PASSFORM type sbook-PASSFORM,
PASSBIRTH type sbook-PASSBIRTH,
end of ty_Bookingstab.
data:t_Bookingstab type standard table of ty_Bookingstab,
x_bookings type ty_Bookingstab.
select CARRID
CONNID
FLDATE
BOOKID
CUSTOMID
CLASS
FORCURAM
FORCURKEY
ORDER_DATE
AGENCYNUM
CANCELLED
PASSNAME
PASSFORM
PASSBIRTH
from sbook
into table t_Bookingstab
where carrid = stru_flighttab-carrid and
connid = stru_flighttab-connid and
fldate = stru_flighttab-fldate.
if not t_Bookingstab[] is initial.
loop at t_Bookingstab into x_bookings.
move-corresponding x_bookings to Stru_Bookingstab.
append Stru_Bookingstab to Itab_Bookingstab.
endloop.
CALL METHOD NODE->BIND_TABLE
EXPORTING
NEW_ITEMS = Itab_Bookingstab.
* SET_INITIAL_ELEMENTS = ABAP_TRUE
* INDEX =
endif.
endmethod.

7. Activate the component and create an Application and test the same.
8. The output appears as below:
9.

10. When Clicked on Submit:


11.

12. When selected any other row in the first table i.e., data record from SFLIGHT,
corresponding data from SBOOK table appears in the second table which is as below:
13.

You might also like