Skip to content

Commit 44ac433

Browse files
authored
Update odata.md
1 parent 43c5cc5 commit 44ac433

File tree

1 file changed

+45
-49
lines changed

1 file changed

+45
-49
lines changed

docs/development/specific/odata.md

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,67 +5,39 @@ By default, you can bind all public attributes of your implementation class to U
55
### Define Second Model
66
As an example, we will use the test OData service `/sap/opu/odata/DMO/API_TRAVEL_U_V2/`, which is available in most ABAP systems. Ensure the service is publicly accessible. Use the following method to define the model and make it available under the name `TRAVEL`:
77
```abap
8-
client->follow_up_action( client->_event_client(
9-
val = z2ui5_if_client=>cs_event-set_odata_model
10-
t_arg = value #(
11-
( `/sap/opu/odata/DMO/API_TRAVEL_U_V2/` )
12-
( `TRAVEL` ) ) ) ).
8+
client->follow_up_action( client->_event_client(
9+
val = z2ui5_if_client=>cs_event-set_odata_model
10+
t_arg = value #(
11+
( `/sap/opu/odata/DMO/API_TRAVEL_U_V2/` )
12+
( `TRAVEL` ) ) ) ).
1313
```
1414
### Bind Data
1515
Next, bind this OData model to your view definition. Since we’re using a non-default model, we must explicitly specify the model name for each binding. Here's an example:
1616
```abap
17-
DATA(view) = z2ui5_cl_xml_view=>factory( )->page( ).
18-
DATA(tab) = view->table(
19-
items = `{FLIGHT>/Airport}`
20-
growing = abap_true ).
21-
22-
tab->columns(
23-
)->column( )->text( 'AirportID' )->get_parent(
24-
)->column( )->text( 'Name' )->get_parent(
25-
)->column( )->text( 'City' )->get_parent(
26-
)->column( )->text( 'CountryCode' ).
27-
28-
tab->items( )->column_list_item( )->cells(
29-
)->text( '{FLIGHT>AirportID}'
30-
)->text( '{FLIGHT>Name}'
31-
)->text( '{FLIGHT>City}'
32-
)->text( '{FLIGHT>CountryCode}' ).
33-
```
34-
By using the growing property we can make use of the feautre that not all data is loaded at once, leveraging performance.
17+
DATA(tab) = z2ui5_cl_xml_view=>factory( )->page( )->table(
18+
items = `{FLIGHT>/Airport}`
19+
growing = abap_true ).
3520
36-
### Multiple OData Models
37-
You can bind multiple OData models simultaneously by defining additional OData models. Here’s an example:
38-
```abap
39-
tab = page->table(
40-
items = `{FLIGHT>/Airport}`
41-
growing = abap_true ).
42-
43-
tab->columns(
44-
)->column( )->text( 'AirportID' )->get_parent(
45-
)->column( )->text( 'Name' )->get_parent(
46-
)->column( )->text( 'City' )->get_parent(
47-
)->column( )->text( 'CountryCode' )->get_parent( ).
21+
tab->columns(
22+
)->column( )->text( 'AirportID' )->get_parent(
23+
)->column( )->text( 'Name' )->get_parent(
24+
)->column( )->text( 'City' )->get_parent(
25+
)->column( )->text( 'CountryCode' ).
4826
49-
tab->items( )->column_list_item( )->cells(
50-
)->text( '{FLIGHT>AirportID}'
51-
)->text( '{FLIGHT>Name}'
52-
)->text( '{FLIGHT>City}'
53-
)->text( '{FLIGHT>CountryCode}' ).
54-
55-
client->follow_up_action( client->_event_client(
56-
val = z2ui5_if_client=>cs_event-set_odata_model
57-
t_arg = value #(
58-
( `/sap/opu/odata/DMO/ui_flight_r_v2/` )
59-
( `FLIGHT` ) ) ) ).
27+
tab->items( )->column_list_item( )->cells(
28+
)->text( '{FLIGHT>AirportID}'
29+
)->text( '{FLIGHT>Name}'
30+
)->text( '{FLIGHT>City}'
31+
)->text( '{FLIGHT>CountryCode}' ).
6032
```
33+
By using the growing property we can make use of the feautre that not all data is loaded at once, leveraging performance.
6134

6235
### Full Example
6336
Here’s the complete source code for one OData model:
6437
```abap
6538
METHOD z2ui5_if_app~main.
6639
67-
DATA(view) = z2ui5_cl_xml_view=>factory( )->page( ).
68-
DATA(tab) = view->table(
40+
DATA(tab) = z2ui5_cl_xml_view=>factory( )->page( )->table(
6941
items = `{TRAVEL>/BookingSupplement}`
7042
growing = abap_true ).
7143
@@ -95,6 +67,30 @@ METHOD z2ui5_if_app~main.
9567
9668
ENDMETHOD.
9769
```
98-
For a fully functional code snippet, check out the sample `Z2UI5_CL_DEMO_APP_315`.
9970

71+
### Multiple OData Models
72+
You can also bind multiple OData models simultaneously by defining additional OData models. Here’s an example:
73+
```abap
74+
tab = page->table(
75+
items = `{FLIGHT>/Airport}`
76+
growing = abap_true ).
77+
78+
tab->columns(
79+
)->column( )->text( 'AirportID' )->get_parent(
80+
)->column( )->text( 'Name' )->get_parent(
81+
)->column( )->text( 'City' )->get_parent(
82+
)->column( )->text( 'CountryCode' )->get_parent( ).
83+
84+
tab->items( )->column_list_item( )->cells(
85+
)->text( '{FLIGHT>AirportID}'
86+
)->text( '{FLIGHT>Name}'
87+
)->text( '{FLIGHT>City}'
88+
)->text( '{FLIGHT>CountryCode}' ).
10089
90+
client->follow_up_action( client->_event_client(
91+
val = z2ui5_if_client=>cs_event-set_odata_model
92+
t_arg = value #(
93+
( `/sap/opu/odata/DMO/ui_flight_r_v2/` )
94+
( `FLIGHT` ) ) ) ).
95+
```
96+
For a fully functional code snippet, check out the sample `Z2UI5_CL_DEMO_APP_315`.

0 commit comments

Comments
 (0)